0

I executed a simple C++ program in Visual Studio2010 using OpencV version 2.2 to start the camera and display the video simaltaneously.But the camera gets started and only the window came as output and not the video capture simaltaneously..Here is my code.Is there any error in camera..Do we need to install any softwares..Please suggest as soon as possible.

#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <conio.h>

int main()
{
    CvCapture* capture =0;       
    capture = cvCaptureFromCAM(0);
    if(!capture)
        {
           printf("Capture failure\n");
           return -1;
        }
    IplImage* frame=NULL;
    cvNamedWindow("Video");      
    cvNamedWindow("Ball");
    //iterate through each frames of the video      
    while(true)
        {
                frame = cvQueryFrame(capture);      
                if(!frame) break;
                frame=cvCloneImage(frame); 
                cvShowImage("Video", frame);    
            //Clean up used images
                cvReleaseImage(&frame);
            //Wait 50mS
                int c = cvWaitKey(10);
            //If 'ESC' is pressed, break the loop
                if((char)c==27 ) break;   
           }
    cvDestroyAllWindows() ;
    cvReleaseCapture(&capture); 
    return 0; 
}

Edited by Vivitha

2
Contributors
1
Reply
14
Views
3 Years
Discussion Span
Last Post by Paul.Esson
0

Hey,

I just run the code and can confirm it works fine.

On my mac the "Video" window was hiding behind my IDE and the "ball" window was visible.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.