def video_emitter(video):
# Open the video
video = cv2.VideoCapture(video)
print(' emitting.....')
# read the file
while (video.isOpened):
# read the image in each frame
success, image = video.read()
# check if the file has read the end
if not success:
break
# convert the image png
ret, jpeg = cv2.imencode('.png', image)
# Convert the image to bytes and send to kafka
producer.send_messages(topic, jpeg.tobytes())
# To reduce CPU usage create sleep time of 0.2sec
time.sleep(0.2)
# clear the capture
video.release()
print('done emitting')
评论列表
文章目录