Bugs in the test for LatentSVM were fixed.
This commit is contained in:
parent
ef06694779
commit
110351d3de
@ -576,10 +576,21 @@ int searchObjectThresholdSomeComponents(const CvLSVMFeaturePyramid *H,
|
|||||||
for (i = 0; i < kComponents; i++)
|
for (i = 0; i < kComponents; i++)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_TBB
|
#ifdef HAVE_TBB
|
||||||
searchObjectThreshold(H, &(filters[componentIndex]), kPartFilters[i],
|
error = searchObjectThreshold(H, &(filters[componentIndex]), kPartFilters[i],
|
||||||
b[i], maxXBorder, maxYBorder, scoreThreshold,
|
b[i], maxXBorder, maxYBorder, scoreThreshold,
|
||||||
&(pointsArr[i]), &(levelsArr[i]), &(kPointsArr[i]),
|
&(pointsArr[i]), &(levelsArr[i]), &(kPointsArr[i]),
|
||||||
&(scoreArr[i]), &(partsDisplacementArr[i]), numThreads);
|
&(scoreArr[i]), &(partsDisplacementArr[i]), numThreads);
|
||||||
|
if (error != LATENT_SVM_OK)
|
||||||
|
{
|
||||||
|
// Release allocated memory
|
||||||
|
free(pointsArr);
|
||||||
|
free(oppPointsArr);
|
||||||
|
free(scoreArr);
|
||||||
|
free(kPointsArr);
|
||||||
|
free(levelsArr);
|
||||||
|
free(partsDisplacementArr);
|
||||||
|
return LATENT_SVM_SEARCH_OBJECT_FAILED;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
searchObjectThreshold(H, &(filters[componentIndex]), kPartFilters[i],
|
searchObjectThreshold(H, &(filters[componentIndex]), kPartFilters[i],
|
||||||
b[i], maxXBorder, maxYBorder, scoreThreshold,
|
b[i], maxXBorder, maxYBorder, scoreThreshold,
|
||||||
|
@ -95,16 +95,22 @@ CvSeq* cvLatentSvmDetectObjects(IplImage* image,
|
|||||||
CvPoint *oppPointsOut = 0;
|
CvPoint *oppPointsOut = 0;
|
||||||
float *scoreOut = 0;
|
float *scoreOut = 0;
|
||||||
CvSeq* result_seq = 0;
|
CvSeq* result_seq = 0;
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
cvConvertImage(image, image, CV_CVTIMG_SWAP_RB);
|
cvConvertImage(image, image, CV_CVTIMG_SWAP_RB);
|
||||||
// Getting maximum filter dimensions
|
// Getting maximum filter dimensions
|
||||||
getMaxFilterDims((const CvLSVMFilterObject**)(detector->filters), detector->num_components, detector->num_part_filters, &maxXBorder, &maxYBorder);
|
getMaxFilterDims((const CvLSVMFilterObject**)(detector->filters), detector->num_components,
|
||||||
|
detector->num_part_filters, &maxXBorder, &maxYBorder);
|
||||||
// Create feature pyramid with nullable border
|
// Create feature pyramid with nullable border
|
||||||
H = createFeaturePyramidWithBorder(image, maxXBorder, maxYBorder);
|
H = createFeaturePyramidWithBorder(image, maxXBorder, maxYBorder);
|
||||||
// Search object
|
// Search object
|
||||||
searchObjectThresholdSomeComponents(H, (const CvLSVMFilterObject**)(detector->filters), detector->num_components,
|
error = searchObjectThresholdSomeComponents(H, (const CvLSVMFilterObject**)(detector->filters),
|
||||||
detector->num_part_filters, detector->b, detector->score_threshold,
|
detector->num_components, detector->num_part_filters, detector->b, detector->score_threshold,
|
||||||
&points, &oppPoints, &score, &kPoints, numThreads);
|
&points, &oppPoints, &score, &kPoints, numThreads);
|
||||||
|
if (error != LATENT_SVM_OK)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
// Clipping boxes
|
// Clipping boxes
|
||||||
clippingBoxes(image->width, image->height, points, kPoints);
|
clippingBoxes(image->width, image->height, points, kPoints);
|
||||||
clippingBoxes(image->width, image->height, oppPoints, kPoints);
|
clippingBoxes(image->width, image->height, oppPoints, kPoints);
|
||||||
|
@ -44,6 +44,14 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <cvconfig.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_TBB
|
||||||
|
#include "tbb/task_scheduler_init.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
const int num_detections = 3;
|
const int num_detections = 3;
|
||||||
@ -77,7 +85,12 @@ void CV_LatentSVMDetectorTest::run( int /* start_from */)
|
|||||||
{
|
{
|
||||||
string img_path = string(ts->get_data_path()) + "latentsvmdetector/cat.jpg";
|
string img_path = string(ts->get_data_path()) + "latentsvmdetector/cat.jpg";
|
||||||
string model_path = string(ts->get_data_path()) + "latentsvmdetector/cat.xml";
|
string model_path = string(ts->get_data_path()) + "latentsvmdetector/cat.xml";
|
||||||
|
int numThreads = -1;
|
||||||
|
#ifdef HAVE_TBB
|
||||||
|
numThreads = 2;
|
||||||
|
tbb::task_scheduler_init init(tbb::task_scheduler_init::deferred);
|
||||||
|
init.initialize(numThreads);
|
||||||
|
#endif
|
||||||
IplImage* image = cvLoadImage(img_path.c_str());
|
IplImage* image = cvLoadImage(img_path.c_str());
|
||||||
if (!image)
|
if (!image)
|
||||||
{
|
{
|
||||||
@ -95,8 +108,7 @@ void CV_LatentSVMDetectorTest::run( int /* start_from */)
|
|||||||
|
|
||||||
CvMemStorage* storage = cvCreateMemStorage(0);
|
CvMemStorage* storage = cvCreateMemStorage(0);
|
||||||
CvSeq* detections = 0;
|
CvSeq* detections = 0;
|
||||||
detections = cvLatentSvmDetectObjects(image, detector, storage);
|
detections = cvLatentSvmDetectObjects(image, detector, storage, 0.5f, numThreads);
|
||||||
|
|
||||||
if (detections->total != num_detections)
|
if (detections->total != num_detections)
|
||||||
{
|
{
|
||||||
ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH );
|
ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH );
|
||||||
@ -116,7 +128,9 @@ void CV_LatentSVMDetectorTest::run( int /* start_from */)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_TBB
|
||||||
|
init.terminate();
|
||||||
|
#endif
|
||||||
cvReleaseMemStorage( &storage );
|
cvReleaseMemStorage( &storage );
|
||||||
cvReleaseLatentSvmDetector( &detector );
|
cvReleaseLatentSvmDetector( &detector );
|
||||||
cvReleaseImage( &image );
|
cvReleaseImage( &image );
|
||||||
|
@ -43,6 +43,10 @@
|
|||||||
#include "cvtest.h"
|
#include "cvtest.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef HAVE_TBB
|
||||||
|
#include "tbb/task_scheduler_init.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
const int num_detections = 3;
|
const int num_detections = 3;
|
||||||
@ -75,27 +79,31 @@ bool CV_LatentSVMDetectorTest::isEqual(CvRect r1, CvRect r2)
|
|||||||
|
|
||||||
void CV_LatentSVMDetectorTest::run( int /* start_from */)
|
void CV_LatentSVMDetectorTest::run( int /* start_from */)
|
||||||
{
|
{
|
||||||
string img_path = string(ts->get_data_path()) + "latentsvmdetector/cat.jpg";
|
int numThreads = -1;
|
||||||
string model_path = string(ts->get_data_path()) + "latentsvmdetector/cat.xml";
|
#ifdef HAVE_TBB
|
||||||
|
numThreads = 2;
|
||||||
|
tbb::task_scheduler_init init(tbb::task_scheduler_init::deferred);
|
||||||
|
init.initialize(numThreads);
|
||||||
|
#endif
|
||||||
|
|
||||||
IplImage* image = cvLoadImage(img_path.c_str());
|
IplImage* image = cvLoadImage(img_path.c_str());
|
||||||
if (!image)
|
if (!image)
|
||||||
{
|
{
|
||||||
ts->set_failed_test_info( CvTS::FAIL_INVALID_TEST_DATA );
|
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CvLatentSvmDetector* detector = cvLoadLatentSvmDetector(model_path.c_str());
|
CvLatentSvmDetector* detector = cvLoadLatentSvmDetector(model_path.c_str());
|
||||||
if (!detector)
|
if (!detector)
|
||||||
{
|
{
|
||||||
ts->set_failed_test_info( CvTS::FAIL_INVALID_TEST_DATA );
|
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
|
||||||
cvReleaseImage(&image);
|
cvReleaseImage(&image);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CvMemStorage* storage = cvCreateMemStorage(0);
|
CvMemStorage* storage = cvCreateMemStorage(0);
|
||||||
CvSeq* detections = 0;
|
CvSeq* detections = 0;
|
||||||
detections = cvLatentSvmDetectObjects(image, detector, storage);
|
detections = cvLatentSvmDetectObjects(image, detector, storage, 0.5f, numThreads);
|
||||||
|
|
||||||
if (detections->total != num_detections)
|
if (detections->total != num_detections)
|
||||||
{
|
{
|
||||||
@ -117,6 +125,9 @@ void CV_LatentSVMDetectorTest::run( int /* start_from */)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_TBB
|
||||||
|
init.terminate();
|
||||||
|
#endif
|
||||||
cvReleaseMemStorage( &storage );
|
cvReleaseMemStorage( &storage );
|
||||||
cvReleaseLatentSvmDetector( &detector );
|
cvReleaseLatentSvmDetector( &detector );
|
||||||
cvReleaseImage( &image );
|
cvReleaseImage( &image );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user