LBP features integrated in CascadeClassifier_GPU
This commit is contained in:
parent
2dc93574e1
commit
1b7ad93dc9
@ -1397,7 +1397,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////// CascadeClassifier_GPU //////////////////////////////////////////
|
////////////////////////////////// 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
|
class CV_EXPORTS CascadeClassifier_GPU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -1407,42 +1407,28 @@ public:
|
|||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
bool load(const std::string& filename);
|
bool load(const std::string& filename);
|
||||||
void release();
|
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;
|
|
||||||
|
|
||||||
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;
|
struct CascadeClassifierImpl;
|
||||||
CascadeClassifierImpl* impl;
|
CascadeClassifierImpl* impl;
|
||||||
};
|
struct HaarCascade;
|
||||||
|
struct LbpCascade;
|
||||||
////////////////////////////////// SURF //////////////////////////////////////////
|
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
|
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 img(img_host);
|
||||||
cv::gpu::GpuMat gpu_rects;
|
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")));
|
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml")));
|
||||||
|
|
||||||
cascade.detectMultiScale(img, gpu_rects);
|
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;
|
const int block = 128;
|
||||||
int grid = divUp(workAmount, block);
|
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);
|
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);
|
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)
|
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";
|
std::string classifierXmlPath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/lbpcascade_frontalface.xml";
|
||||||
ASSERT_TRUE(classifier.load(classifierXmlPath));
|
ASSERT_TRUE(classifier.load(classifierXmlPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_Read_classifier,
|
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_Read_classifier,
|
||||||
testing::Combine(ALL_DEVICES, testing::Values<int>(0)));
|
testing::Combine(ALL_DEVICES, testing::Values<int>(0)));
|
||||||
|
|
||||||
|
|
||||||
PARAM_TEST_CASE(LBP_classify, cv::gpu::DeviceInfo, int)
|
PARAM_TEST_CASE(LBP_classify, cv::gpu::DeviceInfo, int)
|
||||||
@ -344,7 +344,7 @@ TEST_P(LBP_classify, Accuracy)
|
|||||||
for (; it != rects.end(); ++it)
|
for (; it != rects.end(); ++it)
|
||||||
cv::rectangle(markedImage, *it, CV_RGB(0, 0, 255));
|
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));
|
ASSERT_TRUE(gpuClassifier.load(classifierXmlPath));
|
||||||
|
|
||||||
cv::gpu::GpuMat gpu_rects;
|
cv::gpu::GpuMat gpu_rects;
|
||||||
@ -352,23 +352,23 @@ TEST_P(LBP_classify, Accuracy)
|
|||||||
int count = gpuClassifier.detectMultiScale(tested, gpu_rects);
|
int count = gpuClassifier.detectMultiScale(tested, gpu_rects);
|
||||||
|
|
||||||
cv::Mat downloaded(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++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
cv::Rect r = faces[i];
|
cv::Rect r = faces[i];
|
||||||
|
|
||||||
#if defined (LOG_CASCADE_STATISTIC)
|
#if defined (LOG_CASCADE_STATISTIC)
|
||||||
std::cout << r.x << " " << r.y << " " << r.width << " " << r.height << std::endl;
|
std::cout << r.x << " " << r.y << " " << r.width << " " << r.height << std::endl;
|
||||||
#endif
|
|
||||||
cv::rectangle(markedImage, r , CV_RGB(255, 0, 0));
|
cv::rectangle(markedImage, r , CV_RGB(255, 0, 0));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined (LOG_CASCADE_STATISTIC)
|
#if defined (LOG_CASCADE_STATISTIC)
|
||||||
cv::imshow("Res", markedImage); cv::waitKey();
|
cv::imshow("Res", markedImage); cv::waitKey();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_classify,
|
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
|
} // namespace
|
||||||
|
Loading…
x
Reference in New Issue
Block a user