fork download
  1. #include "stdafx.h"
  2. #include "cv.h"
  3. #include "highgui.h"
  4. #include <cxcore.h>
  5. #include <stdio.h>
  6. #include <math.h>
  7. #include <iostream>
  8.  
  9.  
  10. // A Simple Camera Capture Framework
  11. int main() {
  12. CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
  13. if ( !capture ) {
  14. fprintf( stderr, "ERROR: capture is NULL \n" );
  15. getchar();
  16. return -1;
  17. }
  18. else
  19. fprintf( stderr, "Camera is OK \n");
  20. // Create a window in which the captured images will be presented
  21. cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
  22. // Show the image captured from the camera in the window and repeat
  23. while ( 1 ) {
  24. // Get one frame
  25. IplImage* frame = cvQueryFrame( capture );
  26. if ( !frame ) {
  27. fprintf( stderr, "ERROR: frame is null...\n" );
  28. getchar();
  29. break;
  30. }
  31. cvShowImage( "mywindow", frame );
  32. // Do not release the frame!
  33. //If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
  34. //remove higher bits using AND operator
  35. if ( (cvWaitKey(10) & 255) == 27 ) break;
  36. }
  37. // Release the capture device housekeeping
  38. cvReleaseCapture( &capture );
  39. cvDestroyWindow( "mywindow" );
  40. return 0;
  41. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty