acdha / image-mining

Experiments mining image collections using OpenCV
Other
64 stars 21 forks source link

locate-thumbnail: handle failures to reconstruct the crop box #5

Open acdha opened 10 years ago

acdha commented 10 years ago

There are two problems here:

  1. We should have sanity checks for the crop box falling outside of the image bounds
  2. We should catch errors like the libpng failure and ensure that a non-zero exit code is returned
INFO locate_thumbnail: Attempting to locate /tmp/tmpkq9k0z-wdl-19.thumbnail/mstr_3g03352u.jpg within /tmp/tmpkq9k0z-wdl-19.thumbnail/3g03352u.tif
INFO locate_thumbnail: Found 196 matches
INFO find_homography: 135 inliers, 196 matched features
INFO get_scaled_corners: Thumbnail bounds within analyzed image: [[-2, 96], [1048, 95], [1043, 959], [2, 961]]
INFO reconstruct_thumbnail: Reconstructing thumbnail from source image
INFO reconstruct_thumbnail: Master dimensions: (1458, 1152, 3)
INFO reconstruct_thumbnail: Thumbnail dimensions: (255, 308, 3)
INFO reconstruct_thumbnail: Reconstructed thumb dimensions: (866, 0, 3) (rotation=0°)
libpng warning: Image width is zero in IHDR
libpng error: Invalid IHDR data
acdha commented 10 years ago

The basic fix has worked well in testing but it does risk changing the aspect ratio slightly for applications where that matters. The more advanced step would involve actually adjusting the edges slightly to perfectly match.