Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why is this triggering EXC_BAD_ACCESS?

Sometimes this code triggers a critical error. I tried to put every condition I could think of to prevent bad input, but it's still not working sometimes.

if (image.rows < 1 || image.cols < 1 || ![keyframe.camera isInFrame:position withBoundary:0] || image.channels() < 4)
        return Vec3f(0,0,0);

Vec4b bgra;
bgra = image.at<Vec4b>(position.x, position.y);

Any clue?

Why is this triggering EXC_BAD_ACCESS?

Sometimes this code triggers a critical error. I tried to put every condition I could think of to prevent bad input, but it's still not working sometimes.

- (Vec3f)extractColorWithKeyframe:(Keyframe*)keyframe WithPosition:(Point2f)position
{
    Mat image = keyframe.originalImage;
    if (image.rows < 1 || image.cols < 1 || ![keyframe.camera isInFrame:position withBoundary:0] || image.channels() < 4)
        return Vec3f(0,0,0);

 Vec4b bgra;
 bgra = image.at<Vec4b>(position.x, position.y);

Any clue?

Why is this triggering EXC_BAD_ACCESS?

Sometimes this code triggers a critical error. I tried to put every condition I could think of to prevent bad input, but it's still not working sometimes.

- (Vec3f)extractColorWithKeyframe:(Keyframe*)keyframe WithPosition:(Point2f)position
{
    Mat image = keyframe.originalImage;
    if (image.rows < 1 || image.cols < 1 || ![keyframe.camera isInFrame:position withBoundary:0] || image.channels() < 4)
        return Vec3f(0,0,0);

    Vec4b bgra;
    bgra = image.at<Vec4b>(position.x, position.y);

Any clue?