Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Skip invalid IplImage from being scanned #57

Merged
merged 1 commit into from
Jan 26, 2016

Conversation

bluk
Copy link
Contributor

@bluk bluk commented Jan 25, 2016

  • In very odd but numerous crash reports, there are instances where the IplImage does
    not have a valid header. This could cause a crash notably calling through (reversed stack trace):

    [CardIOVideoStream sendFrameToDelegate:]
    [CardIOCameraView videoStream:didProcessFrame:]
    [CardIOView videoStream:didProcessFrame:]
    [CardIOView didScanCard:]
    [CardIOVideoFrame imageWithGrayscale:]
    [CardIOIplImage rgbImageWithY:cb:cr:]
    void dmz_YCbCr_to_RGB(IplImage *y, IplImage *cb, IplImage *cr, IplImage **rgb)
    

    and eventually calls cvGetSize() which throws an exception with
    "Array should be CvMat or IplImage".

    This code tries to detect invalid IplImage values earlier and skips scanning them.

@@ -133,8 +133,8 @@ - (void)detectCardInSamplesWithFlip:(BOOL)shouldFlip {
dmz_transform_card(self.dmz, self.ySample.image, self.corner_points, frameOrientation, false, &foundCardY);
self.cardY = [CardIOIplImage imageWithIplImage:foundCardY];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this assignment to self.cardY also wait until we've confirmed that foundCardY is valid?

I.e., if we get as far as the call to dmz_transform_card(), but the result is invalid, then act as if foundCard were false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, sounds good. I amended the commit.

- In very odd but numerous reports, there are instances where the IplImage does
  not have a valid header. This could cause a crash notably in:
  [CardIOView didScanCard:]
  [CardIOVideoFrame imageWithGrayscale:]
  [CardIOIplImage rgbImageWithY:cb:cr:]
  void dmz_YCbCr_to_RGB(IplImage *y, IplImage *cb, IplImage *cr, IplImage **rgb)
  and eventually calls cvGetSize() which throws an exception with
  "Array should be CvMat or IplImage".

  This code tries to detect invalid IplImage values earlier and skips using
  them for scans.
@dgoldman-pdx
Copy link
Member

Looks reasonable to me! :shipit:

bluk added a commit that referenced this pull request Jan 26, 2016
Skip invalid IplImage from being scanned
@bluk bluk merged commit 0b4bd70 into card-io:master Jan 26, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants