Webcam Image Processing

Hi there! First post on C++ Forums. :)

I am currently a graduating Computer Engineering student and have a certain idea for our senior project which requires the use of a webcam to implement image processing.

Although I have had experience with C++, our lessons have never touched upon image processing, and it is my intention that our program have a GUI, something I'm not familiar making using C++.

As such, I'd like to ask help one step at a time so we can get started - the first one being, how exactly do I use C++ to process a live streaming webcam image? If you need to know, our projects involves recognizing hand gestures using the webcam and translating these into commands. Although I have seen articles on image processing, I have not successfully found one that uses C++, webcams and image processing at the same time.

Thank you and hoping for some help from anybody :)
Understand first that C++ has no inherent understanding of images (or indeed, monitors, keyboards, a mouse, colours or anything else like that).

Everything involving that has to be done through an interaction with the OS,or coded yourself; for hardware interaction, either directly with the functions provided by that OS, or by using a library that in turn uses those functions. As such, you need a library (at the very least, something that will grab data from your webcam).

The most common library for this sort of thing I see people using is openCV. Alternatively, you could find a simple library that grabs images from a webcam, and conduct your own analysis of those images.
Last edited on
Well, assuming that I use another way to get the images from the webcam, is C++ still not recommended for processing images? If so can you suggest any other way I can accomplish my objective?
is C++ still not recommended for processing images?


I can't think of a good reason not to use C++ to process images. The difficultly is not going to be in grabbing the data, or carrying out mathematical operations on the images. The difficultly is going to be in thinking about the algorithms to write.
I see, well could you give me start then? What to research, or any open source C++ programs, etc.?
Not an expert on the matter by any stretch but just a suggestion; is it worth taking a look at the Kinect SDK?

I know it's not a webcam, but it does rely on image processing and gestures, so might be worth a look at.
Depends how much you want to do it yourself, and how much you want a function along the lines of recogniseHandGesture(inThisImage)

If you're doing it yourself, just get whatever library you need to fetch an image from the camera, get familiar with the data format that image is presented within the C++ program, and start thinking about what mathematical operations you can conduct on the data to find gestures.

It may help to think of the image data as a 2D array of pixels, each one with a single value (i.e. a greyscale image).
I see. Well I did mention earlier that the camera must recognize gestures, which are of course, several frames of video. Will it make a difference if what I want to process is a gesture composed of many frames rather than a still image?
Yes. You'll have to think of a way to examine several frames in turn, and come up with a way to recognise a gesture over several frames. This will be a more complicated algorithm.
I see. So this is gonna be tougher than it seems. I wonder how to start...Suddenly it became a lot less feasible...
Welcome to programming; the art and craft of thinking about problems in a way that lends the solution to being implemented using the (programming) tools at hand. All that other stuff is just memorising syntax and practicing with the hammer :)

Break it down into pieces, and attack each piece. I'd start by doing something like:

1) Grab image data from webcam
2) Present image data in convenient internal format for processing
3) Apply algorithm

One will require a little research and reading of the reference manual. Two will depend on how your chosen image-grabbing method fetches the data. Three will be interesting to develop and fun to apply. To give yourself a start, look up "image segmentation".
Well if you have to use the webcam and image processing then at least you know you're not wasting your time!

Maybe get out a few books on object recognition and think about what you want to do based on that?

EDIT: And if other people are using other technologies than C++ to do this processing, why won't you?
Last edited on
Good news for me, I got word from a friend who has actually made his own image processing program too. :)

Gonna meet him on Tuesday and check his suggestions. Will follow up here anything I don't get. Thanks to all those who replied :) Will take your suggestions too.
Before you jump into trying to solve this incredibly important, but very very difficult task, you may want to look at OpenCV, as Moschops already mentioned, and, more importantly, OpenNI (open natural interfaces), which is a library specifically developed by many people to facilitate natural interfaces, such as gestures. And it's C++.

So it depends on what you really want to do with senior project. If you want to do the recognition from scratch - be ready that it's not likely to even get close to what OpenNI could do (I don't mean it that you're not capable enough - it's just that OpenNI was developed by many people with a lot of experience for a long time...). Other thing you may consider is to study OpenNI, maybe go through their dashboard and see which problems they have. And then solve one of the problems and contribute to OpenNI by doing something new. However, again, that won't be easy at all.

Last thing - you mentioned that you want a GUI. Qt library might be a way to start :)
Check this out guys:

http://ahmedorabi.blogspot.com/2011/05/this-was-computer-vision-research.html?showComment=1340872707305#c1674103149436605481

It's very possible - in fact this guy's program is even better, allowing you to use the mouse and all!

I contacted him and am still waiting for a reply. Meanwhile perhaps some of you guys could understand how this works and explain to me? :)

On another note, I downloaded OpenCV Version 2.4 and CMake, but I can't seem to understand how to put it in Dev C++ (The Original DevC++ integration guide is already obsolete). Any idea how I can integrate OpenCV 2.4 in DevC++? I'm still confused by CMake and all.
Topic archived. No new replies allowed.