Qt Code:
  1. #include <stdio.h>
  2. #include "cv.h"
  3. #include "highgui.h"
  4.  
  5.  
  6. int main( int argc, char **argv )
  7. {
  8.  
  9.  
  10.  
  11.  
  12. CvCapture *capture = 0;
  13. CvCapture *capture1 =0;
  14. IplImage *frame = 0;
  15. IplImage *frame1=0;
  16. int key = 0;
  17. /* initialize camera */
  18. capture = cvCaptureFromCAM( 0 );
  19. capture = cvCaptureFromCAM( 1 );
  20.  
  21. /* always check */
  22. // if ( !capture ) {
  23. // fprintf( stderr, "Cannot open initialize webcam!\n" );
  24. // return 1;
  25. // }
  26. //
  27. // if ( !capture1 ) {
  28. // fprintf( stderr, "Cannot open initialize webcam!\n" );
  29. // return 1;
  30. // }
  31. cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
  32. cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);
  33.  
  34. cvSetCaptureProperty(capture1, CV_CAP_PROP_FRAME_WIDTH, 640);
  35. cvSetCaptureProperty(capture1, CV_CAP_PROP_FRAME_HEIGHT, 480);
  36.  
  37. cvSetCaptureProperty(capture, CV_CAP_PROP_FPS, 8);
  38. cvSetCaptureProperty(capture1, CV_CAP_PROP_FPS, 8);
  39. /* create a window for the video */
  40. cvNamedWindow( "result", CV_WINDOW_AUTOSIZE );
  41.  
  42. while( key != 'q' ) {
  43. /* get a frame */
  44. frame = cvQueryFrame( capture );
  45. frame1 = cvQueryFrame( capture1 );
  46. /* always check */
  47. // if( !frame ) break;
  48. // if( !frame1 ) break;
  49.  
  50. /* display current frame */
  51.  
  52.  
  53. cvShowImage("Left", frame);
  54. cvShowImage("Right",frame1);
  55.  
  56.  
  57.  
  58. /* exit if user press 'q' */
  59. key = cvWaitKey( 1 );
  60. }
  61.  
  62. /* free memory */
  63. cvDestroyWindow( "result" );
  64. cvDestroyWindow( "result1" );
  65. cvReleaseCapture( &capture );
  66. cvReleaseCapture( &capture1 );
  67.  
  68. return 0;
  69. }
To copy to clipboard, switch view to plain text mode 

It's not RUN