void CrelaxMyFriendDlg::OnBnClickedOk()
{
hdc = this->GetDC()->GetSafeHdc();
// TODO: 在此添加控件通知处理程序代码
string addrImg = "c:/Users/actorsun/Pictures/";
string addrVideo = "c:/Users/actorsun/Videos/";
string addr = addrVideo + "1.mp4";
VideoCapture vc(addr);
if (!(vc.isOpened()))
{
Sleep(1);
}
Mat relax, positive, gray;
Mat first,current,obj;
vc >> first;
cvtColor(first, first, COLOR_BGR2GRAY);
GaussianBlur(first, first, Size(0, 0), 1);
while (1)
{
vc >> current;
if (current.empty())
{
break;
}
cvtColor(current, current, COLOR_BGR2GRAY);
GaussianBlur(current, current, Size(0, 0), 1);
absdiff(first, current, obj);
imshow("obj", obj);
waitKey(1000 / vc.get(CAP_PROP_FPS));
}
//在运动物体上面画个矩形框,像我的监控一样
waitKey(0);
}
注意看右上角那个白色的东西,那是一个人从右上角路过,然后被检测到了,注意了这个白色的区域会一直跟随人而移动