Let perf/accuracy test of ocl haar uses detectMultiScale api.

Fix image to be used by perf test.
pull/1739/head
peng xiao 11 years ago
parent 8c1eb5bf0e
commit 2a111f7a6c
  1. 42
      modules/ocl/perf/perf_haar.cpp
  2. 11
      modules/ocl/test/test_objdetect.cpp
  3. 6
      samples/ocl/facedetect.cpp

@ -48,49 +48,11 @@
using namespace perf;
///////////// Haar ////////////////////////
namespace cv
{
namespace ocl
{
struct getRect
{
Rect operator()(const CvAvgComp &e) const
{
return e.rect;
}
};
class CascadeClassifier_GPU : public OclCascadeClassifier
{
public:
void detectMultiScale(oclMat &image,
CV_OUT std::vector<cv::Rect>& faces,
double scaleFactor = 1.1,
int minNeighbors = 3, int flags = 0,
Size minSize = Size(),
Size maxSize = Size())
{
(void)maxSize;
MemStorage storage(cvCreateMemStorage(0));
//CvMat img=image;
CvSeq *objs = oclHaarDetectObjects(image, storage, scaleFactor, minNeighbors, flags, minSize);
vector<CvAvgComp> vecAvgComp;
Seq<CvAvgComp>(objs).copyTo(vecAvgComp);
faces.resize(vecAvgComp.size());
std::transform(vecAvgComp.begin(), vecAvgComp.end(), faces.begin(), getRect());
}
};
}
}
PERF_TEST(HaarFixture, Haar)
{
vector<Rect> faces;
Mat img = imread(getDataPath("gpu/haarcascade/basketball1.png"), CV_LOAD_IMAGE_GRAYSCALE);
Mat img = imread(getDataPath("gpu/haarcascade/group_1_640x480_VGA.pgm"), CV_LOAD_IMAGE_GRAYSCALE);
ASSERT_TRUE(!img.empty()) << "can't open basketball1.png";
declare.in(img);
@ -107,7 +69,7 @@ PERF_TEST(HaarFixture, Haar)
}
else if (RUN_OCL_IMPL)
{
ocl::CascadeClassifier_GPU faceCascade;
ocl::OclCascadeClassifier faceCascade;
ocl::oclMat oclImg(img);
ASSERT_TRUE(faceCascade.load(getDataPath("gpu/haarcascade/haarcascade_frontalface_alt.xml")))

@ -218,14 +218,9 @@ PARAM_TEST_CASE(Haar, int, CascadeName)
OCL_TEST_P(Haar, FaceDetect)
{
MemStorage storage(cvCreateMemStorage(0));
CvSeq *_objects;
_objects = cascade.oclHaarDetectObjects(d_img, storage, 1.1, 3,
flags, Size(30, 30), Size(0, 0));
vector<CvAvgComp> vecAvgComp;
Seq<CvAvgComp>(_objects).copyTo(vecAvgComp);
oclfaces.resize(vecAvgComp.size());
std::transform(vecAvgComp.begin(), vecAvgComp.end(), oclfaces.begin(), getRect());
cascade.detectMultiScale(d_img, oclfaces, 1.1, 3,
flags,
Size(30, 30), Size(0, 0));
cpucascade.detectMultiScale(img, faces, 1.1, 3,
flags,

@ -41,7 +41,7 @@ static double getTime()
static void detect( Mat& img, vector<Rect>& faces,
ocl::OclCascadeClassifierBuf& cascade,
ocl::OclCascadeClassifier& cascade,
double scale, bool calTime);
@ -87,7 +87,7 @@ int main( int argc, const char** argv )
outputName = cmd.get<string>("o");
string cascadeName = cmd.get<string>("t");
double scale = cmd.get<double>("c");
ocl::OclCascadeClassifierBuf cascade;
ocl::OclCascadeClassifier cascade;
CascadeClassifier cpu_cascade;
if( !cascade.load( cascadeName ) || !cpu_cascade.load(cascadeName) )
@ -180,7 +180,7 @@ int main( int argc, const char** argv )
}
void detect( Mat& img, vector<Rect>& faces,
ocl::OclCascadeClassifierBuf& cascade,
ocl::OclCascadeClassifier& cascade,
double scale, bool calTime)
{
ocl::oclMat image(img);

Loading…
Cancel
Save