From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modify image to note state of pulse train

So here's what I'm trying to do - I have two things going on -

 

1. I'm putting out two continuous digital pulse trains using two counters, and

2. I'm acquiring live video using the Vision Acquisistion Express VI and saving this video to my computer 

 

These are both going on at the same time.  What I'd like to do is put some sort of designation in my images whenver the counters change state so that I know in exactly which image a counter changed from on to off and vice versa.

 

One thought is that maybe I could add a single white pixel in my image whever a counter changes to its on state (maybe one pixel for each counter).  Is something like this possible?  How would it be done?

 

Another thought would be to add a blank frame in my image aquisition whenever a counter is turned on.

 

I'm using a PCI 6010 for the counters and a Prosilica (AVT) GE 655 GigE camera for the imaging at ~90 frames per second.  Below is the code for the two basic things I'm doing - pulse train generation and imaging.

 

Thanks for any help.

 

Combined Image.JPG

 

 

0 Kudos
Message 1 of 6
(2,698 Views)

There are several ways to modify your image, assuming you have the Vision Development Module. In order to change a specific pixel value to white, for example, you can use IMAQ SetPixelValue VI (Functions Palette>>Vision and Motion>>Vision Utilities>>Pixel Manipulation) to do this. You can take a look at the other image processing functions to see other modifications you can make to your image such as overlaying text on it.

 

I hope this helps.

Vivek Nath
National Instruments
Applications Engineer

Machine Vision
0 Kudos
Message 2 of 6
(2,672 Views)

Thanks for your adivce.  I'm now able to successfully set a pixel to a certain value in my images.  The difficult part is to only change this pixel value when my first pulse train is in the 'on' state.  Or even better, to change one pixel value when one pulse train is 'on' and another pixel value when the second pulse train is 'on'.

 

My attempt at changing one pixel value when the first pulse train is on is below.  I connected my counter1 output on my DAQ to an analog input.  I'm using a case structure such that when this analog input is above 1 (ie 'on') the saved images should have pixel (0,0) set to a value of 500.  When the input is below 1 the image is saved without modification.  Unfortunately this doesn't work.  My counters work fine and display on the graph, but neither imaging nor saving function at all.

 

When I remove the case structure around the pixel manipulation code, and remove the >1 comparison, the imaging and saving work, I just get a white pixel in every image.  I'm probably violating some fundamental law with these programming structures, but I just don't know of another way.

 

Any help is appreciated.

Counters with image modification.JPG

0 Kudos
Message 3 of 6
(2,655 Views)

It is not possible to constantly transfer data between two parallel loops using a wire. Currently, you are trying to wire the boolean output of 'great than 1?' to the image acquisition and processing loop. To resolve this issue, you could either:

1) Have both image processing and data acquisition take place in the same loop

2) Use queues or local variables to pass the boolean data between loops

 

I would recommend taking a look at these articles to get an idea of how to work with parallel loops where one is dependent on the other: 

http://zone.ni.com/devzone/cda/tut/p/id/3023

http://digital.ni.com/public.nsf/allkb/DD7DBD9B10E3E537862565BC006CC2E4?OpenDocument

http://digital.ni.com/public.nsf/allkb/4F3CC921B4179F9F86256A3B0045CE2D?OpenDocument

 

 

Vivek Nath
National Instruments
Applications Engineer

Machine Vision
Message 4 of 6
(2,637 Views)

I'm getting closer to achieving what I want, but things aren't working quite right.  I'm using a local variable from a boolean output (greater than 0.1?) to control a case structure that writes the text "ON" if true and "OFF" if false onto each of my images.  The problem is this doesn't work consistently.  For example, using 0.1 second on/off times for the pulses, and recording at 80 frames per second, each label ("ON" or "OFF") should appear for 8 frames and they should be cycling back and forth (ie. 8 frames "ON", 8 frames "OFF", etc).  This works for at most 75% of the pulses.  The other pulses show ON or OFF for <7 or >9 frames (allowing 1 frame of error since imaging is discrete).  Sometimes an ON or OFF designation only lasts for only 4 frames, or may last up to 12 frames.  This would mean it is incorrect by ~50ms.

 

I've tried writing ON in the true state and doing nothing in the false state.  I've tried changing a single pixel rather than writing text.  Neither helped.  I don't think the time it takes to write the text is the problem (it should have 12.5ms to do this).

 

I was orginally saving inidividual bmp files of each image.  Now I'm saving a single AVI file, as I thought this might be faster.  The problem persists.

 

I've measured the voltage at my AI and the pulses are nearly exactly 0.1s, so that's not the problem.  I figure either the image saving is too slow or the local variable passing is too slow.  Should either of these take longer than 12.5ms?  If using a local variable isn't going to work, I'll try the producer/consumer structure.  My code is below; "Counter1 ON?" is the local variable controlling the image manipulation.  Any insights are appreciated.  Thanks.

Code image.JPG 

0 Kudos
Message 5 of 6
(2,604 Views)
There is nothing in the bottom loop that makes it wait for the 'Counter 1' indicator to be updated from the first loop. To avoid race conditions, I would try to incorporate the image acquisition portion and the DAQ Assistant in the same loop. Otherwise, you could try using queues as well.
Vivek Nath
National Instruments
Applications Engineer

Machine Vision
0 Kudos
Message 6 of 6
(2,580 Views)