Which OpenCV function for Analog camera?
Which OpenCV's function support the analog camera for live streaming?
Please give me the answer.
I tried CvCapture and VideoCapture functions of OpenCV. It works for USB camera but did not work for Analog camera.
I tried VideoInput function.It works well with analog camera but i want to use opencv inbuilt function. So please help me. Thanks for your time.
Thanks for your reply.
This is my code and I have used videoInput function and it works well.
#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include "videoInput.h"
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
using namespace std;
int main(int, char**)
{
videoInput VI;
int numDevices = VI.listDevices();
//int device1= 0;
VI.setup(0);
unsigned char* yourBuffer = new unsigned char[VI.getSize(0)];
IplImage* colourImage = cvCreateImage(cvSize(320,240),8,3);
while(1)
{
VI.grabFrame(0, yourBuffer);
colourImage->imageData = (char*)yourBuffer;
cvConvertImage(colourImage, colourImage, 3);
cvShowImage("test",colourImage);
if( cvWaitKey(10) == 27)
break;
}
return 0;
}
End of code.
Next code using video capture function which is opencv function.But this function not support the analog camera.
start of code
int main() {
VideoCapture stream1(-1); //0 is the id of video device.0 if you have only one camera.
if (!stream1.isOpened()) { //check if video device has been initialised
cout << "cannot open camera";
return 0;
}
//unconditional loop
while (true) {
Mat cameraFrame;
stream1.read(cameraFrame);
imshow("cam", cameraFrame);
if (waitKey(30) >= 0)
break;
}
return 0;
}
end of code
And last code using cvcapture and it is also opencv function and it is also not support analog camera.
start of code is
char key;
int main()
{
cvNamedWindow("Camera_Output", 1); //Create window
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY); //Capture using any camera connected to your system
while(1){ //Create infinte loop for live streaming
IplImage* frame = cvQueryFrame(capture); //Create image frames from capture
cvShowImage("Camera_Output", frame); //Show image frames on created window
key = cvWaitKey(10); //Capture Keyboard stroke
if (char(key) == 27){
break; //If you hit ESC key loop will break.
}
}
cvReleaseCapture(&capture); //Release capture.
cvDestroyWindow("Camera_Output"); //Destroy Window
return 0;
}
End of code
Please help me.
First of all, the amount of information you are providing is dramatically low. Specify some sample code, specify your camera you are using, the system you are working on, ... Next you should know that most analog camera devices return data to your pc, and have drivers to convert that data in a digital stream. Camera specific API will mostly give you the chance of retrieving the data stream, which is not always possible in openCV, and then you just pass the data to openCV for processing.
As a suggestion, never use the old C - API, so skip that and try to create a solution using the C++ API :)