Check if a data buffer can be decoded

asked 2017-06-09 13:04:46 -0600

fijoy gravatar image

Is there an OpenCV function that allows us to do an initial check whether a given data buffer can be decoded by cv::imdecode() without fully decoding it?

Looking through the source for imdecode(), I do see that it utilizes a helper function findDecoder() to identify the correct decoder, but that helper is a static function. I'm wondering if there is public version of this function to do a quick initial check.

If there is no such public function, I should be able to write one utilizing the cv::ImageCodecInitializer container and following the code of findDecoder(), correct?

edit retag flag offensive close merge delete


why do you need it ? what would you do, if a buffer can be decoded ?

before trying to hack anything on your own, i guess you want to see the outcome of this

berak gravatar imageberak ( 2017-06-10 04:07:37 -0600 )edit

in my case an encoded buffer may be a photographic or a medical image. i want to determine which image it is efficiently so that i can skip a photographic buffer if i'm expecting a medical image. thanks for the link - the changes there should address my need.

fijoy gravatar imagefijoy ( 2017-06-10 09:03:14 -0600 )edit