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
?
I googled it
My code to use opencv with python cgi :
im_data = form['image'].file.read()
im = cv2.imdecode( np.asarray(bytearray(im_data), dtype=np.uint8), 1 )
ret, im_thresh = cv2.threshold( im, 128, 255, cv2.THRESH_BINARY )
self.send_response(200)
self.send_header("Content-type", "image/jpg")
self.end_headers()
ret, buf = cv2.imencode( '.jpg', im_thresh )
self.wfile.write( np.array(buf).tostring() )