|
- #include<opencv2\core\core.hpp>
- #include<opencv2\highgui\highgui.hpp>
- #include<cv.h>
- #include<iostream>
- using namespace std;
- using namespace cv;
- int main()
- {
- Mat Img1;
- Mat Img2;
- Mat Img3;
- int m=0;
- char files[30];
- VideoCapture cap;
- cap.open(1);//打开摄像头
- while (cap.isOpened())
- {
- cap>>Img1;
- rectangle(Img1,Point(0,0),Point(150,150),Scalar(255,0,0),1,0);
- Img2=Img1(Rect(0,0,150,150));//抠出图片指定区域
- resize(Img2,Img3,Size(Img2.rows/3,Img2.cols/3),0,0,1);
- imshow("yuanshitu",Img1);
- imshow("jianqie",Img2);
- imshow("suofang",Img3);
- char c=waitKey(35);
- //按回车键拍照保存图片至指定文件夹
- if(c==13)
- {
- sprintf(files,"E:\\C++/Testpicture/%d.jpg",m);
- imwrite(files,Img3);
- m++;
- cout<<files<<endl;
- }
- }
- return 0;
- }
复制代码
|
|