Ask Your Question
0

Intercept Corrupt Data

asked 2013-07-04 18:22:36 -0600

Wnt2bsleepin gravatar image

Hello, I have some corrupted image data mixed with some images. When I load it with

cv2.imread(image)

I get the error

Corrupt JPEG data

I would like to intercept this and move those images to a folder since they have corruption issues. However, it doesn't seem to be an exception so I cannot catch it. Any help is appreciated.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-07-05 04:55:57 -0600

I guess this stackoverflow topic gives you a hint on how you could approach the problem.

edit flag offensive delete link more

Comments

Indeed. Calling the decode function brings up the error. I do wish it threw an exception.

Wnt2bsleepin gravatar imageWnt2bsleepin ( 2013-07-05 13:21:37 -0600 )edit

Wouldn't a try - catch around the decode function work?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-05 14:46:55 -0600 )edit

No, it doesn't throw an exception. It does seem to print the error message on the stderr stream, but I don't know how to capture it when the program is running.

Wnt2bsleepin gravatar imageWnt2bsleepin ( 2013-07-05 16:51:35 -0600 )edit

Time to dig into code and look where the actual error message is generated I would say, then generating an exception yourself by adding the lines of code necessary and then build OpenCV yourself with the adapted code. Maybe even add it as a pull request so it gets added in the official library.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-06 05:48:40 -0600 )edit

Question Tools

Stats

Asked: 2013-07-04 18:22:36 -0600

Seen: 2,301 times

Last updated: Jul 05 '13