Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

how to get a region by mouse click

Solved!
Go to solution

Hi,

 

I am using C# .net. I want to use the mouse to select a region from the source image for mask. How can I get the Left, Top, Width, Height values by mouse selected on the source image.

 

axCWIMAQViewer.Regions.RemoveAll();

axCWIMAQViewer.Region.GetRegionData(); //????

 

Greetings.

Message Edited by newuser12342 on 11-10-2008 09:24 AM
0 Kudos
Message 1 of 3
(3,566 Views)
Solution
Accepted by topic author newuser12342

Look in google and search for mouse coordinate - you find something like that

 

http://www.mycsharp.de/wbb2/thread.php?threadid=61761

 

   Private Sub Form2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        Dim x, y As Integer

        x = Me.MousePosition.X - (Me.Location.X + 4) '+4 wegen den rändern der form
        y = Me.MousePosition.Y - (Me.Location.Y + 30) '+30 wegen der titelleiste und dem unteren rahmen

        Form1.PictureBox1.Location = New System.Drawing.Point(x, y)
    End Sub

 

Or use this:

Control.PointToScreen und Control.PointToClient

 

When i create a mouse event in my Visual Studion 2005 C# project i can work with x and y values:

 

private void axCWIMAQViewer1_MouseDownEvent(object sender, AxNationalInstruments.CWIMAQControls._DCWIMAQViewerEvents_MouseDownEvent e)

{

e.x                                        //x  coordinates 

}

 

Please give me feedback if the help suggestions help you to work with mouse coordinates

0 Kudos
Message 2 of 3
(3,551 Views)

hi there,

 

I use  axCWIMAQViewer1_MouseDownEvent, axCWIMAQViewer1_MouseMoveEvent, axCWIMAQViewer1_MouseUpEvent to get the ROI by mouse selected.

It works fine.

 

Thanks for the info.

Greetings.


0 Kudos
Message 3 of 3
(3,529 Views)