Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem with Camera Capturing

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.

click to hide/show revision 2
No.2 Revision

updated 2014-04-19 05:02:34 -0600

berak gravatar image

Problem with Camera Capturing

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.

Problem with Camera Capturing

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>

#include < opencv\cv.h >
#include < opencv\highgui.h >
#include < iostream >
using namespace std; std;
using namespace cv; cv;
int main() { main()
{
char c; c;
CvCapture* capture = cvCreateCameraCapture(0); //0 is the external camera ID,1 is the internal camera ID of my laptop. laptop.
IplImage* src; src;
for (;;) {
{
src = cvQueryFrame(capture); cvQueryFrame(capture);

cvShowImage("Input", src); src);
c = waitKey(10); waitKey(10);
if (c == 27) break; break;
} cvReleaseCapture(&capture);
cvReleaseCapture(&capture);
return 0; }

0;
}
2.using the functions in the opencv2

 #include <opencv2\core\core.hpp>
 #include <opencv2\highgui\highgui.hpp>
 #include <iostream>

#include < opencv2\core\core.hpp >
#include < opencv2\highgui\highgui.hpp >
#include < iostream >
using namespace cv; cv;
using namespace std; std;
int main() { main()
{
char c; c;
VideoCapture inputVideo(0); //0为外部摄像头的ID,1为笔记本内置摄像头的ID //0为外部摄像头的ID,1为笔记本内置摄像头的ID
Mat src; for(;;) { src;
for(;;)
{
inputVideo >> src; imshow("input",src); src;
imshow("input",src);
c = waitKey(10); waitKey(10);
if (c == 27) break; } break;
}
return 0; }

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.

Problem with Camera Capturing

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.

Problem with Camera Capturing

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);
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.

click to hide/show revision 6
No.6 Revision

Problem with Camera Capturing

I've got two ways to capture a camera. 1.using the functions in the opencv
#include < opencv\cv.h >

 #include < opencv\cv.h
 #include < opencv\highgui.h >
#include < iostream >
using namespace std;
std; using namespace cv;
cv; int main()
{
main() { char c;
c; CvCapture* capture = cvCreateCameraCapture(0); //0 is the external camera ID,1 is the internal camera ID of my laptop.
laptop. IplImage* src;
src; for (;;)
{
(;;) { src = cvQueryFrame(capture);
cvShowImage("Input", src);
src); c = waitKey(10);
waitKey(10); if (c == 27) break;
break; }
cvReleaseCapture(&capture);
cvReleaseCapture(&capture); return 0;
}

0; } 2.using the functions in the opencv2
#include < opencv2\core\core.hpp >
***opencv2*** #include < opencv2\core\core.hpp #include < opencv2\highgui\highgui.hpp >
#include < iostream >
using namespace cv;
cv; using namespace std;
std; int main()
{
main() { char c;
c; VideoCapture inputVideo(0); //0为外部摄像头的ID,1为笔记本内置摄像头的ID
//0为外部摄像头的ID,1为笔记本内置摄像头的ID Mat src;
for(;;)
{
src; for(;;) { inputVideo >> src;
imshow("input",src);
src; imshow("input",src); c = waitKey(10);
waitKey(10); if (c == 27) break;
}
break; } return 0;
}

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.