0

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 opencv inbuilt function. So please help me. Thanks for your time.

This is the code for cvcapture function which I have used.

#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;

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

Next code is using VideoInput function.

The code is

#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

and last code is using videocapture function

the code is

#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() {
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

Please help me.

user2865434
  • 111
  • 2
  • 2
  • 10
  • Please share 1) How your analog camera output is getting into your computer 2) The VideoInput code that works and 3) An example of what you tried with OpenCV that attempts to do what you want. – KobeJohn Oct 17 '13 at 04:22
  • Actually videoInput is working well with analog camera but I want to use Qt with C++ for GUI purpose and so I got the error after include the videoInput.lib file in my qt project that's why I am searching inbuilt function of OpenCV. Thanks for your reply. – user2865434 Oct 17 '13 at 05:04
  • Good update. I use opencv in python so haven't tried your code. Please explain what doesn't work in the two OpenCV examples. – KobeJohn Oct 18 '13 at 07:49
  • Thnks for your reply. Actually I want to make one application which will able to record live streaming analog camera with GUI.For GUI purpose I am using Qt creator. So videoInput library working well with analog camera and opencv's built in function does not support analog camera so I have to use videoInput library and videoInput library is third party library it is not opencv's built in library so i have to include it in my project.I have successfully included it in my visual studio project and it is working good. – user2865434 Oct 21 '13 at 04:31
  • But now for GUI purpose I have to include videoInput library in my Qt creator project. I have tried lot but can't able to successful run my Qt creator Project. It gives me different different errors during include the videoInput library.That's why I am searching for opencv built in library which is support analog camera. – user2865434 Oct 21 '13 at 04:33
  • If more information require then please tell me I will provide you. Thanks a lot. – user2865434 Oct 21 '13 at 04:34
  • I will probably not be able to help you because your code is in C++, but hopefully someone with C++ experience will. I suggest you put the details of the specific errors that you are getting into your original question so that others don't have to reproduce your whole system to understand the problems and give ideas. – KobeJohn Oct 21 '13 at 12:51
  • Thanks for your reply. I will try to put my code with particular errors. – user2865434 Oct 22 '13 at 04:17
  • @user2865434 Did you find your solution? – praxmon Jan 24 '14 at 11:03
  • Thanks for your reply. Actually I was tried to make application which will able to monitor live streaming using analog camera in qt creator.And videoInput.lib file require for analog camera.So i needed to include videoInput.lib file to Qt creator but at that time I got the error like "No rule to make target" so I have used Qt-addin-Visual Studio and include videInput.lib in visual studio 2010 and completed my project. Due to this problem I wanted to opencv built in function for read analog camera. – user2865434 Jan 24 '14 at 11:18
  • My problem is posted [here](http://stackoverflow.com/questions/19374920/no-rule-to-make-target/20881959#20881959). – user2865434 Jan 24 '14 at 11:35

0 Answers0