Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import requests
- def process_frame(bgr_image, jpg_as_text):
- try:
- # Post to api for processing and get the results
- # result = requests.post("example.com", data={"jpg": jpg_as_text})
- # Add results to bgr_image
- # cv2.putText()
- except Exception as e:
- print(e)
- pass
- # Show the frame
- cv2.imshow("frame", bgr_image)
- video = cv2.VideoCapture("video.mp4")
- i = 0
- while video.isOpened():
- ret, bgr_image = video.read()
- if ret == True:
- img_height, img_width, _ = bgr_image.shape
- jpg_as_text = cv2.imencode(".jpg", bgr_image)[1].tostring()
- process_frame(bgr_image, jpg_as_text)
- print(i)
- i += 1
- else:
- break
- if cv2.waitKey(1) & 0xFF == ord("q"):
- break
- video.release()
- cv2.destroyAllWindows()
Add Comment
Please, Sign In to add comment