LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Video Acquisition USB Camera

Hi all,

 

I'm currently using a USB camera with the latest 32-bit version of LabView with Win7. I do not have access to IMAQ drivers due to not having the Vision Acquisition software pack. I've recently modified a VI that will allow me to capture 'n' images with a gap of 1s between each capture. The camera I'm using uses the uc480.Net assembly library. My next task is to try to capture video with this camera. I found an example here Webcam that doesn't use IMAQ drivers but I don't know how to modify it for my camera. The camera appears in devices as a bulk device as opposed to a serial device. 

I have attached the VI that I have been using to capture my images. Would anyone be able to help me modify either the webcam code, or my code in order to capture video please?

 

Many thanks,

 

Emma

0 Kudos
Message 1 of 29
(7,605 Views)

Anyone any ideas? Please?

0 Kudos
Message 2 of 29
(7,549 Views)

Hi Emma,

I've been looking at the drivers and the documentation for your camera, and I think you should try this method. There are two function calls that need to be happen to record and save video from that camera. I've attached an image showing the flow of this process.

 

You will first need to get a reference for the Video object for your camera. This comes from a Property node with the Camear wired as the reference.

You the need to decide when the Start() will be called, and this will follow on from the Video reference. This should initiate the recording and specify the file.

Then call the Stop() method, and the video will stop recording. This also needs the same Video reference.

 

I hope this helps.

 

Nic

 

--------
Nico
Systems Engineer

Certified TestStand Architect Certified LabVIEW Architect

Message 3 of 29
(7,514 Views)

Hi Nic,

 

Thank you for your reply to my post and your help! I finally have a VI that I can use to capture video! I have two issues though that maybe you could help with. First, I'd like to be able to start saving my video to a file when a button is pressed on the front panel rather than just when the VI is run. I've used a case structure to start the while loop that acquires the video footage but the boolean needs to be switched to 'True' very quickly or the programme will stop. What would be the best way to keep the code running until I click the 'Acquire' button?

 

Also, when I open this VI first and run with no case structure in place, just to acquire video on startup, the programme will create a file, eg test1.avi in my chosen location but it will be empty. When I run the programme again it then fills this file with data. If I choose to write a new file, eg test2.avi, without having closed the programme, it captures the video first time. 

 

I have attached the VI I'm currently working from.

0 Kudos
Message 4 of 29
(7,496 Views)

I don't have the library that these functions are coming from it seems, so I can't see any detailed help, but I wonder, does it start writing to the file when you use the 'Start' node or the 'Open' node?

 

If you want to wait some time before saving, you need to identify which command causes it to save, and then not call that until you're ready.

 

I would guess that the best way to achieve this is by placing the reference to your camera on a shift register for your while loop, and placing an event structure inside the loop. Then, you can place your 'Save' boolean on your front panel and use the 'MySaveButton:Value Change' event to start saving data using the node you identified in the first step.

 

Given that you want to run what's currently inside your loop continuously, even when not saving (I think?), I guess you'd want to consider placing this in a 'timeout' case of the event structure with a very short timeout constant (since you currently have no wait, I'm assuming that one of the invoke nodes inside the loop controls the execution speed based on the framerate you set earlier.) You'd also need a case on the event structure to handle the 'stop:value change' event and place your stop button inside that case.

 

Without the help files I'm not sure, but I'd guess your file opening is due to either a) reading the control 'Name and file of path' before you change it or b) the 'Open' invoke node running before the file is opened. I'm not sure if that would be allowed for your node. If not, you can wire the error out node of the 'Open/Create/Replace File' primitive to the error in node of the Video's 'Open' invoke node. That will force the order to be "open file -> call 'Open' on invoke node".


GCentral
Message 5 of 29
(7,492 Views)

Hi Emma,

I'm not sure why it's not saving that data on the first run. I'd recommend passing the error wire through the Video method calls and use the simple error handler to see what shows up. It may be that the Start() is not actually running the first time, but without seeing it happen I can't be certain.

 

For you second question, I think the response above (cbutcheris a good starting point. That behavior comes down to the architecture of the application. The description is something similar to an Event-Based State-Machine. This document describes the set up of that architecture:

 

http://www.ni.com/white-paper/2926/en/

 

Nic

--------
Nico
Systems Engineer

Certified TestStand Architect Certified LabVIEW Architect

Message 6 of 29
(7,462 Views)

Hi Nic and @cbutcher,

 

Thank you both for getting back to me with some help. I have tried to include error indicators through the video nodes to take a look at what could be causing the problem I'm having when I first open the VI. The error out statements that I placed on the output of the Start() and Add Frames() nodes did not show up with an error.

 

As for the boolean start, I have still yet to figure out how I need to assemble the event structure to run as I expect it to. I had tried placing just the Start() in a case structure and trying to toggle when acquisition should occur. I still had a live display but the file remained empty. I've attached the vi with my latest attempt at trying to solve this problem.

 

Many thanks to you both,

 

Emma

0 Kudos
Message 7 of 29
(7,454 Views)

A small update on where I'm at now, I've just altered the behaviour of the code by wiring it as a state machine. The issue I'm getting at the moment is a .NET reference error. I think this is because of how I have wired the shift registers with the references. I see this error so much when I am programming in Labview, using .NET. I am obviously making the same mistake time and time again but I still don't know how to fix it. 

Would anyone know how the shift registers should be wired so I don't get a reference error? 

 

Many thanks,

 

Emma

0 Kudos
Message 8 of 29
(7,447 Views)

Hi,

I think the problem is that you haven't wired the references through each of the cases. The 'Camera Init' case creates all three references, but the other two cases don't keep those references going. Currently they both are set as 'Use Default if Unwired' on the output tunnel of the case structure. This means that each of those tunnels outputs the default value for the refnum (which is empty).

You can wire the input tunnels directly across the case structure to the correct output tunnel and the shift register should carry the reference correctly.

 

Nic

--------
Nico
Systems Engineer

Certified TestStand Architect Certified LabVIEW Architect

Message 9 of 29
(7,443 Views)

Thank you Nic, I'm no longer seeing a .NET reference error. Smiley Happy I have now run into 2 other issues. The data is no longer writing to the file, though the file is created with no issues and my stop button won't stop the programme! Could there be conflict between the boolean being on and the triggering of the stop? 

I greatly appreciate the help!

 

Emma

0 Kudos
Message 10 of 29
(7,439 Views)