资源简介
opencv 多指尖检测 源代码
opencv 多指尖检测 源代码

代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#pragma comment(lib“cv210.lib“)
#pragma comment(lib“cxcore210.lib“)
#pragma comment(lib“highgui210.lib“)
void ErrorHandler(char* message)
{
cout< exit(0);
}
#undef UNICODE
void fingerTip(char* imgname);
int main()
{
WIN32_FIND_DATA FileData;
HANDLE hSearch;
BOOL fFinished = FALSE;
if(!SetCurrentDirectory(“images“)){
cout<<“failed to change work directory“< exit(0);
}
hSearch = FindFirstFile(“*.bmp“ &FileData);
if (hSearch == INVALID_HANDLE_VALUE){
ErrorHandler(“No .bmp files found.“);
}
while (!fFinished){
fingerTip(FileData.cFileName);
if (!FindNextFile(hSearch &FileData)){
if (GetLastError() == ERROR_NO_MORE_FILES){
fFinished = TRUE;
} else {
ErrorHandler(“Couldn‘t find next file.“);
}
}
cvWaitKey(0);
}
// Close the search handle.
if (!FindClose(hSearch)){
ErrorHandler(“Couldn‘t close search handle.“);
}
return 0;
}
void fingerTip(char* imgname)
{
IplImage* pImgColor=NULL;
IplImage* pImgGray=NULL;
IplImage* pImgContourAll=NULL;
IplImage* pImgContourAppr=NULL;
IplImage* pImgHull=NULL;
IplImage* pImgDefects=NULL;
pImgColor=cvLoadImage(imgnameCV_LOAD_IMAGE_COLOR);
if (!pImgColor){
cout<<“failed to load image“< exit(0);
}
pImgGray=cvCreateImage(cvGetSize(pImgColor)81);
cvCvtColor(pImgColorpImgGrayCV_RGB2GRAY);
pImgContourAppr=cvCreateImage(cvGetSize(pImgGray)83);
pImgContourAll=cvCreateImage(cvGetSize(pImgGray)83);
pImgHull=cvCreateImage(cvGetSize(pImgGray)83);
pImgDefects=cvCreateImage(cvGetSize(pImgGray)83);
cvZero(pImgContourAppr);
cvZero(pImgContourAll);
cvZero(pImgHull);
cvZero(pImgDefects);
//canny
CvMemStorage* storage=cvCreateMemStorage();
CvSeq* contourSeqAll=cvCreateSeq(0sizeof(CvSeq)sizeof(CvPoint)storage);
cvCanny(pImgGraypImgGray10305);
cvFindContours(pImgGraystorage&contourSeqAllsizeof(CvContour)CV_RETR_LISTCV_link_RUNS);
//original contours
CvSeq* tseq=contourSeqAll;
for (;contourSeqAll;contourSeqAll=contourSeqAll->h_next){
cvDrawContours(pImgContourAllcontourSeqAllcvScalar(25500)cvScalar(00255)02);
}
contourSeqAll=tseq;
CvMemStorage* storageAppr=cvCreateMemStorage();
CvSeq* contourAppr=cvCreateSeq(0sizeof(CvSeq)sizeof(CvPoint)storageAppr);
contourAppr=cvApproxPoly(contourSeqAllsizeof(CvContour)storageApprCV_POLY_APPROX_DP51);
//approximated contours
tseq=contourAppr;
for (;contourAppr;contourAppr=contourAppr->h_next){
cvDrawContours(pImgContourApprcontourApprcvScalar(25500)cvScalar(00255)02);
}
contourAppr=tseq;
//print contours
/*cout<<“contours:“< for (int i=0;itotal;i++){
CvPoint* p=(CvPoint*)CV_GET_SEQ_ELEM
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3928 2010-11-28 13:39 fingertips\fingertips.vcproj
文件 885 2010-11-27 21:45 fingertips\fingertips.sln
..A..H. 9728 2010-12-01 09:14 fingertips\fingertips.suo
文件 1423 2010-12-01 09:14 fingertips\fingertips.vcproj.FOOLPP-REGION.Administrator.user
文件 41078 2010-11-26 16:35 fingertips\images\down-001.bmp
文件 41078 2010-11-26 16:34 fingertips\images\straight-000.bmp
文件 41078 2010-11-26 16:34 fingertips\images\left-000.bmp
文件 41078 2010-11-26 16:34 fingertips\images\right-000.bmp
文件 41078 2010-11-26 16:34 fingertips\images\up-000.bmp
文件 41078 2010-11-26 16:34 fingertips\images\down-000.bmp
文件 41078 2010-11-26 16:35 fingertips\images\straight-001.bmp
文件 41078 2010-11-26 16:35 fingertips\images\left-001.bmp
文件 41078 2010-11-26 16:35 fingertips\images\right-001.bmp
文件 41078 2010-11-26 16:35 fingertips\images\up-001.bmp
文件 6646 2010-11-28 13:43 fingertips\Debug\BuildLog.htm
文件 663 2010-11-27 22:14 fingertips\Debug\fingertips.exe.em
文件 601088 2010-11-28 13:43 fingertips\Debug\vc90.idb
文件 552960 2010-11-28 13:43 fingertips\Debug\vc90.pdb
文件 728 2010-11-27 22:14 fingertips\Debug\fingertips.exe.em
文件 42496 2010-11-28 13:43 fingertips\Debug\fingertips.exe
文件 969728 2010-11-28 13:43 fingertips\Debug\fingertips.pdb
文件 621 2010-11-28 13:43 fingertips\Debug\fingertips.exe.intermediate.manifest
文件 64 2010-11-28 13:43 fingertips\Debug\mt.dep
文件 716432 2010-11-28 13:43 fingertips\Debug\fingertips.ilk
文件 86914 2010-11-28 13:43 fingertips\Debug\fingertips.obj
文件 4415 2010-11-28 13:43 fingertips\fingertips.cpp
目录 0 2010-11-27 21:46 fingertips\images
目录 0 2010-11-27 22:12 fingertips\Debug
目录 0 2010-11-27 21:45 fingertips
----------- --------- ---------- ----- ----
............此处省略2个文件信息
- 上一篇:人工智能 水壶问题的求解.rar
- 下一篇:手势控制音乐播放器 源码
相关资源
- bp神经网络源代码,可直接运行
- 仿知乎界面小程序源代码
- 贪吃蛇源代码.fla
- dotnet 写字板 实验 源代码 不好请要不
- 图像二维小波变换的实现源代码
- 八三编码器设计 VHDL代码 简单,包附
- linux应用层的华容道游戏源代码
- 网上拍卖系统完整源代码
- CSMA/CD等动画演示加源代码
- silicon lab公司的收音IC SI47XX全套开发工
- 合同管理系统的源代码(附数据库)
- 用VC 编写的仿QQ聊天室程序源代码
- STM32F103 串口程序(完整版)
- VPC3_DPV1源代码,Profibus
- PB做的托盘程序(最小化后在左下角显
- 透明加密源码及说明
- 排队机叫号 源代码
- 五子棋C 源代码
- CAD LISP24个源代码
- 二叉树基本操作源代码
- 推箱子及人工智能寻路C 源代码
- opengl轮廓字体源代码
- 冈萨雷斯 数字图像处理 源代码(m文
- 直流伺服电机电路原理图(内附单片
- 哈哈冒险岛登入器源代码
- midi电子琴简单设计(附源代码).ra
- PESQ C源代码
- 画图程序MFC/VC/VC CRectTracker 串行化
- 莱卡 全站仪数据格式转换程序,有源
- 基于OpenCV的数字识别468815
评论
共有 条评论