From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Googly Eyes (Powered by LabVIEW)

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Vision Development Module
  • LabVIEW

Code and Documents

Attachment

Description

 

 

 

One fateful morning, I was pursuing the awesome LabVIEW example finder (Help >> Find Examples). I spotted an interesting application called “Optical Flow Feature Tracking Example.vi” which is installed with the LabVIEW Vision Development Module

LabVIEW Example.JPG

 

This example loads some high-speed video footage of an exploding firework, and tracks the movement of certain burning embers/particles between frames in the footage.

 

Wow! That looks seriously complex... or so I thought!

 

At the heart of the application was a pre-built function called IMAQ Optical Flow (LKP), which is included with the LabVIEW Vision Development Module. The rest of the code was architectural... *this* function represented the real “brains behind the operation”.

 

IMAQ Optical Flow (LKP).JPG

 

The IMAQ Optical Flow (LKP) function allows you to track the movement (flow) of certain features between frames in full motion video footage.

 

I was inspired! I decided to start developing my own example code that would work with live video footage, rather than a pre-recorded .avi. The attached project includes 3 different applications, each representing a different evolution of my own optical flow application.

 

 

1 Optical Motion (with velocity plot).vi

I gutted the example application, and added IMAQdx functions to pull live video feeds from my webcam. I also displayed the number of pixels a user-selected feature moves between frames (a direct representation of the speed that the feature is moving). I also added a new overlay that plots a vector to describe the velocity (speed & trajectory) of the moving feature.

 

To test drive the application, I drew a single dot on a piece of paper.

 

1 (single feature).jpg

 

But the application had been written in such a way that it can simultaneously track any number of features.

 

1 (Multiple feature).jpg

 

I also decided to test drive the optical flow tracking on busier, more complex images. This worked brilliantly – illustrating how robust that IMAQ Optical Flow (LKP) function really is!!

 

1 (comlex image).jpg

  

 

2 Optical Motion (Overlay Eyes).vi

Following the success of the first iteration of the code, I decided to have some fun. This time I implemented features that allow you to add “Googly Eyes” to an object within the image frame. Far from being static, the Googly Eyes will actually stare at a user-controlled feature on the image (identified by a red crosshair).

 

2 (Rich Eyes 1).JPG

 

Here is another image to prove that the object tracking is dynamic! No smoke and mirrors here

 

2 (Rich Eyes 2).JPG

 

Ofcourse, the scalable application architecture means that you can place eyes onto any number of people stood infront of the camera, and the algorithm will happily track the optical flow of multiple points – whilst ensuring that all eyes stare at the feature point!

 

2 (Multiple People).JPG

 

And, it doesn’t just work on humans! The beauty of Googly Eyes is that they can be used to personify anything! Thereby enabling you to add a little charm and personality to just about any object...

 

2 (Personification).JPG

 

 

 

3 Optical Motion (Looking For Geometry).vi

The final iteration of the application replaces the static feature point with a dynamic Geometry Match. I added the pre-built Geometry Matching Algorithms (that ship with the Vision Development Module) to the application. The code can be trained to search for any type of Geometry, by my example code looks for the following shape.

 

3 (the pattern of interest).JPG

 

Each and every eye applied to you video feed will look directly at the detected geometry...

Your head moves = the pupils move!

The geometry moves = the pupils move!

 

3 (eye tracking).JPG

 

 

And, ofcourse, if you ever wanted to make yourself look like the Legendary Black Beast of Aaaaarrrrrrggghhh (from Monty Python and the Holy Grail), then this is the app for you!

 

3 (Beast of Arrrgh).JPG

 

 To run this application on your own machine; you will need a copy of LabVIEW 2012, the Vision Development Module 2012 and the Vision Acquisition Software  2012.08 (or above)

 

You will also need a camera. You can use any direct-show compliant USB webcam, Firewire (IEEE 1394) camera or GIGE camera.

 

Important: I wrote the code for a colour camera...

if you are using a monochrome/greyscale camera, please remove

the “IMAQ Extract Single Color Plane” function from the block diagram!

NOTE GreyScale.JPG

 

Embrace the Silliness!

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
RIObotics
Member
Member
on

Great stuff!  One more reason to upgrade!

Alex.T
Active Participant
Active Participant
on

Rich that's such a cool example! How did you create the effect at the very end of the video where you wipe all of the eyes away?

Also, are the Googly Eyes ripped out of Teasing Homer Simpson?


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

Julien_De_Freitas
NI Employee (retired)
on

Great example

I have tried every example. But I am in trouble with the last one. I do not know how to set the option parameter for the IMAQ Optical Flow VI for my set camera. I have an error as an ouput of this VI because of the size.

Any ideas?

Thanks for your help!

Julien De Freitas

Applications Engineering Group Leader / Certified LabVIEW Developer (CLD)
National Instruments Switzerland
Kvanto
Member
Member
on

Who can save attachment Optical Flow.zip in early version, e.g. LabVIEW 2010?

abdelhady
Member
Member
on

I use tis program to track some cell , but when the cell go out of region of interest the programm stopped and the programm freeze

how can I overcome this proplem

ElmoSA
Member
Member
on

Hi, great stuff; could you please save it in LV2011?

VineetA
Member
Member
on

amazing, thanks

bmvalarezo1
Member
Member
on

Hi, maybe for Labview 2010?

achraf94ih
Member
Member
on

Please i have labview 2011 and i can t open this files, can someone show me just the screenshoots.

or the programme on labview 2011

 my email: achraaf.benseddik@gmail.com

Contributors