这几天跑了Opencv中的camshift算法,发现目标需要自己去选,够费劲的。
突然想要,是hog进行人体检测,然后用shift去跟踪是不是效果会好些。
camshift的跟踪还好,主要是hog的检测,opencv中hog检测的误检率还是很高的。
程序我直接拿来了opencv中现成的代码,也就是个简单的demo。大家看看,感觉下效果就可以了
如果需要更精确的效果,程序还需要很多优化,毕竟opencv中的camshift算法紧紧是重心的跟踪迭代。
程序如下:
#include <fstream>
#include <string>
#include <cv.h>
#include <highgui.h>
#include <ml.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "cvaux.h"
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
using namespace cv;
using namespace std;
Rect r ;
int track_object = 0;
Rect ObjectDectd(IplImage* frame,int object,Rect r);
IplImage* MeanSift(IplImage *frame,Rect r);
int main()
{
int number = 0;
CvCapture* capture = 0;
capture = cvCaptureFromAVI("112218.avi");
if( !capture )
{
fprintf(stderr,"Could not initialize capturing...\n");
return -1;
}
cvNamedWindow( "HogSiftDemo", 1 );
for(;;)
{
cout<<number<<endl;
number++;
IplImage* frame = 0;
frame = cvQueryFrame( capture );
//frame