Guest User

Untitled

a guest
Jun 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import cv2
  2. import requests
  3.  
  4.  
  5. def process_frame(bgr_image, jpg_as_text):
  6. try:
  7. # Post to api for processing and get the results
  8. # result = requests.post("example.com", data={"jpg": jpg_as_text})
  9.  
  10. # Add results to bgr_image
  11. # cv2.putText()
  12. except Exception as e:
  13. print(e)
  14. pass
  15. # Show the frame
  16. cv2.imshow("frame", bgr_image)
  17.  
  18.  
  19. video = cv2.VideoCapture("video.mp4")
  20. i = 0
  21.  
  22.  
  23. while video.isOpened():
  24. ret, bgr_image = video.read()
  25. if ret == True:
  26. img_height, img_width, _ = bgr_image.shape
  27. jpg_as_text = cv2.imencode(".jpg", bgr_image)[1].tostring()
  28. process_frame(bgr_image, jpg_as_text)
  29. print(i)
  30. i += 1
  31. else:
  32. break
  33. if cv2.waitKey(1) & 0xFF == ord("q"):
  34. break
  35.  
  36. video.release()
  37. cv2.destroyAllWindows()
Add Comment
Please, Sign In to add comment