bytedeco / javacv

Java interface to OpenCV, FFmpeg, and more
Other
7.49k stars 1.57k forks source link

Handling corrupt images #1467

Open saketsneha opened 4 years ago

saketsneha commented 4 years ago

I am using val sourceImageMat = imread(sourceImage.toString()) to read a file in java. But for corrputed images it just prints Premature end of JPEG file . I can see its not an exception and that is why its not ignoring the image but processing it further. Is there a way to avoid this processing? Have had a look at the community channel but was not of much help.Hope you can throw some ideas around this?

samplecorrupt

saudet commented 4 years ago

In that case, sourceImageMat.empty() will be true, so you can throw an exception on that if you need it.

saketsneha commented 4 years ago

@saudet no its not returning empty Mat

saketsneha commented 4 years ago

@saudet I have this condition added if (!sourceImageMat.empty()) {} , its still going inside

saudet commented 4 years ago

You can try to use Leptonica instead. It has more options when it comes to loading images.

saketsneha commented 4 years ago

its a completely different library , there is nothing in javacv that can be helpful?I am not wanting to a new library.Thanks for reopening.

saudet commented 4 years ago

Leptonica is part of JavaCV...

saketsneha commented 4 years ago

https://tpgit.github.io/Leptonica/jpegio_8c_source.html this return a warning only.It would not be helpful right?I need an exception