android opencv imdecode returns empty Mat!

asked 2019-09-26 12:47:01 -0600

ramprasad90 gravatar image

updated 2019-09-27 07:31:37 -0600

supra56 gravatar image

Code:

public void processPicture( Mat picture ) {
 Mat img = Imgcodecs.imdecode(picture, Imgcodecs.CV_LOAD_IMAGE_UNCHANGED);
}

//picture contains data, when we decode to Mat img returns empty!

Please help with this issue, Thanks in advance.

edit retag flag offensive close merge delete

Comments

how do you obtain picture ? what is it ? and what do you expect to be there ?

berak gravatar imageberak ( 2019-09-26 12:51:54 -0600 )edit

i will got the ImageReader from camera2 and convert it into mat object and forward to processPicture method.

ramprasad90 gravatar imageramprasad90 ( 2019-09-27 01:00:28 -0600 )edit

why do you think, you have to imencode() it at all, then ? (it expects an image "as on disc", headers, compressed pixels, etc. probably not what you have there)

please check picture.size() and picture.type() (and tell us !)

berak gravatar imageberak ( 2019-09-27 01:10:03 -0600 )edit

Thank you for reply, picture.size():4032x3024 and picture.type():0

ramprasad90 gravatar imageramprasad90 ( 2019-09-27 04:52:00 -0600 )edit

picture.size():4032x3024 and picture.type():0 img.size():0x0 and img.type():0

ramprasad90 gravatar imageramprasad90 ( 2019-09-27 05:03:36 -0600 )edit

i'm quite sure, you can just skip the imdecode(), here (as you already have a "ready-to-use" image in the Mat).

berak gravatar imageberak ( 2019-09-27 05:04:29 -0600 )edit

Thank you for giving reply.

ramprasad90 gravatar imageramprasad90 ( 2019-09-27 05:11:21 -0600 )edit