Add OPENCV_CUDA define, to allow having preprocess both in CPU and GPU (Mobilenet and Centernet)

Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
Micaela Verucchi
2020-03-20 10:21:11 +01:00
parent 58fe723b6a
commit c7d9c38ea0
5 changed files with 111 additions and 33 deletions
+14 -6
View File
@@ -35,9 +35,7 @@ class CenternetDetection {
int ndets = 0;
// tk::dnn::Yolo::detection *dets = nullptr;
cv::Mat imageF;
cv::cuda::GpuMat imageF1_d, imageF2_d;
cv::cuda::GpuMat bgr[3];
cv::Mat imageOrig;
// std::vector< cv::cuda::GpuMat > bgr;
// variable to test cnet on dog pictures
@@ -71,8 +69,16 @@ class CenternetDetection {
float *target_coords;
float *mean_d;
float *stddev_d;
#ifdef OPENCV_CUDA
float *mean_d;
float *stddev_d;
#else
cv::Vec<float, 3> mean;
cv::Vec<float, 3> stddev;
dnnType *input;
#endif
float *d_ptrs;
@@ -88,6 +94,8 @@ class CenternetDetection {
// pointer used in the kernels
float *src_out;
int *ids_out;
void preprocess();
public:
dnnType *rt_out[4];
@@ -97,7 +105,7 @@ class CenternetDetection {
int classes = 80;
int num = 0;
int n_masks = 0;
float thresh = 0.0;
float thresh = 0.3;
cv::Scalar colors[256];
// this is filled with results
+1 -1
View File
@@ -83,7 +83,7 @@ private:
void generate_ssd_priors(const SSDSpec *specs, const int n_specs, bool clamp = true);
void convert_locatios_to_boxes_and_center();
float iou(const tk::dnn::box &a, const tk::dnn::box &b);
void preprocess(const bool gpu = true);
void preprocess();
std::vector<tk::dnn::box> postprocess(const int width, const int height);
float get_color2(int c, int x, int max);
+2
View File
@@ -14,6 +14,8 @@
#define dnnType float
#define OPENCV_CUDA
// Colored output
#define COL_END "\033[0m"