Machine Vision

取消
显示结果 
搜索替代 
您的意思是: 

How can I programmatically modify/delete ROIs of an ImageViewer in .NET

Hello, I am using the NationalInstruments.Vision.WindowsForms.ImageViewer .NET-control of Vision 2009 to display camera images. I take the coordinates of a drawn rectangle Roi to specify a camera crop region. Then I would like to delete/modify/scale the Roi because the new cropped images from the camera have a different size so the Roi is displayed at the wrong position. But all the control's properties are read-only. And if I modify/clear the Roi array (ImageViewer.Roi) I get an exception out of the control. Is there a "clear roi" function or something similar that I have overlooked? Is there another workaround? Thanks a lot for your help, Fabian
0 项奖励
1 条消息(共 5 条)
4,694 次查看

The ROIs drawn on the image are stored in a collection (imageViewer.Roi)

imageViewer.Roi.Clear() will clear the ROIs drawn on the display control.

To add a new ROI, you first need to define its contour, then add it to the collection.

 

Dim roiContour As New RectangleContour(98, 134, 285, 182)

imageViewer.Roi.Add(roiContour)

 

Vision Development Module ships with .NET examples that you can find here:

C:\Program Files (x86)\National Instruments\Vision\Examples\dotNET

 

You can also prototype your algorithm using Vision Assistant, and generate the .NET code. This will show you how the different functions can be implemented in .NET.

 

Hope this helps,

 

-Christophe

0 项奖励
2 条消息(共 5 条)
4,687 次查看
Hi Christophe, but imageViewer.Roi.Clear() ends up with an AccessViolationException: {"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}. Any idea? thx, Fabian
0 项奖励
3 条消息(共 5 条)
4,673 次查看

Can you zip and attach a simple example that reproduces the problem?

 

Thanks,

 

-Christophe

0 项奖励
4 条消息(共 5 条)
4,670 次查看
Hi Christophe, I think I found the problem: The exceptions occur if you call the viewer's function from a different thread. It works if you invoke the calls on the Form's thread. Thanks for your help, Fabian
0 项奖励
5 条消息(共 5 条)
4,663 次查看