LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Vision acquisition - resolution problem

Hi, I've got a problem with my project with the vision acquisition block. When i configure my camera in this block I can change the resolution etc. But when I'm starting a program, the resolution is set to the maximum possible. I need 30fps with low resolution. In labview examples "grab and attributes" or similar I can change the resolution and it works with this camera, but the problem is with vision acquisition, that don't change that. 

I need to connect the Image out to "extract single color plane" and then to the vision assistant to use some filters. I've tried to copy examples where I can change resolution like in "grab and attributes" but it doesn't work with block "extract single color plane" and vision assistant.

I tried to create a virtual camera in OBS to lower the resolution, but in NI Max and in LabView I can't use it. Timeout Error 0xBFF6901B pops.

Is there any way to fix vision acquisition or use other blocks that work similarly to that? I need an image out from my camera.

Screenshots in attachments

I am a newbie so please explain it to me like to newbie 😛

Thank you!

0 Kudos
Message 1 of 29
(786 Views)

open the vision acquisition's front panel, copy the IMAQ initialize, set attribute, snap functions into your main VI and use it from there instead

CY (expired CLAD)
0 Kudos
Message 2 of 29
(738 Views)

We cannot "execute a picture" (well, we could pin it up on a wall and shoot at it, I suppose).

 

Write a small VI that tries to take an image and, say, display it in a Vision "Window" (similar to what MAX does when you do a Grab or a Snap).  Do a "Save for Previous Version" and specify LabVIEW 2019 or 2021 (both so I can run it and so other "old-timers" (or "experienced LabVIEW users") can try it out.  I can almost guarantee we'll be able to make it work at 30 fps and "low resolution" (tell us what resolution you'd like).

 

I'd probably try this with the Web Cam that's part of my Dell Laptop.  I could write such a program now, but would rather see your code first, so that I can "explain" (= "teach") the changes I made and why they are needed.

 

Bob Schor

Message 3 of 29
(728 Views)

Thanks for respond.

So, in my attachment named "first" I used example named "grab and select video mode" and i used blocks for pattern maching like extract single color plane and match pattern etc. and it worked, I can change resolution, its okay. But when i copy it to my school project, that have to use fans and calculate height with PID, my camera is working on like 2 FPS in resolution 640x360 px.  Attachements "part1" and "part2" show how i put it together. Problem with FPS is from too many blocks? or it is from other issue?

Download All
0 Kudos
Message 4 of 29
(677 Views)

I can't help you if all you send me are pictures of code.  I can't "edit" pictures, I can't "run" pictures, etc.

 

Please attach a complete VI that you think does what you want (it is OK if it doesn't work).  It should be saved as a 32-bit LabVIEW 2021 VI (I can also handle LabVIEW 2019).  Please also tell me what you want it to do.  I assume that, at one level, you want to acquire 640 x 480 color images at 30 FPS using IMAQdx.  Is there more to it than that?  If you want to add supporting routines, create a LabVIEW Project that has all the required VIs and TypeDefs (again, saved as 32-bit LabVIEW 2021), then compress the Project Folder (by right-clicking the Folder, choosing "Send To:", "Compressed (zipped) folder" and attach the resulting .zip file.

 

Bob Schor

0 Kudos
Message 5 of 29
(662 Views)

There is a problem 😕 In school we're using a LabView 2015, we only have that license. I don't know if You can open it... I'm gonna send it to you, maybe you know how to open it. 

 

So, the program is working fine, when i connect older camera it has like 15 FPS, but the delays are a little bit too much. So i connected newer camera, and I'm lowering the resolution, but when i'm opening resolution 640x360 etc. with 30FPS it works on like 2FPS? Program is slowing down much more on my newer webcam... 

Thank you for your help!

0 Kudos
Message 6 of 29
(652 Views)

Hello RiffLord,

 

have you tried experimenting with the camera settings in NI MAX, to see what works (and what the limits are to some Camera Attributes)?

 

From what I can see from your VI, you don't have a separate loop for camera streaming. Instead all sorts of processing takes place, which slows down the grab rate (fps).

I'd suggest to use a dedicated loop for grabbing images and another loop for processing them.

 

However, since you've indicated you're a 'newbie', this may take a bit of study to make it work.

 

0 Kudos
Message 7 of 29
(642 Views)

you can get the required low level functions (including the camera attributes) if you have previously configured using the vision acquisition assistant, simply by opening the assistant's front panel and copy them out

CY (expired CLAD)
0 Kudos
Message 8 of 29
(634 Views)

The suggestions of @matys and @cy are excellent.  In particular, @matys seems to correctly identify the source of the "slowness", namely you have forgotten the Laws of Data Flow, one of which is that a While Loop does not "loop" until everything inside it finishes.  So if in a single While loop you (a) acquire an image, (b) process that image, (c) have a completely-unnecessary "Wait until next ms multiple" function, and (d) do lots of "image processing" and Image "displaying", with all of those times adding because they are all "connected serially by wires", you are lucky to be able to run at 2 Hz!

 

Here's (more-or-less) what you want to do:

  • Before a While Loop, get the Camera completely set up, ready to Grab at 640 x 480 MJPG 30 FPS.
  • When you are ready to start recording, IMAQ Start Acquisition and enter the While Loop.
  • Inside the While Loop, do a Grab.  The first time into the loop, this will take 1/30 of a second, or 33.333 milliseconds, and you'll have your Image.  Get rid of the Image in one of several ways (you can immediately place it on a Queue and "export" it to a "Consumer Loop" (this While Loop being the "Producer" of a "Producer/Consumer Design Pattern") where you can do further processing.  Doing this will take maybe a microsecond, so you'll have plenty of time to finish the While and do the next iteration to get the next frame (which means you'll be "waiting" for 33.332 milliseconds).
  • So now you have to "consume" (or "process" the Image, arriving 30 times/second.  If you don't have enough time to do it in "real time", spool the images to disk (you can certainly write an AVI file at 30 FPS) and process it off-line.

There's another way to do this, but this is definitely "advanced vision" work.  The Camera has a buffer, a place in PC memory where the camera saves the pixels that it is acquiring for you.  You can configure the number of buffers of PC memory you want, which lets you "look back in time" and start saving images that occur before a Trigger signal.  

 

Fortunately for me, I was already an experienced LabVIEW programmer when a colleague asked me for help with LabVIEW Vision (which I'd never used).  The two of us, working together, finally figured it out, but it took several weeks of hard work.  I strongly suggest you use the Producer/Consumer pattern I described above, and pass your Images to a Consumer loop for further processing.

 

Bob Schor

 

 

0 Kudos
Message 9 of 29
(616 Views)

Hi!

I have tried experimenting in NI MAX and the camera works fine, no lags, no delays... The only problem is when I'm using vision acquisition and it doesn't save resolution. I tried using normal blocks from IMAQdx and without my full program it works too, but when I'm using it in my full program camera slows down, have like 2-3FPS, but the resolution is changing so that's progress 😛

Do you mean to use a separate loop for camera streaming with filters and pattern matching? And it can be done in the same VI? or do I need to do it in a separate VI? Any tips how to separate it in different loops?

Thanks for responding!

0 Kudos
Message 10 of 29
(595 Views)