01-01-2016 09:42 PM - last edited on 01-04-2016 10:26 AM by LiliMcDonald
Hello everyone, I am just starting to use lab view to control a camera to performing data analysis. I have a Monochrome USB3.0 Camera to obtain Image with type Grayscale (U8).But it seems IMAQdx Grab VI always get image data in type of RGB(U32) which could be used by Image analysis vi like IMAQ Centroid VI only after converting it to image type U8 or U16.
Is there any chance that IMAQdx Grab VI could obtain image in type of Grayscale (U8)? That will same me lots of time with type converting.
01-04-2016 10:14 AM - last edited on 01-04-2016 10:26 AM by LiliMcDonald
What's your settings in NI-MAX ?
What's your buffer image type ?
01-04-2016 10:17 AM - last edited on 01-04-2016 10:26 AM by LiliMcDonald
Have you looked at the Vision functions? Surely there is one that can convert an RGB image to an I16 or U8 GrayScale image ...
Bob Schor
01-09-2016 08:08 PM
This is the code I used, it will work after using Cast Image VI. As the image I want analyzed with the size of 3856 x 2764 that will slow down the sampling rate.
01-09-2016 09:13 PM
I'm glad you are satisfied with your code, and no longer need our help. [I'm deducing this from the fact that (a) you refused to attach your code, but only showed us a picture (non-executable) of part of your code) and (b) you didn't ask any question.
Bob Schor
01-09-2016 09:22 PM
I am not satisfied with my code, If there is a way that Grab VI could generate a Grayscale U8 image I like to know?
01-10-2016 12:05 PM
Thank you. Now I can see what you are doing. I notice that you use the Enumerate Video Modes function, but don't look at its outputs, which is probably just as well, as setting Camera Attributes in IMAQdx is not particularly User-Friendly. Can you look at the array output by Enumerate Video Modes and find one that is more suitable than the default you are now using?
You can also examine, and set, the Video Attributes of your Camera in MAX. One of my Cameras has a Color or Mono Attribute, along with variable Image Size -- might yours?
Bob Schor
01-11-2016 02:24 AM
01-11-2016 10:19 PM
Well, my assumption that you could "turn down" the image coming from the camera. I'd used MAX to look at one of my AXIS cameras, saw that it had a "JPEG Mono" mode, so I figured I could choose this mode when I configured IMAQdx and decrease the image size from a U32 RGB to a U8 Grey.
Wrong! First, there seemed to be no Property Node (nor Camera Configuration) that would set the mode to give me an 8-bit Image. I could manually set the camera to send no color information, getting a B&W image on my camera, but still getting a U32 image. However, the IMAQ Cast Image function should be very quick in getting the image size converted to a U8 Grayscale.
So let's go back to your VI. In your While loop, you (a) acquire an Image, (b) display it, and (c) "process the pixels" (do some computations on the pixel values). All three of these events occur in sequence, so the loop time is the sum of the times for all three steps. However, because the Camera runs on a "frame-rate" clock, this time, ideally, should be less than 1/Frame Rate so as not to miss any frames.
One way to speed up the loop process is to adopt a Producer/Consumer Design -- as the Images come in, put them on a Queue and pass them to a Consumer loop for display and image processing. This will allow Image Acquisition (which takes camera time) and Image Processing (which takes PC time) to largely occur in parallel, clocked not by the sum of their respective speeds, but by the slower of their individual speeds. Indeed, if you don't need to view every frame, you can drop the occasional Display to speed up the Consumer loop.
Give that a try, and see if this gets the speed of your Image Acquisition and Processing up to acceptable levels. I'm guessing that it will.
Bob Schor
01-14-2016 05:53 AM
Thank you, I will try it to optimize my code.