Skip to content

Exception ERROR in ColorSpaces: interactiveColorDetect.cpp#780

Open
PrimusSPS wants to merge 1 commit intospmallick:masterfrom
PrimusSPS:patch-1
Open

Exception ERROR in ColorSpaces: interactiveColorDetect.cpp#780
PrimusSPS wants to merge 1 commit intospmallick:masterfrom
PrimusSPS:patch-1

Conversation

@PrimusSPS
Copy link
Copy Markdown

Current code throw an exception error when cursor is moved in the "placeholder" area. It can be fixed by updating the if condition on line 12:

FROM:
LINE 12: if( event == EVENT_MOUSEMOVE)

TO:
LINE 12: if( event == EVENT_MOUSEMOVE and (x<img.rows and y<img.cols))

Current code throw an exception error when cursor is moved in the "placeholder" area. It can be fixed by updating the if condition on line 12:

FROM:
LINE 12: if( event == EVENT_MOUSEMOVE)

TO: 
LINE 12: if( event == EVENT_MOUSEMOVE and (x<img.rows and y<img.cols))
@spmallick
Copy link
Copy Markdown
Owner

Thanks for the fix attempt. The reported crash is real, but I don’t think this condition is correct yet.

In the mouse callback, x is the column coordinate and y is the row coordinate, so the bounds check should be against img.cols for x and img.rows for y. The current PR uses:

x < img.rows && y < img.cols

which is swapped. It only appears to work here because the image is resized to 400x400, so rows == cols.

Could you please update it to something like:

if (event == EVENT_MOUSEMOVE && x >= 0 && x < img.cols && y >= 0 && y < img.rows)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants