OpenCV示例1

#include //#include #include #include #include #include using namespace std;using namespace cv;int main(){Mat frame;VideoCapture cap(0);double alpha = 0.5;cap >> frame;Mat dst;frame.convertTo(dst,CV_32FC3,1,0);namedWindow("test",1);namedWindow("dst",1);Mat mask(frame.size(), CV_8UC1);mask.setTo(Scalar::all(1));int val[] = {1,1,1,-1,-1,-1, 1,1,1,-1,-1,-1, 1,1,1,-1,-1,-1,};Matx m(val);while(1){cap >> frame;Mat f;frame.convertTo(f,CV_32FC3,1,0);accumulateWeighted(f,dst,alpha,Mat());Mat fg;cvtColor(f,fg,CV_BGR2GRAY);pyrDown(fg,fg,Size());pyrDown(fg,fg,Size());blur(fg,fg,Size(3,6));filter2D(fg,fg,-1,Mat(m));imshow("test",fg);Mat d;dst.convertTo(d,CV_8UC3,1,0);imshow("d",d);Mat temp;temp = abs(f - dst);temp.convertTo(temp,CV_8UC3,1,0);Mat gray;cvtColor(temp,gray,CV_BGR2GRAY);//adaptiveThreshold(gray,gray,255,ADAPTIVE_THRESH_MEAN_C,THRESH_BINARY,7,0);imshow("dst",gray);waitKey(22);}system("pause");return 0;}

猜你喜欢

转载自blog.csdn.net/zdx19880830/article/details/42422431