Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Coordinate Transfer problems in VB

I am attempting to perform an edge detection on a rotated image in VB.
First I obtain the CWMVCoordinatTransformation using the FindCoordTransformUsingPattern function.
Next I use the TransformRegions function to adjust the regions of my CWIMAQViewer from the reference system to the measurement system.

The problem I am having is that as I rotate the feature clockwise my region appears to shift away from the coordinate system along the Y-axis, and as I rotate the feature counter clockwise my region appears to shift toward the coordinate system along the Y-axis. ( The region does rotate and shift with the measurement coordinate system, but it is moving along the Y-axis as well ) Any suggestion what might be causing this behavior?

Thanks
0 Kudos
Message 1 of 7
(4,789 Views)
Hi A Wooten,

Thanks for using our discussion forums. I haven't seen this behavior before, although it sounds to me like the image is being rotated around a different point each time (possibly something in the way the coordinate system is set). Try something like the example I included with this post. If you are still ahving trouble, I'd be glad to take a look at a sample of your code that demonstrates this. We'd look forward to hearing from you. Have a happy Thanksgiving.

Regards

Dan
National Instruments
0 Kudos
Message 2 of 7
(4,771 Views)
Hello
I am posting this message out of context. Pardon me. I donot find much help with VB and imaq vision.
I am developing an application similar to your post. I am using edge detection on a pulley to find the edges. If the pulley is not in an fixed position the edge detection does not work (because the tool is not positioned on the edge of the pulley)
I found a suggestion to use pattern match, transform the same to coordinates and then position the edge tool.
Unfortunately, I am able to go upto the coordinate defining (using the battery clamp example code). But i am not able to define the edge tool (the battery clamp uses circular edge not needed by my application)
Can you pls suggest me a way out or an extract of some vb program
Thanks a lot in advance  
Image attached. Need to count the no. of ridges.

Suresh  

0 Kudos
Message 3 of 7
(4,613 Views)
Suresh,
 
Thanks for posting the image, it really helps me understand what you are trying to accomplish.
 
You said you need to count the number of ridges on your pulley.  I really think doing a simples edges detection will achieve what you need.  The method "CWIMAQVision.FindEdges2" will do this for you.  Below is example code from the NI Vision for Visual Basic Reference Help.
 
-----------------
' Find the first and last edge coordinates along a path defined by regions
' on Viewer1 and display the coordinates on the image.
Private Sub Run_Click()
    Dim ProfileReport As New CWIMAQProfileReport
    Dim EdgeOptions As New CWIMAQEdgeOptions
    Dim EdgeCoordinates As New CWIMAQPoints
    Dim EdgeReport As New CWIMAQEdgeReport
    Dim J As Integer
   
    ' Find the coordinates of the points along the path
    ' defined by the regions on Viewer1
    CWIMAQVision1.RegionsProfile CWIMAQViewer1.Image, CWIMAQViewer1.Regions, ProfileReport
   
    ' Find the first and last edges along the selected path
    CWIMAQVision1.FindEdges2 CWIMAQViewer1.Image, ProfileReport(1).Coordinates, EdgeOptions, _
                             EdgeCoordinates, cwimaqEdgeProcessFirstAndLast, EdgeReport
   
    ' Display the results
    For J = 1 To EdgeCoordinates.Count
        CWMachineVision1.DrawCircularPoint CWIMAQViewer1.Image.Overlays(1), EdgeCoordinates(J), _
                                           8, cwimaqOverlayModePaint, vbRed
    Next
End Sub
-----------------
 
The catch is that your pulley might be in different locations for each image.  If this is the case you will need to first detect the pulley and then use the position and orientation of the pulley to setup a coordinate system so that you do the edge detection along the correct line, no matter where your pulley appears in the image.  Doing this in Visual Basic is not so straight forward and will require that you combine a few example programs together.
 
On the other hand, you could purchase Vision Builder for Automated Inspection.  You would be able to setup an inspection which does exactly what I am talking about above within 1 week.  I kid you not.  And if you have to get the inspeciton of the pulley to integrate with some Visual Basic code, you in luck.  Vision Builder for Automated Inspection ships with an ActiveX library which will allow you to communicate with Vision Builder for Automated Inspection from Visual Basic.  Honestly, spending a few extra dollars to save you many hours of work and frustration will be worth it.  Also, you do not need LabVIEW to run Vision Builder for Automated Inspection.
 
Follow the link below to learn more about Vision Builder for Automated Inspection...
 
I hope I answered your question,
Lorne Hengst
Applicaiton Engineer
National Instruments
0 Kudos
Message 4 of 7
(4,592 Views)
Dear Lorne,
Thanks for the response.
AS you mentioned, I did try the code excerpt. But ran into problems. Exactly as your said, getting the pulleys at diff. positions. i am not able to get the coordinates of the pattern match into the following code excerpt. Knowing I am making some outlandish mistake,
As you mentioned, I am tryng the eval of VBAI and definitely it is good.
Sad to say, I have bought vision devl. module 7.1.1, Labview 8, Vision deployement license,PCI 1405 (2Nos). All this after I had a trial with VBAI before deciding. And There was no demo for Vision dev. module. Then I was suggested that Vision development offers portability to VB whereas VBAI does not. Now all I can say  I am stuck
Now the few dollars more you suggest will real nail me down.
At least you can suggest the example program names and I shall do my best.
Thanks
Suresh
0 Kudos
Message 5 of 7
(4,586 Views)
An after thought. Can VBAI scripts be ported to Vison Dev. And Can the VBAI ActiveX be run on a machine without labview but with Ni-IMAq , IMAQ Vision deplyment license and kit.
Thanks
Suresh
0 Kudos
Message 6 of 7
(4,587 Views)
Hi All
Thanks Thanks Thanks to everyone. I could at last get to locate the simple edge detecting tool along the derived coordinates.

There is light beyond darkness. i have to just keep walking
Suresh

0 Kudos
Message 7 of 7
(4,577 Views)