I am having difficulty sending a jpeg opened with cv2 to a server as bytes. The server complains that the file type is not supported. I can send it without problems using Python's "open" function, but not with OpenCV. How can I get this to work?
import cv2
path = r".\test\frame1.jpg"
with open(path, "rb") as image:
image1 = image.read()
image2 = cv2.imread(path, -1)
image2 = cv2.imencode(".jpg", image2)[1].tobytes() #also tried tostring()
print(image1 == image2)
#This prints False.
#I want it to be True or alternatively encoded in a way that the server accepts.