cam.c
上传用户:hfxfswkj
上传日期:2022-03-17
资源大小:17k
文件大小:1k
源码类别:

图片显示

开发平台:

C/C++

  1. #include <cv.h>
  2. #include <highgui.h>
  3. #include <cxcore.h>
  4. #include <sys/types.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. CvCapture *capture ;
  8. int init()
  9. {
  10. capture =cvCreateCameraCapture(0);
  11. if (capture)
  12. {
  13. cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,320);
  14.                 cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,240);
  15.                 printf("sucessfuln");
  16. return 1;
  17. }
  18. else
  19. {
  20. printf("NOsucessfuln");
  21. return -1;
  22. }
  23. }
  24. main()
  25. {
  26. init();
  27. IplImage *frame =0;
  28. char *image32=0;
  29. char *image;
  30. cvGrabFrame(capture);
  31. frame=cvRetrieveFrame( capture );
  32. image=frame->imageData;
  33. cvSaveImage("/mnt/c/lwg.jpg",frame);
  34.         cvReleaseCapture(&capture);
  35. }