Example Code

Robust Color Recognition using IMAQ

Code and Documents

Attachment

Overview

Recently I got quite interested in LabVIEW's IMAQ add-on and using it to do various image processing. I decided to start simple and try color recognition first, however none of the examples I found seemed accurate or robust enough so I decided to give it a go myself. In the end my approach looked relatively resistant to errors and noise. I was able to detect red and blue colors successfully in images and ignore unwanted shades.

colour_1.png

colour_2.png

Description

This example acquires data from a camera device connected to your machine. It then extracts two separate color planes from images grabbed (e.g. Blue and Red) and performs a Logical Diff (NAND) operation on them. This allows to extract only a very specific range of colors that we are interested in. Then a threshold is applied to the 8bit image and it is then cleared from unwanted particles. Once all this is done, the VI extracts remaining particle data and checks whether object of desired size is within camera's field of view. If object of interest is found, a red rectangle is drawn around it.


Steps to Implement or Execute Code

1) Download the vi

2) Make sure you have selected your camera input in the block diagram

3) Select what colour you want to acquire and other relevant settings on the front panel (can also be adjusted while running)
4)
Hit run

5) Try tweaking the settings to improve color detection

6) Press the "Reset Default Settings" button on the front panel to reset controls to their default values (can be changed in the block diagram)


Requirements

Labview 2013
Vision Development Module

NI-IMAQ

NI-IMAQdx


______________________________________________________

Mark N
Applications Engineer
National Instruments UK & Ireland

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

Comments
Jake183
Member
Member
on

hello, i have been having a look at this VI and was wondering if I would be able to change the camera input to that of a Kinect? Would you know how to do such a thing?

wkdlr778
Member
Member
on

wow, thx!!!!! , um..i want multi dection in one colour matching,, what should i do??

shreya111
Member
Member
on

Its really amazing ! Can u pls post vi in LabVIEW 2012 version.

pearli
Member
Member
on

Sir, I'm really impressed about this robust color recognition.In my project I need to recognize red, green and blue color automatically from the image.Also i need to make it efficient. what should i do? should i use color learn and matching. Send me reply as fast as u could. Longing for ur reply. Thank you in advance.

Until now i've tried thisrGB RECOG.PNG

Not applicable
on
pearli
Member
Member
on

Sir, can you post the reply as early as possible.Please.

likantropka
Member
Member
on

Hi i don't know if somebody looks here but if does could somebody convert the file to the labview 14.0 ? Please i will be very thankful

Contributors