1 | initial version |
I have solved this problem. It occurred to me that by using method 2 the first frame got from the external camera might be blank while the others are normal, so I add something to the code:
#include < opencv2\highgui\highgui.hpp >
#include < iostream >
using namespace cv;
using namespace std;
int main()
{
char c;
int i = 0;
VideoCapture inputVideo(0); //0为外部摄像头的ID,1为笔记本内置摄像头的ID
Mat src;
for(;;)
{
inputVideo >> src;
if(src.empty() & i > 1) return 1;
if(i > 1) imshow("input",src);
i ++;
c = waitKey(10);
if (c == 27) break;
}
return 0;
}
2 | No.2 Revision |
I have solved this problem. It occurred to me that by using method 2 the first frame got from the external camera might be blank while the others are normal, so I add something to the code: