Guest User

Untitled

a guest
Jan 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include "opencv2/highgui/highgui.hpp"
  2. #include "opencv2/imgproc/imgproc.hpp"
  3. #include <iostream>
  4.  
  5. using namespace cv;
  6. using namespace std;
  7.  
  8. int main() {
  9. VideoCapture stream1(0); //0 is the id of video device.0 if you have only one camera.
  10.  
  11. if (!stream1.isOpened()) { //check if video device has been initialised
  12. cout << "cannot open camera";
  13. }
  14.  
  15. //unconditional loop
  16. while (true) {
  17. Mat cameraFrame;
  18. stream1.read(cameraFrame);
  19. imshow("cam", cameraFrame);
  20. if (waitKey(30) >= 0)
  21. break;
  22. }
  23. system("pause");
  24. return 0;
  25. }
  26.  
  27. VideoCapture stream1("video.avi");
  28. stream1.read(cameraFrame);
  29.  
  30. if (waitKey(30) >= 0)
  31. break;
  32.  
  33. if( (char)waitKey(10) == 'q' )
  34. break;
Add Comment
Please, Sign In to add comment