问题描述
OpenCV说类似
Corrupt JPEG data: premature end of data segment
或
Corrupt JPEG data: bad Huffman code
或
Corrupt JPEG data: 22 extraneous bytes before marker 0xd9
当使用imread()加载损坏的jpeg图像时.我能以某种方式抓住它吗?否则我为什么会得到这些信息?我必须自己检查二进制文件吗?
when loading a corrupt jpeg image with imread().Can I somehow catch that? Why would I get this information otherwise?Do I have to check the binary file on my own?
推荐答案
如果使用imread()
,则无法捕获它.但是,有imdecode()
函数由imread()
调用. 也许,它可以为您提供更多反馈.为此,您必须自己将图像加载到内存中,然后调用解码器.
You cannot catch it if you use imread()
. However there is imdecode()
function that is called by imread()
. Maybe it gives you more feedback. For this you would have to load the image into memory on your own and then call the decoder.
它可以归结为:您必须深入研究OpenCV来源才能解决您的问题.
It boils down to: You have to dig through the OpenCV sources to solve your problem.
这篇关于在OpenCV中使用imread()加载图像时,如何捕获损坏的JPEG?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!