Ask Your Question
0

Converting an OpenCV frame to JPEG format in app

asked 2018-11-26 08:16:35 -0500

iono gravatar image

updated 2018-11-26 08:36:04 -0500

Currently, I am following https://www.pyimagesearch.com/2018/06... . I got the app up running on Raspberry Pi.

I have modified the code a bit in that it will send the name of the detected face into my Websocket server. I could already sent the name as a simple string in JSON without any issue. However, I would like to send in the image (or frame, if you preferred) of the detected face as well. No face segmentation required. I just want the whole image at the time of face detection.

I am thinking of something like converting the frame into JPEG first, then just send the data right into Websocket. From looking around, I see that there is imwrite function, but it saves a file. Is it possible to convert a frame into JPEG data without saving to a file? How can this be done? Or are there better ways to do this?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2018-11-26 08:40:05 -0500

LBerger gravatar image

read doc imencode

edit flag offensive delete link more
-3

answered 2018-11-26 22:33:41 -0500

supra56 gravatar image
img = cv2.imread('supra.png')
print('converting image.....')
cv2.imwrite('supra1.png', img, [cv2.IMWRITE_JPEG_QUALITY, 10]) #SELECT 0-100PRI
edit flag offensive delete link more

Comments

read doc IMWRITE

supra56 gravatar imagesupra56 ( 2018-11-26 22:35:36 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-11-26 08:16:35 -0500

Seen: 40 times

Last updated: Nov 26