Difference between revisions of "ECE597 Project Interactive Pong"
(→Code) |
(→Code) |
||
| Line 15: | Line 15: | ||
==Code== | ==Code== | ||
OpenCV | OpenCV | ||
| + | |||
| + | /*Get the color of the hand, so that we can track the movement of the hand automatically.*/ | ||
| + | void loadTemplateImage() | ||
| + | { | ||
| + | IplImage *tempimage = cvLoadImage("/home/dica/workspace/cvex1/sshou.bmp",1); | ||
| + | cvCvtColor( tempimage, hsv, CV_BGR2HSV ); | ||
| + | int _vmin = vmin, _vmax = vmax; | ||
| + | |||
| + | cvInRangeS( hsv, cvScalar(0,smin,MIN(_vmin,_vmax),0), | ||
| + | cvScalar(180,256,MAX(_vmin,_vmax),0), mask ); | ||
| + | |||
| + | cvSplit( hsv, hue, 0, 0, 0 ); | ||
| + | |||
| + | selection.x = 1; | ||
| + | selection.y = 1; | ||
| + | selection.width = 320-1; | ||
| + | selection.height= 240-1; | ||
| + | |||
| + | cvSetImageROI( hue, selection ); | ||
| + | cvSetImageROI( mask, selection ); | ||
| + | cvCalcHist( &hue, hist, 0, mask ); | ||
| + | |||
| + | float max_val = 0.f; | ||
| + | |||
| + | cvGetMinMaxHistValue( hist, 0, &max_val, 0, 0 ); | ||
| + | cvConvertScale( hist->bins, hist->bins, max_val ? 255. / max_val : 0., 0 ); | ||
| + | cvResetImageROI( hue ); | ||
| + | cvResetImageROI( mask ); | ||
| + | track_window = selection; | ||
| + | track_object = 1; | ||
| + | |||
| + | |||
| + | cvZero( histimg ); | ||
| + | int bin_w = histimg->width / hdims; | ||
| + | for(int i = 0; i < hdims; i++ ) | ||
| + | { | ||
| + | int val = cvRound( cvGetReal1D(hist->bins,i)*histimg->height/255 ); | ||
| + | CvScalar color = hsv2rgb(i*180.f/hdims); | ||
| + | cvRectangle( histimg, cvPoint(i*bin_w,histimg->height), | ||
| + | cvPoint((i+1)*bin_w,histimg->height - val), | ||
| + | color, -1, 8, 0 ); | ||
| + | } | ||
| + | |||
| + | cvReleaseImage(&tempimage); | ||
| + | |||
| + | } | ||
==Task List== | ==Task List== | ||
Revision as of 01:36, 21 May 2010
This project is part of the ECE597 32-bit Embedded Linux class at Rose-Hulman Institute of Technology in Terre Haute, IN.
Contents |
Project Goal
The goal of this project is to implement a simple game of "Pong" on the Beagle Board that allows a user to play the game by gesturing with their hands rather than using a mouse or keyboard.
Team Members
Elliot Simon
Mitch Garvin
Matt Luke
Jian Li
Code
OpenCV
/*Get the color of the hand, so that we can track the movement of the hand automatically.*/ void loadTemplateImage() { IplImage *tempimage = cvLoadImage("/home/dica/workspace/cvex1/sshou.bmp",1); cvCvtColor( tempimage, hsv, CV_BGR2HSV ); int _vmin = vmin, _vmax = vmax;
cvInRangeS( hsv, cvScalar(0,smin,MIN(_vmin,_vmax),0), cvScalar(180,256,MAX(_vmin,_vmax),0), mask );
cvSplit( hsv, hue, 0, 0, 0 );
selection.x = 1; selection.y = 1; selection.width = 320-1; selection.height= 240-1;
cvSetImageROI( hue, selection ); cvSetImageROI( mask, selection ); cvCalcHist( &hue, hist, 0, mask );
float max_val = 0.f;
cvGetMinMaxHistValue( hist, 0, &max_val, 0, 0 ); cvConvertScale( hist->bins, hist->bins, max_val ? 255. / max_val : 0., 0 ); cvResetImageROI( hue ); cvResetImageROI( mask ); track_window = selection; track_object = 1;
cvZero( histimg );
int bin_w = histimg->width / hdims;
for(int i = 0; i < hdims; i++ )
{
int val = cvRound( cvGetReal1D(hist->bins,i)*histimg->height/255 );
CvScalar color = hsv2rgb(i*180.f/hdims);
cvRectangle( histimg, cvPoint(i*bin_w,histimg->height),
cvPoint((i+1)*bin_w,histimg->height - val),
color, -1, 8, 0 );
}
cvReleaseImage(&tempimage);
}
Task List
Below is an estimated list of tasks to complete Task list will be updated as necessary
| Task | Status | Description |
|---|---|---|
| Pong on the Beagle Board | Complete | Port a simple game of classic pong onto the Beagle Board with keyboard/mouse input |
| Webcam interface with the Beagle Board and OpenCV | Complete | Get the Beagle Board to recognize the webcam and perform basic functionalities from OpenCV (connect to camera, snapshot, etc.) |
| Refactor Pong | Complete | Refactor Pong to work with a different input (camera) |
| Track hands with camera and OpenCV | Complete | Track user's hands using OpenCV library functions on the Beagle Board |
| Interface tracking camera with pong | Complete | Join the tracking and game into one system such that users can play pong with their hands |