I\'m working with PyOpenCV. How to convert cv2 image (numpy) to binary string for writing to MySQL db without a temporary file and imwrite?
imwrite
I googled it
It works in 2020 with numpy==1.19.4 and opencv==4.4.0:
import cv2 cam = cv2.VideoCapture(0) # get image from web camera ret, frame = cam.read() # convert to jpeg and save in variable image_bytes = cv2.imencode('.jpg', frame)[1].tobytes()