fix bug when used as lib

This commit is contained in:
jario 2024-01-02 14:02:34 +08:00
parent cc715bef70
commit 9612f9fe83
6 changed files with 54 additions and 81 deletions

View File

@ -9,7 +9,7 @@
#endif #endif
#ifdef WITH_INTEL #ifdef WITH_INTEL
#include<openvino/openvino.hpp> #include <openvino/openvino.hpp>
#include "common_det_intel_impl.h" #include "common_det_intel_impl.h"
#endif #endif

View File

@ -1002,11 +1002,11 @@ void CommonObjectDetectorBase::detect(cv::Mat img_, TargetsInFrame& tgts_, Box*
if (this->_with_segmentation) if (this->_with_segmentation)
{ {
cv::Mat mask_j = boxes_seg[j].clone(); cv::Mat mask_j = boxes_seg[j].clone();
#ifdef WITH_INTEL #ifdef WITH_INTEL
tgt.setMask(mask_j); tgt.setMask(mask_j);
#endif #endif
#ifdef WITH_CUDA #ifdef WITH_CUDA
int maskh = mask_j.rows, maskw = mask_j.cols; int maskh = mask_j.rows, maskw = mask_j.cols;
assert(maskh == maskw); assert(maskh == maskw);
@ -1036,7 +1036,7 @@ void CommonObjectDetectorBase::detect(cv::Mat img_, TargetsInFrame& tgts_, Box*
{ {
tgt.setMask(mask_j); tgt.setMask(mask_j);
} }
#endif #endif
} }
tgts_.targets.push_back(tgt); tgts_.targets.push_back(tgt);

View File

@ -25,7 +25,6 @@ public:
double line_location_a2; double line_location_a2;
bool is_load_parameter; bool is_load_parameter;
std::string line_color; std::string line_color;
protected: protected:
@ -40,4 +39,4 @@ protected:
void seg(cv::Mat line_area_, cv::Mat line_area_a1_, cv::Mat line_area_a2_, std::string line_color_, cv::Point &center_, int &area_, cv::Point &center_a1_, cv::Point &center_a2_); void seg(cv::Mat line_area_, cv::Mat line_area_a1_, cv::Mat line_area_a2_, std::string line_color_, cv::Point &center_, int &area_, cv::Point &center_a1_, cv::Point &center_a2_);
}; };
} }
#endif #endif

View File

@ -10,42 +10,34 @@
namespace sv namespace sv
{ {
#ifdef WITH_CUDA
class CommonObjectDetectorCUDAImpl;
#endif
#ifdef WITH_INTEL class CommonObjectDetectorCUDAImpl;
class CommonObjectDetectorIntelImpl; class CommonObjectDetectorIntelImpl;
#endif
class CommonObjectDetector : public CommonObjectDetectorBase
{
public:
CommonObjectDetector(bool input_4k = false);
~CommonObjectDetector();
protected: class CommonObjectDetector : public CommonObjectDetectorBase
bool setupImpl(); {
void detectImpl( public:
cv::Mat img_, CommonObjectDetector(bool input_4k = false);
std::vector<float> &boxes_x_, ~CommonObjectDetector();
std::vector<float> &boxes_y_,
std::vector<float> &boxes_w_,
std::vector<float> &boxes_h_,
std::vector<int> &boxes_label_,
std::vector<float> &boxes_score_,
std::vector<cv::Mat> &boxes_seg_);
#ifdef WITH_CUDA protected:
CommonObjectDetectorCUDAImpl *_cuda_impl; bool setupImpl();
#endif void detectImpl(
cv::Mat img_,
std::vector<float> &boxes_x_,
std::vector<float> &boxes_y_,
std::vector<float> &boxes_w_,
std::vector<float> &boxes_h_,
std::vector<int> &boxes_label_,
std::vector<float> &boxes_score_,
std::vector<cv::Mat> &boxes_seg_);
#ifdef WITH_INTEL CommonObjectDetectorCUDAImpl *_cuda_impl;
CommonObjectDetectorIntelImpl *_intel_impl; CommonObjectDetectorIntelImpl *_intel_impl;
#endif
bool _input_4k; bool _input_4k;
}; };
} }
#endif #endif

View File

@ -10,13 +10,9 @@
namespace sv { namespace sv {
#ifdef WITH_CUDA
class LandingMarkerDetectorCUDAImpl;
#endif
#ifdef WITH_INTEL class LandingMarkerDetectorCUDAImpl;
class LandingMarkerDetectorIntelImpl; class LandingMarkerDetectorIntelImpl;
#endif
class LandingMarkerDetector : public LandingMarkerDetectorBase class LandingMarkerDetector : public LandingMarkerDetectorBase
{ {
@ -30,13 +26,8 @@ protected:
std::vector<int>& output_labels_ std::vector<int>& output_labels_
); );
#ifdef WITH_CUDA LandingMarkerDetectorCUDAImpl *_cuda_impl;
LandingMarkerDetectorCUDAImpl *_cuda_impl; LandingMarkerDetectorIntelImpl *_intel_impl;
#endif
#ifdef WITH_INTEL
LandingMarkerDetectorIntelImpl *_intel_impl;
#endif
}; };

View File

@ -10,44 +10,35 @@
namespace sv namespace sv
{ {
#ifdef WITH_CUDA
class VeriDetectorCUDAImpl;
#endif
#ifdef WITH_INTEL class VeriDetectorCUDAImpl;
class VeriDetectorIntelImpl; class VeriDetectorIntelImpl;
#endif
class VeriDetector : public LandingMarkerDetectorBase class VeriDetector : public LandingMarkerDetectorBase
{ {
public: public:
VeriDetector(); VeriDetector();
~VeriDetector(); ~VeriDetector();
void detect(cv::Mat img_, const cv::Rect &bounding_box_, sv::Target &tgt); void detect(cv::Mat img_, const cv::Rect &bounding_box_, sv::Target &tgt);
protected: protected:
void _load(); void _load();
bool setupImpl(); bool setupImpl();
void roiCNN( void roiCNN(
std::vector<cv::Mat> &input_rois_, std::vector<cv::Mat> &input_rois_,
std::vector<float> &output_labels_); std::vector<float> &output_labels_);
void getSubwindow(cv::Mat &dstCrop, cv::Mat &srcImg, int originalSz, int resizeSz); void getSubwindow(cv::Mat &dstCrop, cv::Mat &srcImg, int originalSz, int resizeSz);
std::string vehicle_id; std::string vehicle_id;
// Save the target bounding box for each frame. // Save the target bounding box for each frame.
std::vector<float> targetSz = {0, 0}; // H and W of bounding box std::vector<float> targetSz = {0, 0}; // H and W of bounding box
std::vector<float> targetPos = {0, 0}; // center point of bounding box (x, y) std::vector<float> targetPos = {0, 0}; // center point of bounding box (x, y)
#ifdef WITH_CUDA VeriDetectorCUDAImpl *_cuda_impl;
VeriDetectorCUDAImpl *_cuda_impl; VeriDetectorIntelImpl *_intel_impl;
#endif };
#ifdef WITH_INTEL
VeriDetectorIntelImpl *_intel_impl;
#endif
};
} }
#endif #endif