HogDescriptor无法检测到任何内容。 OpenCV 2.3

时间:2014-02-07 07:34:02

标签: c++ opencv

基于Hog的多尺度探测器无法探测任何人脸甚至任何人。根据OpenCV示例中的peopledetect.cpp,我试图检测人员,但没有得到我在这里缺少的东西。按照我正在尝试的代码:

        #include "cvaux.h"
        #include "highgui.h"
        #include <stdio.h>
        #include <iostream>
        #include <string.h>
        #include <ctype.h>

            using namespace cv;
            using namespace std;

            int main(int argc, char** argv)
            {
                Mat img;
                FILE* f = 0;
                char _filename[1024];

                if( argc == 1 )
                {
                    printf("Usage: peopledetect (<image_filename>\n");
                    return 0;
                }
                img = imread(argv[1]);

                if( img.data )
                {
                        strcpy(_filename, argv[1]);
                }

                HOGDescriptor hog;
                hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());

                for(;;)
                {
                  char* filename = _filename;
                  printf("%s:\n", filename);
                  if(!img.data)
                  continue;
                  fflush(stdout);

                  vector<Rect> found, found_filtered;
                  double t = (double)getTickCount();

                  hog.detectMultiScale(img, found, 0, Size(8,8), Size(32,32), 1.05, 2);
                  cout<<found.size()<<endl; // To check how many faces detected.
                  t = (double)getTickCount() - t;
                  printf("tdetection time = %gms\n",t*1000./cv::getTickFrequency());
                        size_t i, j;
                        for( i = 0; i < found.size(); i++ )
                        {
                                Rect r = found[i];cout<<i<<endl;
                                for( j = 0; j < found.size(); j++ )
                                        if( j != i && (r & found[j]) == r)
                                                break;
                                if( j == found.size() )
                                   found_filtered.push_back(r);
                                   cout<<found_filtered.size()<<endl;
                        }

                        imshow("people detector", img);
                        int c = waitKey(0) & 255;

                }
                            return 0;
            }

任何图片都没有被检测到。可能是什么问题?我没挂东西吗?

0 个答案:

没有答案