ImageVerifierCode 换一换
格式:DOCX , 页数:11 ,大小:17.72KB ,
资源ID:3836443      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3836443.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(opencv手势识别.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

opencv手势识别.docx

1、opencv手势识别#ifdef _CH_#define WIN32#error The file needs cvaux, which is not wrapped yet. Sorry#endif#ifndef _EiC#include cv.h#include cxcore.h#include cvaux.h#include highgui.h#include #include #include #include #include #include #include #include #include #endifstatic CvMemStorage* storage;/static

2、double color;static CvSize imgSize;static CvSize tmplSize;static CvSeq* contour;static CvSeq* biggest;static CvCapture* capture = 0;static int isHandOpen = 1;/static double color;static CvScalar color;static IplImage *img;static IplImage *tmpImg;static IplImage *conv;static IplImage *H;static IplIma

3、ge *S;static IplImage *V;static IplImage *tmpH1;static IplImage *tmpS1;static IplImage *tmpH2;static IplImage *tmpS2;static IplImage *tmpH3;static IplImage *tmpS3;static IplImage *openHandTmpl, *closedHandTmpl;static IplImage *openGrayHandTmpl, *closedGrayHandTmpl;static IplImage *openscaledTmpl, *c

4、losedscaledTmpl;static IplImage *openMatchResult, *closedMatchResult;FILE *output;void handDetect( IplImage *img);static int numImg = 10;char *names = ./images/test01.jpg, ./images/test02.jpg, ./images/test03.jpg, ./images/test04.jpg, ./images/test05.jpg, ./images/test06.jpg, ./images/test07.jpg, ./

5、images/test08.jpg, ./images/test09.jpg, ./images/test10.jpg;char *resultsiamge = result01.jpg,result02.jpg,result03.jpg,result04.jpg,result05.jpg,result06.jpg,result07.jpg,result08.jpg,result09.jpg,result10.jpg;int main( int argc, char* argv ) int i = 0; char filename80; storage = cvCreateMemStorage

6、(0); #ifdef DEBUG cvNamedWindow( Template1, 1 ); cvNamedWindow( Template2, 1 ); cvNamedWindow( Comp Results1, 1 ); cvNamedWindow( Comp Results2, 1 ); cvNamedWindow( Skin Detection, 1 );#endif openHandTmpl = cvLoadImage(openHandTmpl.jpg,1); closedHandTmpl = cvLoadImage(closedHandTmpl.jpg,1); / Conver

7、t form RGB to GRAY tmplSize.width = openHandTmpl-width; tmplSize.height = openHandTmpl-height; openGrayHandTmpl = cvCreateImage( tmplSize, IPL_DEPTH_8U, 1); cvCvtColor( openHandTmpl, openGrayHandTmpl, CV_BGR2GRAY ); tmplSize.width = closedHandTmpl-width; tmplSize.height = closedHandTmpl-height; clos

8、edGrayHandTmpl = cvCreateImage( tmplSize, IPL_DEPTH_8U, 1); cvCvtColor( closedHandTmpl, closedGrayHandTmpl, CV_BGR2GRAY ); cvNamedWindow(source,1); cvMoveWindow(source,0,0); cvNamedWindow( Results, 1 ); cvMoveWindow(Results,400,300); cvAddSearchPath(images); / Open the Output File output = fopen( re

9、sults.log, w ); / Color for contour drawing color = CV_RGB( 255,255,255 ); if( argc = 1 | (argc = 2 & strlen(argv1) = 1 & isdigit(argv10) capture = cvCaptureFromCAM( argc = 2 ? argv10 - 0 : 0 ); else if( argc = 2 ) capture = cvCaptureFromAVI( argv1 ); if(capture != 0) for(;) IplImage *frame;/, *fram

10、e_copy; if( !cvGrabFrame( capture ) break; frame = cvRetrieveFrame( capture ); if( !frame ) break; imgSize.width = frame-width; imgSize.height = frame-height;/ frame_copy = cvCloneImage( frame ); handDetect( frame ); if( cvWaitKey( 10 ) = 0 ) break; cvReleaseCapture( &capture ); else for ( i = 0; i

11、width; imgSize.height = img-height; handDetect( img );/ strcat(filename, names); cvSaveImage(resultsiamge, img); cvReleaseImage(&img); cvWaitKey(0); / for ( i = 0; i width;/ tmplSize.height = openHandTmpl-height;/ / openGrayHandTmpl = cvCreateImage( tmplSize, IPL_DEPTH_8U, 1);/ cvCvtColor( openHandT

12、mpl, openGrayHandTmpl, CV_BGR2GRAY );/ / tmplSize.width = closedHandTmpl-width;/ tmplSize.height = closedHandTmpl-height;/ / closedGrayHandTmpl = cvCreateImage( tmplSize, IPL_DEPTH_8U, 1);/ cvCvtColor( closedHandTmpl, closedGrayHandTmpl, CV_BGR2GRAY );/ Generate processing images tmpImg = cvCloneIma

13、ge(img); conv = cvCreateImage( imgSize, IPL_DEPTH_8U, 3); tmpH1 = cvCreateImage( imgSize, IPL_DEPTH_8U, 1); tmpS1 = cvCreateImage( imgSize, IPL_DEPTH_8U, 1); tmpH2 = cvCreateImage( imgSize, IPL_DEPTH_8U, 1); tmpS2 = cvCreateImage( imgSize, IPL_DEPTH_8U, 1); tmpH3 = cvCreateImage( imgSize, IPL_DEPTH_

14、8U, 1); tmpS3 = cvCreateImage( imgSize, IPL_DEPTH_8U, 1); H = cvCreateImage( imgSize, IPL_DEPTH_8U, 1); S = cvCreateImage( imgSize, IPL_DEPTH_8U, 1); V = cvCreateImage( imgSize, IPL_DEPTH_8U, 1); / Flip the image if in capture mode if ( capture ) cvFlip(conv, conv, 0); / Image Smoothing /cvSmooth(im

15、g,tmpImg,CV_BLUR,3,3); cvSmooth(img,img,CV_GAUSSIAN,3,3); / Convert to HSV cvCvtColor( tmpImg, conv, CV_BGR2HSV ); / Split to HSV planes cvCvtPixToPlane(conv,H,S,V,0); / Average Illumination averageValue = cvAvg( V , 0); fprintf(output, Illumination Level = %fn, averageValue.val0); / Detect skin ton

16、e Hues and Saturations / NOTE: Hue values need to be doubled for actual / Red to Orange Hue with High Saturation / Hue 0 to 28 degree and Sat 190 to 200 cvInRangeS(H,cvScalar(0.0,0.0,0,0),cvScalar(14.0,0.0,0,0),tmpH1); cvInRangeS(S,cvScalar(75.0,0.0,0,0),cvScalar(200.,0.0,0,0),tmpS1); cvAnd(tmpH1,tm

17、pS1,tmpH1,0); / Red Hue with Low Saturation / Hue 0 to 26 degree and Sat 20 to 90 cvInRangeS(H,cvScalar(0.0,0.0,0,0),cvScalar(13.0,0.0,0,0),tmpH2); cvInRangeS(S,cvScalar(20.0,0.0,0,0),cvScalar(90.0,0.0,0,0),tmpS2); cvAnd(tmpH2,tmpS2,tmpH2,0); / Red Hue to Pink with Low Saturation / Hue 340 to 360 de

18、gree and Sat 15 to 90 cvInRangeS(H,cvScalar(170.0,0.0,0,0),cvScalar(180.0,0.0,0,0),tmpH3); cvInRangeS(S,cvScalar(15.0,0.0,0,0),cvScalar(90.,0.0,0,0),tmpS3); cvAnd(tmpH3,tmpS3,tmpH3,0); / Combine the Hue and Sat detections cvOr(tmpH3,tmpH2,tmpH2,0); cvOr(tmpH1,tmpH2,tmpH1,0); / Dilation and Erosion /

19、 Structuring Element Generation dilationElement = cvCreateStructuringElementEx( 5,5,3,3, CV_SHAPE_RECT , 0 ); erosionElement = cvCreateStructuringElementEx( 5,5,3,3, CV_SHAPE_RECT , 0 ); / Dilation adds a layer on, and returns things to the correct size. cvDilate(tmpH1,tmpH2,dilationElement,1); / Erosion peels a layer of pixels off, and makes small regions disappear cvErode(tmpH1,tmpH3,erosionElement,1); / Find the contours of all

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1