LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQ Image Control-- Restrict ROI contours to image bounds

Greetings. I am working on a system that involves a single user drawn ROI/contour (straight line or rectangle, and most likely rotated rectangle in the future) within an IMAQ image control that displays the output from a camera. This ROI will serve as the spatial dimensions of a particular measurement on the sample under the camera, thus it is important the ROI be limited to the image bounds.

 

The default control allows contours to go outside of the image boundaries, both during the initial drawing and moving the ROI. I have not found a built in option to enforce such a restriction. Limiting the mouse position to the image via the user32.dll clipcursor function works well for drawing a new ROI, but not for moving an exisiting ROI, since the mouse is near the center when moving an ROI.

 

I have also tried reseting the cursor position to back within the image when the bounding box of the ROI goes out of the image bounds, but I have not been able to get a clean effect out of this. It remains very jumpy and makes for a meh user experience.

I would like to ask if anyone else has tackled such a problem before and knows of an effective solution?

0 Kudos
Message 1 of 2
(2,389 Views)

A question is "What would you want to do if the ROI goes outside the Image boundary?".  One thing you could do would be to simply detect this case and refuse to make the change (flashing up a Warning to the User).  An alternative would be to alter the ROI so that it lies within the Image (I think that this would not be difficult to do, but haven't yet tried to do it).  If you choose this method, you'll have to deal with how to handle a "rotated rectangle".  Do you "chop off a corner" (to make a trapezoid, or a 5-sided ROI) or do you shorten the "sticking-out" end until it is inside.

 

This seems (to me) to be a relatively simple problem to solve, particularly if started with several sheets of paper and a good pencil (or pen).  [I've done similar things with ROIs, but not recently ...].

 

Bob Schor

0 Kudos
Message 2 of 2
(2,361 Views)