Camera input - OpenCV
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Camera input - OpenCV

  1. #1
    Join Date
    May 2010
    Posts
    24

    Question Camera input - OpenCV

    Hi folks,
    I want to display the video being captured by the webcam in C++. I've found this code, that uses OpenCV and it's very simple:
    Code:
    #include <ctype.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include "cvcam.h"
    #include "cv.h"
    #include "highgui.h"
    
    int main( int argc, char** argv )
    {
      IplImage* frame = 0;
      CvCapture* capture = 0;
      capture = cvCaptureFromCAM(1);
      frame = cvQueryFrame( capture );
      if( !capture )
      {
        fprintf(stderr,"Could not initialize capturing...\n");
        return -1;
      }
      cvNamedWindow( "in", 0 );
      for(;;)
      {
        if(!cvGrabFrame(capture)) 
          break;
        frame = cvRetrieveFrame(capture);
        cvShowImage("in", frame );
        if( cvWaitKey(10) >= 0 )
          break;
      }
      cvReleaseCapture( &capture );
      cvDestroyWindow("in");
      return 0;
    }
    However, I don't know why it fails (in the "if (!capture)", it always enters - capture is null), and I don't know how to fix it.
    I don't know if there is anyone here that could help me with that OpenCV issue. However, if there isn't, if you tell me another way to grab the camera input (and display it in a window) would be great!
    I'm using Windows XP, if that matters.

  2. #2
    Join Date
    May 2010
    Posts
    24

    Re: Camera input - OpenCV

    Nobody? Nor even to tell me how to use the webcam without OpenCV?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center