Ask Your Question

Hitendra's profile - activity

2019-08-06 07:07:58 -0600 received badge  Popular Question (source)
2013-10-21 23:24:41 -0600 commented answer Which OpenCV function for Analog camera?

Thanks for your reply.I tried but VideoCapture cap(0 + CV_CAP_DSHOW); is not support.

2013-10-21 23:21:43 -0600 commented answer Which OpenCV function for Analog camera?

Thanks for your reply. I have put VideoCapture Device(0); and VideoCapture stream1(0); but both are not working.

2013-10-16 06:43:32 -0600 received badge  Editor (source)
2013-10-16 06:41:16 -0600 asked a question Which OpenCV function for Analog camera?

image descriptionWhich 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.