04-06-2023 02:41 PM
I have a logitech HD Pro Webcam C920. The frame rate of this camera by default is 30 fps. But I need to record an image sequence at 1 fps for my experiments, by using this camera. I was trying to write the labview code using the NI-IMAQdx utility. The code file is attached (whatever I have tried so far). But I am unable to proceed further like which functionality to use for reducing the rate at which images will be recorded. Can someone please offer any suggestion or help in this ?
Thanks,
Solved! Go to Solution.
04-07-2023 08:49 AM
Have you tried plugging in the camera and using MAX to do a Grab? When I did this using LabVIEW 2019 SP1 (32-bit), MAX told me (under Acquisition Attributes) that it was using 2560x1472 YUY2 at 2.00fps (which was the highest resolution and the slowest default Frame Rate). When I did a "Grab", I seemed to get images at 2 Hz (I didn't exactly time it, but it was certainly faster than 1 Hz (though, to be honest, it seemed slower than 2 Hz). Note that to see the entire image in MAX, I had to right-click the viewer and choose "Zoom to fit" -- it might have slowed down to get all those pixels on the screen).
I would imagine I could write a trivial routine in LabVIEW to do the same thing. I wouldn't, of course, put the "Viewer" inside the same loop as the "Acquirer", but would use a Stream Channel Wire to pass the incoming Images to a "View" loop.
Bob Schor
04-07-2023 09:53 AM
Thanks Bob_Schor for the reply. I tried to Grab using the MAX. But, I can only see the option of 30 fps, at any resolution. So, can you suggest how to write a routine for this in the labview to capture images at 1 fps ?
04-08-2023 02:06 PM
I apologize for taking so long to get back to you. I'm right now sitting in my house, with my Logitech C920 "looking at me", and trying to figure out how to set the Frames/second on this camera. Turns out this is not an enumerated attribute of the camera! Which just makes the job a little more difficult, but not impossible (Famous Last Words!).
The Good News is you want a very low frame rate, 1 Frame/second. This is easy -- it is called an IMAQdx Snap (not a Grab), namely "Acquire a single Image". I'm going to open up LabVIEW and try this out:
So now we are 90% of the way done. To finish, drop a While Loop around the Snap and Image (leave "Get Image" outside to the left). Right-click the Stop Icon, "Create Control". Drop a "Wait until next Multiple" inside the loop, wire 1000 to it (1000 ms = 1 sec). Create a copy of this "Wait 1 sec" outside the While Loop (on the left), and wire its output to the left edge of the While (this delays the While until the 1 second-clock ticks). Start the Program, wave your hand, see results, stop the program.
Any questions? [The really hard one is about the Wait -- who uses that one? I'm not sure if it is still true in 2023, but this function was designed for synchronization, and I believe it may behave "better" as a reliable timer than the Wait (ms).]
Bob Schor
04-08-2023 06:19 PM
Thanks very much Bob Schor for your detailed answer. I have written the labview VI according to the instructions as mentioned and have attached it. It seems to work (Great !), but I have two questions :
Why do we need "Wait until next multiple" inside the while loop ? If the "Wait until next multiple outside the while loop delays the loop execution by one second, then what is the need of another one inside the loop ?
Secondly, is there any way of storing these images in a sequence in a folder ? Suppose, we run this VI for 60 seconds, so according to the above VI, the camera should acquire 60 images. I need all these 60 images stored in a sequential number in a folder.
Thanks,
Simrandeep
04-08-2023 09:13 PM
If you read the Help of "Wait on Multiple", you will see it is the the Wait inside the Loop that makes the Loop run at 1 Hz. Remember the Third Law of Data Flow -- you cannot exit a "Structure" (essentially anything on the "Structure" Palette, including Loops, the Event Structure, Case, etc.) until everything inside the Structure runs. "The Race Goes to the Slowest" in Data Flow.
So what's with the (single) Wait until Multiple outside? Unlike the ordinary "Wait (ms)", which says "Wait N milliseconds (from when? that's another problem), Wait until Multiple waits until the 32-bit millisecond timer is a multiple of N. Suppose we only have the "Wait until Multiple" inside the loop, and we specify 1000 ms (so the Loop waits for 1000, 2000, 3000, ... milliseconds (why would it wait for 2000 ms? Well, what if whatever else you do inside the loop took 1001 ms? You'd "miss" the 1000th tick. There's a "fix" for this, too, but we'll get to that much later).
So we enter the While Loop. What is the value of the Millisecond counter when we enter? Who knows? What we do know is if the Millisecond Timer is at 700 when you enter the loop, the "Wait until Multiple" the first time will only be 300 ms, not the 1000 that you wanted. How to fix this? Synchronize on the Wait before you enter.
Here's an experiment you can do (with a stop-watch or simply counting "1, 2, 3, "). Change the little program you wrote to Snap at 1 Hz.
Conclusion -- the Inside "Wait" basically sets the Rate, and the Outside "Wait" serves to synchronize the Waits with the Millisecond Clock.
Bob Schor
04-09-2023 01:59 PM
Thanks so much Bob again for the detailed answer. Yeah, I noticed the effect of putting "Wait until next multiple" separately inside and outside the while loop and now better appreciate the solution.
Simrandeep