Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Real-time scaling of images

Hi!
I have an image acquisition device. I have as of yet not installed any NI vision softwares e.g image acquisition hardware, NI-IMAQ...
 
I just want to do a simple task here.
 
I have a camera that streams images of resolution 640x480. I wanted to know if there is a way of scaling down the image to 320x240 with the 'image acquisition' hardware device or any NI software apart from getting a camera with a resolution of 320x240.
 
If I can do with the hardware how can i do it? If it is a software then which one can do for me.
Thank you so much.
0 Kudos
Message 1 of 13
(5,719 Views)

Some cameras or hardware have the ability to reduce the resolution of the image.  This can be called binning or scaling usually.  The factors are usually 1/2, 1/4, etc.

If your hardware won't do it, you can do it pretty easily using the NI Vision module.  Use IMAQ Extract and set the X and Y step to 2.  This will reduce the resolution to 320x240.

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 13
(5,710 Views)

Thanks for your quick and much awaited reply! Is there a way to call a function using the NI Vision Library to do the 'scaling down'? I am using Visual Studio C++/C# as my development tool.

Thanks so much.

0 Kudos
Message 3 of 13
(5,704 Views)

You can do it from C, but I don't know the function names.  You would have to read through the Vision manual to find them.

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 4 of 13
(5,700 Views)

Thank you again. I tried to search for the manual but the best i got is the 'NI Vision Concepts Manual'. Is there a more thorough manual that describes the functions/gives code examples. If there is one! I would appreciate a link to itSmiley Happy

Thanks...

0 Kudos
Message 5 of 13
(5,693 Views)
Search for Vision CVI User Manual.
 
Bruce


Message Edited by Bruce Ammons on 08-04-2008 06:49 PM
Bruce Ammons
Ammons Engineering
0 Kudos
Message 6 of 13
(5,686 Views)

Hi!

I wanted to get more details about how to use imaqResample() with regards to the problem below:

I have a camera that streams images of resolution 640x480. I wanted to know if there is a way of scaling down the image to 320x240. How do I use this function or another to do this.

Thank you so much.

0 Kudos
Message 7 of 13
(5,650 Views)
kbv2842 -

If you have an image of size 640x480, to scale it down to 320x240 use the following call:

imaqScale(image, image, 2, 2, IMAQ_SCALE_SMALLER, IMAQ_NO_RECT);

You can also use imaqResample(), but the documentation suggests imaqScale() will be faster for zero-order scaling.

Greg Stoll
Vision R&D
National Instruments
Greg Stoll
LabVIEW R&D
Message 8 of 13
(5,632 Views)

I saw imaqScale. But the problem is that the first 2 parameters require an image type and not an array. I am using the 'HL Grab' project provided by NI which uses an array:

static

char *ImaqBuffer=NULL;// acquisiton buffer

static

IplImage *image = 0;

// Let NI-IMAQ manage the memory

ImaqBuffer = NULL;

imgGrab(Sid, (

void **)&ImaqBuffer, TRUE);

_size.height = AcqWinHeight;

_size.width = AcqWinWidth;

image = cvCreateImage( _size, IPL_DEPTH_8U, 4 );

image->imageData = ImaqBuffer;

So, I need to first convert this into an image type and then pass the image to be scaled. Can you show me how i can do this? Thank you so much.



Message Edited by kbv2842 on 08-07-2008 11:19 PM

Message Edited by kbv2842 on 08-07-2008 11:22 PM
0 Kudos
Message 9 of 13
(5,616 Views)
Hi,
I use VB.NET as my IDE. you may see this example
 
CWIMAQVision1.Extract2 CWIMAQViewer1.Image, CWIMAQViewer2.Image,, 2, 2
 
Interpretation
CWIAMQViewer1.image is your image, CWIMAQViewer2.image is the down sampled image (by factor of 2 in both X and Y). so all what you need to do is to is:
  • Grab the image and display it on CWIMAQViewer1 (that's the important step)
  • Implement that line of code
  • and you shall get the result on CWIMAQViewer2 control.

I'm not an expert in C++, but to implement that in C#, just place sermi colon (;) to terminate the command Smiley Very Happy

does this help?

Waleed El-Badry MSc.,MCPD, ISTQB Certified Tester
Assistant Lecturer
Mechatronics Department
Faculty of Engineering
Misr University for Science & Technology



View Waleed El-Badry's profile on LinkedIn

0 Kudos
Message 10 of 13
(5,606 Views)