首页 > 其他 > 详细

Opencv人头跟踪检测

时间:2015-11-28 21:34:45      阅读:1032      评论:0      收藏:0      [点我收藏+]

 

int main()
{

    //VideoCapture video("E:\\C_VC_code\\Text_Photo\\feini.flv");
    VideoCapture video(0);
    if(!video.isOpened())
    {
        return 0;
    }
    vector<float>head;
    FILE *read = fopen("detector_TQ.txt","r");
    if(read==NULL)
    {
        cout<<"Error: The file read fail"<<endl;
        return -1;
    }
    double data;
    while(fscanf(read,"%lf",&data)!=-1)
    {
        head.push_back(data);
    }
    cout<<head.size() <<endl;
    
    Mat img,dstimg;
    vector<cv::Rect>found;
    HOGDescriptor hog(Size(48,48),Size(16,16),Size(8,8),Size(8,8),9);
    hog.setSVMDetector(head);
    double scalar = 0.5;
    while(1)
    {
        video>>img;
        resize(img,dstimg,Size(img.cols*scalar,img.rows*scalar),1,1,3);
        hog.detectMultiScale(dstimg, found, 1, cv::Size(8,8), cv::Size(0,0), 1.1, 3, false);
        for(int i=0;i<found.size();i++)
        {
            Rect r=found[i];
            r.x/=scalar;
            r.y/=scalar;
            r.width/=scalar;
            r.height/=scalar;
            rectangle(img,r,CV_RGB(0,255,0),2);
        }
        imshow("video1",dstimg);
        imshow("video",img);
        found.clear();
        if(waitKey(33)==27)
        {
            imshow("video",img);
            waitKey(0);
            break;
        }
    }
}

 

Opencv人头跟踪检测

原文:http://www.cnblogs.com/mypsq/p/5003416.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!