Just for fun - skin detection

Another example of what you can do with your FRC robot this year, is track human skin. I coded up a simple example in LabVIEW to detect skin in real time, with reasonable reliability. You can tweak the parameters and white balance to make it work better in your lighting environment. As an added bonus, the algorithm should work regardless race.

SkinDetection.zip (37 KB)

SkinDetection.zip (37 KB)

Good thing. I would hate to think your robot is utilizing racial profiling.:wink:

What’s the red goggle thing it’s picking up on the right of the red image?

best guess is that its confusing the change in light [gray, blue, and red] with a human skin tone.

The algorithm is pretty simple, just checking the red and green channels, normalized by intensity. The code runs quickly enough for processing live video, but is sensitive to lighting changes and prone to some false positives. There are a number of functions which could be used to reduce or remove noise and false positives, the posted code however just outputs anything falling into the correct color range.

We decided just detecting skin wasn’t good enough, and decided to use the information for where people were to modify the original image by tinkering with the Hue, Saturation and Luminance. We also added an erode and dilate function to remove some of the random noise.

For those of you who want to put a face to the names you see in the forums, that’s myself, Greg McKaskle and Christy Dellas (left to right) in the sample image. :slight_smile:

SkinDetectionModified.zip (51.6 KB)

SkinDetectionModified.zip (51.6 KB)

Hi, I’m just new in this forum and in the world of robotics and labVIEW programs. I need to implement a program in LabVIEW that recognizes the movement of a hand using an usb camera for my final project career. I’ve downloaded your vi to the skin detection, but when I try to run it, it doesn’t find “Camera.lvlib:Close.vi” and others similar elements. Where can I find the “Robotics Library” or the library I need to use your program?

Please, excuse my English and thank you very much.

The libraries you are looking for are part of the FIRST robotics installation. The example used the camera support from that library.

If you already have LV, you can replace a few elements and do this without the FIRST library. Do you have a camera? What driver or VIs were you planning to use to get images from the camera? If you can get images, then you can replace the Open, Get, and Close with your camera specific VIs.

Greg McKaskle

I swear this is how Terminator FRC addition will start.

Ike, don’t give the theaters new ideas for bad sequels. Also, don’t give my subconscious ideas for bad nightmares, being chased down by 67 scares me… :eek:

Very nifty stuff, this does show off the power of the system we now have access to. Thank you for sharing.

Now, what are the chances of getting OpenCV ported to the Crio? Then our robots could autonomously track down and pummel assorted people with balls for not wearing safety glasses.

Now, what are the chances of getting OpenCV ported to the Crio? Then our robots could autonomously track down and pummel assorted people with balls for not wearing safety glasses.

I think some teams already managed that by accident. I saw in a thread (can’t remember which one) where people walked by the camera with shirts the same color as the vision target 2 years ago. Not a good idea if you don’t like poof balls. The CRIO does run a Linux kernel. If OpenCV will run on a Linux kernel, then it can probably be ported. Not my area of expertese, though.

I’m curious what it is you want out of OpenCV? To my knowledge, it hasn’t been ported to the PPC/VxWorks combo. If you find things in OpenCV that isn’t in NIVision, please bring it up.

Greg McKaskle

Hello again,

I’ve replaced the VIs I haven’t with my camera specific VIs, but I still haven’t got some of the VIs you use: Set image compression.vi Set Exposure Priority.vi and Set White Balance.vi. I’ve omitted them and I can run the program, it captures the original image but the second display is always black. What VIs are essential? And what does Set White Balance. vi do exactly? I’m quite lost…


Those VIs are simply setting acquisition properties on the camera. The Set White Balance takes in an enumeration to define the lights as fluorescent, indoor, outdoor, etc. This will help in producing more true colors, but clearly isn’t available on all cameras or necessary as long as your colors don’t look odd. The VIs are built upon the HTTP requests to the camera http server to change the parameters.

If you have the first image working, you may need to tweak the G and R limits. Thomas would be more knowledgable for how to set them. You may also be able to find the paper discussing the algorithm. Note that on the two images, Thomas tweaked the values to adjust for the lighting in the room.

Good luck.

Greg McKaskle

Thank you all for your comment. It was fun to do. And for Zesty, yeah, it takes some time, depending on the shot and your skills with photoshop. In general 20-30 min for a shot I guess.