Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Running average or median of images from Gige vision camera


@MoviJOHN wrote:

Your shift register in not initialized.  This would be like 1+NaN=NaN.

 

Two choices:

1.  Put a First Run? Case that simply passes the first image into the shift register without adding (or check for Loop "i"=0

2. Initialize the array on the outside, and make sure to define the correct size dimensions.


Hi,

 

I did initialize the array but still its not working.

 

I have Gige vision camera, and require to get the running median/average.(average of about 5-10 frames per sec).

 

 

0 Kudos
Message 11 of 15
(2,699 Views)

Simplify your code.  Lets walk before we run, shall we?

 

First, create an Image, call it "U8Grab", and make it U8. Create another image called "CASTGRABTOSGL". Create a second U8 called "U8Result", and a SGL called "SGLRESULT".  Each time you cast, or convert from array to image data, you should be using one of these references.  If you find you need to use them more than once in a single itteration, then you probably need to create another image.

PUT ALL CREATE IMAGE vis OUTSIDE your loops. Don't call them over and over in the loop, because this is probably not helping. Just bring the reference wire into the loops.

Use only these top level vis for capturing from the camera (for now): [outside]CameraOpen, ConfigureGrab[/outside], [inside]Grab, or SNAP[/inside], [outside]CameraClose[/outside].  Use the high level vis, not low level.

Machine Vision, Robotics, Embedded Systems, Surveillance

www.movimed.com - Custom Imaging Solutions
0 Kudos
Message 12 of 15
(2,696 Views)

@MoviJOHN wrote:

Simplify your code.  Lets walk before we run, shall we?

 

First, create an Image, call it "U8Grab", and make it U8. Create another image called "CASTGRABTOSGL". Create a second U8 called "U8Result", and a SGL called "SGLRESULT".  Each time you cast, or convert from array to image data, you should be using one of these references.  If you find you need to use them more than once in a single itteration, then you probably need to create another image.

PUT ALL CREATE IMAGE vis OUTSIDE your loops. Don't call them over and over in the loop, because this is probably not helping. Just bring the reference wire into the loops.

Use only these top level vis for capturing from the camera (for now): [outside]CameraOpen, ConfigureGrab[/outside], [inside]Grab, or SNAP[/inside], [outside]CameraClose[/outside].  Use the high level vis, not low level.


I did put all the create out side the loop, but still not getting the averaged image, I can see the unprocessed image.

 

I do have to use low level vi's as I think those are faster .

 

I need to get average and medians of images.

 

0 Kudos
Message 13 of 15
(2,689 Views)

Ok so some how I was able to run the program and get the image in the display , how can I modify this program to run faster and take median of the images.

I require to get a running  median of the frames with faster frame rate more then 6-7 fps.

right now if i change the for loop iteration it goes very slow then

0 Kudos
Message 14 of 15
(2,686 Views)

Well, for that, you need to implement a moving average, with a user defined window.

 

At a very high level, it would work like this:

 

Define WINDOW_SIZE to be 10 (image frames)

Begin acquiring images

Once the window contains 10 images, you can display the Moving Average.  THis is very inefficient, since you always need 10 peices of information for your calculation.

 

Ideally, you want only three pieces of information: Previous Image Mean, Current Image, and Window Size

 

(CurrIMG + (PrevIMG x (WinSz - 1))) / WinSz = Moving Average

Machine Vision, Robotics, Embedded Systems, Surveillance

www.movimed.com - Custom Imaging Solutions
0 Kudos
Message 15 of 15
(2,678 Views)