修复了上一个程序的错误。现在运行到视频的最后一帧自己会停下了哦~
而且效果也比上次好多鸟~
敬请期待生成运动轨迹!
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <cvaux.h>//必须引此头文件1
#define threshold_diff1 20 //设置简单帧差法阈值
#define threshold_diff2 20 //设置简单帧差法阈值
using namespace cv;
using namespace std;
int main(int argc,unsigned char* argv[])
{
Mat img_src1,img_src2,img_src3;//3帧法需要3帧图片
Mat img_dst,gray1,gray2,gray3;
Mat gray_diff1,gray_diff2;//存储2次相减的图片
Mat gray_diff11,gray_diff12;
Mat gray_diff21,gray_diff22;
Mat gray;//用来显示前景的
bool pause=false;
VideoCapture vido_file("bike.avi");//在这里改相应的文件名
namedWindow("foreground",0);
BackgroundSubtractorMOG2 mog;
BackgroundSubtractorMOG2 mog2;//用于显示背景
Mat foreground;
Mat background;
Mat foreground2;
int framenum = vido_file.get(CV_CAP_PROP_FRAME_COUNT);
cout<<framenum<<endl;
运动目标检测小程序之修改版
最新推荐文章于 2025-02-24 13:15:06 发布