I've got two ways to capture a camera.
1.using the functions in the opencv
#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
char c;
CvCapture* capture = cvCreateCameraCapture(0); //0 is the external camera ID,1 is the internal camera ID of my laptop.
IplImage* src;
for (;;)
{
src = cvQueryFrame(capture);
cvShowImage("Input", src);
c = waitKey(10);
if (c == 27) break;
}
cvReleaseCapture(&capture);
return 0;
}
2.using the functions in the opencv2
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
char c;
VideoCapture inputVideo(0); //0为外部摄像头的ID,1为笔记本内置摄像头的ID
Mat src;
for(;;)
{
inputVideo >> src;
imshow("input",src);
c = waitKey(10);
if (c == 27) break;
}
return 0;
}
By using the method 1, the program can read both the external and the internal camera's data;but the program can only read the internal camera's data with method 2. I don't know why method 1 and method 2 so different.
What should I do if I want to get the data of the external camera with method 2?
// my operation system is Window8.1, the version of my OPENCV is 2.4.8, the version of my Visual Studio is 2013.
I need your help.