Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

NI IMAQ USB WITH VISUAL BASIC

Hello.
I want to use imaq vision 7.1.1 with usb camera. I have downloaded the ni imaq usb driver. I have also seen the hardware example under MSVB which gets installed when Vision dev. module is installed. But I am not able to get the ni imaq usb to interface with the Visual Basic.
I get 'No interface found message' when the hardware.vbp is run.But I am able to acquire images under vision assistant. I know I am making a mistake with CWIMAQ.ocx. Can somebody pls help
Thanks
Suresh
0 Kudos
Message 1 of 10
(4,486 Views)
Suresh,
 
Bad news.  The NI-IMAQ for USB driver only works for LabVIEW.  NI Vision works in Visual Basic.  I haven't found any reference to using USB cameras with NI Vision in Visual Basic, but it should be possible.
 
I recommend you goto microsofts web page and download the DirectX Software Development Kit.  This will come with everything you will need to grab images from your USB camera from Visual Basic.  The trick will be converting the images returned by DirectShow to the image data types needed by NI-Vision (although this should not be too difficult).
 
Glad to help and good luck,
Lorne Hengst
Application Engineer
National Instruments
0 Kudos
Message 2 of 10
(4,473 Views)
Lorne,
Thanks for the reply. But my question is : How to represent the interface in CWIMAQ control. Are you suggesting offline way of working ?
thanks
Suresh
0 Kudos
Message 3 of 10
(4,465 Views)

Suresh,

You said...

"I get 'No interface found message' when the hardware.vbp is run."

This is because you are trying to use the NI-IMAQ driver to communicate with your USB camera.  The NI-IMAQ driver will not work with USB cameras.  "No interface found" is a common error stating that you are trying to open an interface to a camera, but that the interface does not exist (in your case this is because you do not have an NI-IMAQ compatible camera installed).

Installing the NI-IMAQ for USB does not allow you to use your USB camera in Visual Basic, you to use a different method to communicate with your USB camera in Visual Basic.  That is why I recommended downloading the ActiveX Software Development Kit.

You said...

"I know I am making a mistake with CWIMAQ.ocx. Can somebody pls help"

I don't think you are making a mistake importing CWIMAQ.ocx into your Visual Basic program.  If you are recieved the "No interface found" message, most likely everything is working the way it should.

Lorne Hengst
Application Engineer
National Instruments

0 Kudos
Message 4 of 10
(4,454 Views)
Ok I think I get it. You want me to use the Microsoft DirectX SDK to develop a program in VB to grab pictures from the USB camera. The sequence for achieving the vision concept would be as follows:
1.Grab image using SDK (DirectX)
2. Convert image to Vision compatible (10 bit) (though I am not sure how at this point)
3. Pass the image to the vision modules.
4. Do the image analysis algoritms

Is this what your suggestion is ? Pls correct me if I am wrong

Thanks
Suresh
0 Kudos
Message 5 of 10
(4,452 Views)
Suresh,
 
Correct!
 
"2. Convert image to Vision compatible (10 bit) (though I am not sure how at this point)"
 
This will be the most difficult part (although not too difficult), but once your have the images represented at a 2 Dimensional x-bit array, using them with the vision functions will be a breeze.
 
Lorne Hengst
Application Engineer
National Instruments
0 Kudos
Message 6 of 10
(4,449 Views)
Hi
I tried using a png file converted from jpg in one of the vb examples. CWIMAWVIewer is able to display the converted image. i think this can be used. Or is there anything ........
Thanks
Suresh
0 Kudos
Message 7 of 10
(4,445 Views)

Suresh,

I think you are going to find after you install the DirectX Software Development Kit (SDK) the the SDK will allow you to write a Visual Basic program that will return 1 image at a time from your USB camera.  I believe that if you read all of the documenatation that comes with the DirectX SDK you will find that there is a way to get images from your USB camera in the form of a 2-Dimensional Array.  If you get the images in this form, then you can use "CWIMAQImage.ArrayToImage" to convert the 2D Array into an IMAQ Image type.

Lorne Hengst
Application Engineer
National Instruments

0 Kudos
Message 8 of 10
(4,420 Views)
Thanks a lot for the reply. I shall be trying it out. Shall take some time doing that. And I shall post a reply on this thread on the development (even if  i succeed.)
Thanks
write now I am having trouble with using finding edges (object moves a little). So I am trying to get coordinates using pattern match and then position the edge tool (simple edge) But going wrong somewher (using the battery clamp example which uses circular edge find instead of the simple edge)
Anyway thanks
Suresh

0 Kudos
Message 9 of 10
(4,418 Views)

Suresh,

Let's continue this discussion on the thread below...

Coordinate Transfer problems in VB

Thanks,
Lorne Hengst
Application Engineer
National Instruments
0 Kudos
Message 10 of 10
(4,406 Views)