I need to do some image processing recently. When I get the picture stream after a series of protocol parsing and decoding, the next step is to use cv2 to process the picture. First, I need to get the picture object of cv2.
generally
import cv2
img = cv2.imread ("test.jpg")
so you can get the img object directly.
but I want to convert directly in memory. I don"t want to write to the file and read it in cv2, so I can skip the step of image caching.
with the help of the great gods, I have been tinkering with it for a long time. How can it be realized?
such as
fc= open ("test.jpg", "rb"). Read ()
) when fc is the file stream of the image, which is the same as the file stream I processed.
so how do I read it in cv2 now?
cv2.imread (fc) is definitely wrong.