mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 21:20:18 +08:00
LBP features integrated in CascadeClassifier_GPU
This commit is contained in:
parent
2dc93574e1
commit
1b7ad93dc9
@ -1397,7 +1397,7 @@ public:
|
||||
};
|
||||
|
||||
////////////////////////////////// CascadeClassifier_GPU //////////////////////////////////////////
|
||||
// The cascade classifier class for object detection.
|
||||
// The cascade classifier class for object detection: supports old haar and new lbp xlm formats and nvbin for haar cascades olny.
|
||||
class CV_EXPORTS CascadeClassifier_GPU
|
||||
{
|
||||
public:
|
||||
@ -1407,42 +1407,28 @@ public:
|
||||
|
||||
bool empty() const;
|
||||
bool load(const std::string& filename);
|
||||
void release();
|
||||
|
||||
/* returns number of detected objects */
|
||||
int detectMultiScale(const GpuMat& image, GpuMat& objectsBuf, double scaleFactor=1.2, int minNeighbors=4, Size minSize=Size());
|
||||
|
||||
bool findLargestObject;
|
||||
bool visualizeInPlace;
|
||||
|
||||
Size getClassifierSize() const;
|
||||
private:
|
||||
|
||||
struct CascadeClassifierImpl;
|
||||
CascadeClassifierImpl* impl;
|
||||
};
|
||||
|
||||
// The cascade classifier class for object detection.
|
||||
class CV_EXPORTS CascadeClassifier_GPU_LBP
|
||||
{
|
||||
public:
|
||||
CascadeClassifier_GPU_LBP(cv::Size detectionFrameSize = cv::Size());
|
||||
~CascadeClassifier_GPU_LBP();
|
||||
|
||||
bool empty() const;
|
||||
bool load(const std::string& filename);
|
||||
void release();
|
||||
|
||||
int detectMultiScale(const GpuMat& image, GpuMat& objectsBuf, double scaleFactor = 1.1, int minNeighbors = 4,
|
||||
cv::Size maxObjectSize = cv::Size()/*, Size minSize = Size()*/);
|
||||
Size getClassifierSize() const;
|
||||
void release();
|
||||
|
||||
private:
|
||||
/* returns number of detected objects */
|
||||
int detectMultiScale(const GpuMat& image, GpuMat& objectsBuf, double scaleFactor = 1.2, int minNeighbors = 4, Size minSize = Size());
|
||||
|
||||
bool findLargestObject;
|
||||
bool visualizeInPlace;
|
||||
|
||||
Size getClassifierSize() const;
|
||||
|
||||
private:
|
||||
struct CascadeClassifierImpl;
|
||||
CascadeClassifierImpl* impl;
|
||||
};
|
||||
|
||||
////////////////////////////////// SURF //////////////////////////////////////////
|
||||
struct HaarCascade;
|
||||
struct LbpCascade;
|
||||
friend class CascadeClassifier_GPU_LBP;
|
||||
|
||||
public:
|
||||
int detectMultiScale(const GpuMat& image, GpuMat& objectsBuf, Size maxObjectSize, Size minSize = Size(), double scaleFactor = 1.1, int minNeighbors = 4);
|
||||
};
|
||||
|
||||
////////////////////////////////// SURF //////////////////////////////////////////
|
||||
|
||||
class CV_EXPORTS SURF_GPU
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ GPU_PERF_TEST_1(LBPClassifier, cv::gpu::DeviceInfo)
|
||||
|
||||
cv::gpu::GpuMat img(img_host);
|
||||
cv::gpu::GpuMat gpu_rects;
|
||||
cv::gpu::CascadeClassifier_GPU_LBP cascade(img.size());
|
||||
cv::gpu::CascadeClassifier_GPU cascade;
|
||||
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml")));
|
||||
|
||||
cascade.detectMultiScale(img, gpu_rects);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -290,6 +290,7 @@ namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
const int block = 128;
|
||||
int grid = divUp(workAmount, block);
|
||||
cudaFuncSetCacheConfig(lbp_cascade, cudaFuncCachePreferL1);
|
||||
Cascade cascade((Stage*)mstages.ptr(), nstages, (ClNode*)mnodes.ptr(), mleaves.ptr(), msubsets.ptr(), (uchar4*)mfeatures.ptr(), subsetSize);
|
||||
lbp_cascade<<<grid, block>>>(cascade, frameW, frameH, windowW, windowH, initialScale, factor, workAmount, integral.ptr(), integral.step / sizeof(int), objects, classified);
|
||||
}
|
||||
|
@ -302,13 +302,13 @@ PARAM_TEST_CASE(LBP_Read_classifier, cv::gpu::DeviceInfo, int)
|
||||
|
||||
TEST_P(LBP_Read_classifier, Accuracy)
|
||||
{
|
||||
cv::gpu::CascadeClassifier_GPU_LBP classifier;
|
||||
cv::gpu::CascadeClassifier_GPU classifier;
|
||||
std::string classifierXmlPath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/lbpcascade_frontalface.xml";
|
||||
ASSERT_TRUE(classifier.load(classifierXmlPath));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_Read_classifier,
|
||||
testing::Combine(ALL_DEVICES, testing::Values<int>(0)));
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_Read_classifier,
|
||||
testing::Combine(ALL_DEVICES, testing::Values<int>(0)));
|
||||
|
||||
|
||||
PARAM_TEST_CASE(LBP_classify, cv::gpu::DeviceInfo, int)
|
||||
@ -344,7 +344,7 @@ TEST_P(LBP_classify, Accuracy)
|
||||
for (; it != rects.end(); ++it)
|
||||
cv::rectangle(markedImage, *it, CV_RGB(0, 0, 255));
|
||||
|
||||
cv::gpu::CascadeClassifier_GPU_LBP gpuClassifier;
|
||||
cv::gpu::CascadeClassifier_GPU gpuClassifier;
|
||||
ASSERT_TRUE(gpuClassifier.load(classifierXmlPath));
|
||||
|
||||
cv::gpu::GpuMat gpu_rects;
|
||||
@ -352,23 +352,23 @@ TEST_P(LBP_classify, Accuracy)
|
||||
int count = gpuClassifier.detectMultiScale(tested, gpu_rects);
|
||||
|
||||
cv::Mat downloaded(gpu_rects);
|
||||
const cv::Rect* faces = downloaded.ptr<cv::Rect>();
|
||||
const cv::Rect* faces = downloaded.ptr<cv::Rect>();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
cv::Rect r = faces[i];
|
||||
|
||||
#if defined (LOG_CASCADE_STATISTIC)
|
||||
std::cout << r.x << " " << r.y << " " << r.width << " " << r.height << std::endl;
|
||||
#endif
|
||||
std::cout << r.x << " " << r.y << " " << r.width << " " << r.height << std::endl;
|
||||
cv::rectangle(markedImage, r , CV_RGB(255, 0, 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (LOG_CASCADE_STATISTIC)
|
||||
cv::imshow("Res", markedImage); cv::waitKey();
|
||||
cv::imshow("Res", markedImage); cv::waitKey();
|
||||
#endif
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_classify,
|
||||
testing::Combine(ALL_DEVICES, testing::Values<int>(0)));
|
||||
testing::Combine(ALL_DEVICES, testing::Values<int>(0)));
|
||||
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user