Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. """
  2. Install OpenCV (https://pypi.org/project/opencv-python/) and modify the code below such that
  3. you can view a set of images that are located in your computer. If you have web camera in your
  4. computer use it and present a mirrored image on of the scene in the screen.
  5. (https://opencvpythontutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html)
  6. """
  7.  
  8. import numpy as np
  9. import cv2
  10. import os
  11.  
  12. ipath = "C:\imgs"
  13. allfiles = os.listdir(ipath)
  14. ipath = ipath+"\\"
  15.  
  16. for i in allfiles:
  17.  
  18. img = cv2.imread(ipath + i, 0)
  19. cv2.imshow(i, img)
  20. cv2.waitKey(500)
  21. cv2.destroyAllWindows()
  22.  
  23.  
  24. cap = cv2.VideoCapture(0)
  25.  
  26. while(True):
  27. # Capture frame-by-frame
  28. ret, frame = cap.read()
  29.  
  30. # Our operations on the frame come here
  31. gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
  32.  
  33. # Display the resulting frame
  34. cv2.imshow('flipped', cv2.flip( gray, 1 ))
  35. if cv2.waitKey(1) & 0xFF == ord('q'):
  36. break
  37.  
  38. # When everything done, release the capture
  39. cap.release()
  40. cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement