what exactly does the imencode do, wanted to use it for image upload onto server? [closed]
I am converting an image using imencode
. I'm currently using opencv 3.4
couldn't find the official documentation for 3.4
but did find one for 3.0
. Reading and Writing Images
It's given here that the output is retval
and buf
its said that The function compresses the image and stores it in the memory buffer that is resized to fit the result.
What is the type of compression/encoding
that is followed here in OpenCV
?
ex: cv2.imencode(".jpg",image)
I can just transfer this buf
to a server through an API, which I know will be in compressed format.
How will I decode the received buf
without knowing how it was encoded?
what if you lookup cv2.imdecode() ?
it also should be :
cv2.imencode(".jpg",image)
(extension there is a string)Can't find any info about
cv2.imdecode
also, onlyThe function reads an image from the specified buffer in the memory
no explanation of how it is actually carried outimencode and file signatures and it is not an opencv problem
@LBerger Can you explain? I don't get you. Please share your thoughts and possible solution.
@Santosh1, solutions for which problem ?
imencode() will choose a codec based on the extension string
imdecode() will look at the buffer's file magic, to choose a decoder
@berak I have an image file with dimension
4160 x 2340
, when I docv2.imencode(".jpg",image)
. I have annumpy.ndarray
of shape2756259 , 1
. So based on your explanation a jpg codec is used to compress original image and stored inndarray
. I want to save this compressed.jpg
file that is in form ofndarray
at particular location on cloud?yes, and ? (where is the problem ?)
In
VM
I could have just usedcv2.imwrite
to save the file used custom API to upload the image file on to the cloud. I'm not usingVM
I'm usingcloud function
, which is serverless no VM. I need to store this compressed.jpg
on cloud. How do I do it? With just an.jpg
compressed variable I currently have? I'm confusedif you want to store it somewhere, you obvioously need some datastore, but all of that is entirely off-topic here.
@berak Yes you are correct, its a database thing not related to the topic. I'm not asking about that. I just shared it to for you to know my final goal.I would like to know till where can
OpenCV
help me reach there?