LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I take a picture from usb camera using the Windows Image Acquisition Automation activex control in LabWindows?

Hy!
I have a faculty project in wich I have to acquire image from a webcam in Labwindows 8.1 and to take a picture and save it in a file and to display it.I managed to acquire image from the webcam using the WIA automation activex controll but I haven't been able to take a picture and save it and display it .So i ask of you to post a tutorial or something that would help me to take a picture and save it and display it using the WIA automation activex controll in LabWindows.
OS: Windows XP Professional X86

Please help me!!
0 Kudos
Message 1 of 10
(7,101 Views)

Hello acsyman,

 

I have not seen any users who have done this in C, but here is a.NET example located in another forum.  It should at least give you a frame for how you can craft your code.  

 

I also want to mention that the latest IMAQdx has this functionality built into the driver, but IMAQdx does require a separate license to activate to use.  

 

When you say that you were able to save an image with the WIA Control, is this a separate interface or something that you coded into LabWindows? If you already have the image acquisition, are you just trying to figure out how to display them?

ColeR
Field Engineer
0 Kudos
Message 2 of 10
(7,075 Views)
By acquiring image I ment I had acquired a video using WIA from my webcam.I am sorry I wasn't to explicit.I didn't manage to take a picture and save it and display it.
0 Kudos
Message 3 of 10
(7,060 Views)
Were you able to get anything from the .NET example linked?  Without another user's input, I do not know of where else to point you.  Here's a link to MSDN that has all of the interfaces documented and can give you a better idea of what calls you have available to you.  Do you have any experience with programming with ActiveX before?  What have you tried so far that you're having problems with?
ColeR
Field Engineer
0 Kudos
Message 4 of 10
(7,040 Views)

Unfortunetly I do not have any experience with Activex.This is one of the codes I tried so far:

#include "wiaaut.h"
#include <cvirte.h>        
#include <userint.h>
#include "camm.h"

static int panelHandle;
   int cid,eroare;
   CAObjHandle objh;
   WIAObj_IImageFile result;
   ERRORINFO eror;
 
int main (int argc, char *argv[])
{
    if (InitCVIRTE (0, argv, 0) == 0)
        return -1;    /* out of memory */
    if ((panelHandle = LoadPanel (0, "camm.uir", PANEL)) < 0)
        return -1;
    DisplayPanel (panelHandle);
    RunUserInterface ();
    DiscardPanel (panelHandle);
    return 0;
}


int CVICALLBACK OkCallback (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:
           WIA_NewIVideoPreview(panelHandle,"Video",45,45,&cid,&eroare);
           GetObjHandleFromActiveXCtrl(panelHandle,cid,&objh) ;
            
           
            break;
    }
    return 0;
}

int CVICALLBACK QuitCallback (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:
            QuitUserInterface (0);
            break;
    }
    return 0;
}

int CVICALLBACK pozaCallback (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:
          
            

           WIA_NewICommonDialog(panelHandle,"poza",45,400,&cid,&eroare);
           WIA_ICommonDialogShowAcquireImage(objh,&eror,2,1,131072,"{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}",VTRUE,VTRUE,VTRUE,&result);
           

            break;
    }
    return 0;
}
0 Kudos
Message 5 of 10
(7,030 Views)

I haven't tried the .net example so far ,because the holidays are coming and I have some work to do,but as soon as I will I write I post here.

Thank you verry much for your quick response, I apreciate that.

0 Kudos
Message 6 of 10
(7,029 Views)

Hey acsyman,

 

Here's a KB that outlines a tool that will generate a framework from an ActiveX library that you can use to build your code up with.  Primarily designed to build Instrument Drivers, it also serves well for someone who doesn't have experience with ActiveX programming.  Hope this helps!

ColeR
Field Engineer
0 Kudos
Message 7 of 10
(7,012 Views)
I have allready built an instrument driver with the tool you mentioned.I will try some more.Thank you for your help so far.
0 Kudos
Message 8 of 10
(7,002 Views)

Hello ColeTrain,

 

You mentioned that the IMAQdx has the USB stuff built into it, but I'm having trouble getting it to work. We use LabWindows CVI 8.1 with Vision 8.6 and we have our system working with a firewire camera, but I'd like to change it to a USB one. I can capture a USB frame in the Vision Assistant 8.6, but that's about it.

 

With 2 USB cams connected, when I try IMAQdxEnumerateCameras, I get 0 cameras returned. Also, I can't see the USB cameras in MAX, so I assume that may have something to do with it. I'm reluctant to go down the WIA path since our software needs to work in Windows XP and Win7.

 

Was there an update that we missed? Is there updated documentation/example of getting USB cameras to work for all builds?

 

Thank,

Stan.

0 Kudos
Message 9 of 10
(5,934 Views)

Hi Stan,

 

First of all, you probably would have been better off posting in a new thread as this one is two years old and the issue seems to be different.

 

IMAQdx will work with both USB and FireWire cameras that are DirectShow compliant. (See this KnowledgeBase)

 

If the cameras do not show up in Measurement & Automation Explorer (MAX), then they probably are not DirectShow compliant. If this is the case, then the only options would be to call into the dll that the camera manufacture's software uses to display images or going down the WIA path as discussed in this thread.

------------------------------
Bill E. | Applications Engineer | National Instruments
0 Kudos
Message 10 of 10
(5,920 Views)