Click here to Skip to main content
Click here to Skip to main content
Go to top

Vision on Virtual Commands

, 20 Jun 2011
Rate this:
Please Sign up or sign in to vote.
This application is used to show how Computer interacts with human and converts his/her motion in command actions. It detects motion and converts that motion into respective command actions.
Sample Image - maximum width is 600 pixels

Sample Image - maximum width is 600 pixels

Introduction

This application is used to show how a computer interacts with a human and converts his/her motion in command actions. It detects motion and converts that motion into the respective command actions.

Background

To detect motion, it uses a simple algorithm of subtracting two images. Every image is made up of three layers: red, blue, and green. Thus, each of the pixels in an image holds three values corresponding to its RGB.

Using the Code

The above code snippet shows that it is easy to get a matrix of form byte[,] from a bitmap image. Once you have two of such matrices from consecutive web-cam frames, you could subtract them to find the matrix that shows the motion in each of the pixels.

public ImageMatrix(Bitmap image)		//constructor
{
    this.width = image.Width;
    this.height = image.Height;

    byte[,] function = new byte[width, height];
    //define bounds of function

    //unsafe bitmap to iterate through the image
    unSafeBitmap usb = new unSafeBitmap(image);
    usb.LockImage();

    for (int i = 0; i < width; i++)
    {
        for (int j = 0; j < height; j++)
        {
            /* Reading average (gray scale) 
               value for each of the pixel
             * and storing it in function*/
            this.function[i, j] = usb.GetAverage(i, j);
        }
    }
}

In the sample program I've provided with this article, there are five buttons:

H
E
L
L
O

You can also easily modify the code to control whatever you wish, or you could even add more virtual buttons! If you have questions about the program's functioning, then leave your comments here.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Saket Vyas
Software Developer ratcloud
India India
No Biography provided
Follow on   Twitter   Google+

Comments and Discussions

 
GeneralMy vote of 2 PinmemberJohn Korondy14-Sep-13 6:06 
GeneralMy vote of 1 PinmemberPaul Boothroyd28-Jun-11 6:18 
GeneralMy vote of 1 PinmemberChantiPDM28-Jun-11 5:01 
GeneralMy vote of 2 PinmemberR. Hoffmann28-Jun-11 4:34 
GeneralMy vote of 1 Pinmembersnortle20-Jun-11 10:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 20 Jun 2011
Article Copyright 2011 by Saket Vyas
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid