VideoCapture cap;
VideoCapture cap1;
VideoCapture cap2;
VideoCapture cap3;
//if (!cap.isOpened())
///{
// cout << "攝像頭未打開" << endl;
//}
//Mat M;
//namedWindow("攝像頭1", 1);
cvWaitKey();
Mat frame1,frame2,frame3,frame0;
bool bStop = false;
cap3.open();
cap2.open();
cap1.open();
cap.open();
//cap3.open(3);
while (!bStop) {
cap >> frame0;
cap1 >> frame1;
cap2 >> frame2;
cap3 >> frame3;
1.基本介紹
視訊讀取本質上就是讀取圖像,因為視訊是由一幀一幀圖像組成的。1秒24幀基本就能流暢的讀取視訊了。
①讀取視訊有兩種方法:
VideoCapture cap;
cap.open(.avi”);
或VideoCapture cap(.avi”);
②循環顯示每一幀:
while()
{
Mat frame; //定義Mat變量,用來存儲每一幀
cap>>frame; //讀取目前幀方法一
//cap.read(frame); //讀取目前幀方法二
imshow(“視訊顯示”, frame); //顯示一幀畫面
waitKey(); //延時30ms
}
2.注意
cvWaitKey();暫停(隻處理一幀圖像)
處理連續多幀圖像時不加
3.格式轉換mat->IplImage
IplImage* pBinary0 = &IplImage(frame0);
深拷貝隻要再加一次複制資料:
IplImage *input0 = cvCloneImage(pBinary0);
4.usb控制器
效果圖如下:
使用的是四個相同紅外+白光免驅攝像頭,其中有攝像頭插入HUB上,沒有PCI擴充,
cap3.open(4);
cap2.open(2);
cap1.open(1);
cap.open(0);
最好按順序從高到低排序