• 大小: 593KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: 其他
  • 标签: opencv  

资源简介

opencv 飞行游戏手势控制源码。飞行游戏手势控制。。。。

资源截图

代码片段和文件信息

#include “CVobject.h“
//Download by http://www.NewXing.com
#include 
#include 
#include 
using namespace std;

void cvThresholdBidirection(IplImage* imgint lowerint upper)
{
assert(img->nChannels==1);
for (int h=0;hheight;h++){
for (int w=0;wwidth;w++){
unsigned char* p =(unsigned char*)(img->imageData+h*img->widthStep+w);
if (*p<=upper&&*p>=lower){
*p=255;
}else{
*p=0;
}
}
}
}

void cvFindTargets(const IplImage* img_const int erea_thresholdCvTarget &targets)
{
assert(img_->nChannels==1);

IplImage* img=cvCreateImage(cvSize(img_->widthimg_->height)IPL_DEPTH_8U1);
cvCopy(img_img);

CvTarget tar;
for (int h=0;hheight;h++){
for (int w=0;wwidth;w++){
if (*(unsigned char*)(img->imageData+h*img->widthStep+w)==255){
CvTarget target;
target.top=h;
target.bottom=h;
target.left=w;
target.right=w;
queue points;
points.push(cvPoint(wh));
*(img->imageData+h*img->widthStep+w)=0;
//find target with breadth iteration
while(!points.empty()){
target.erea++;
CvPoint p=points.front();
points.pop();

if (p.x>0&&*(unsigned char*)(img->imageData+p.y*img->widthStep+p.x-1)==255){//left
*(img->imageData+p.y*img->widthStep+p.x-1)=0;
points.push(cvPoint(p.x-1p.y));
if (target.left>p.x-1){
target.left=p.x-1;
}
}
if (p.y+1height&&*(unsigned char*)(img->imageData+(p.y+1)*img->widthStep+p.x)==255){//bottom
*(img->imageData+(p.y+1)*img->widthStep+p.x)=0;
points.push(cvPoint(p.xp.y+1));
if (target.bottom target.bottom=p.y+1;
}
}
if (p.x+1width&&*(unsigned char*)(img->imageData+p.y*img->widthStep+p.x+1)==255){//right
*(img->imageData+p.y*img->widthStep+p.x+1)=0;
points.push(cvPoint(p.x+1p.y));
if (target.right target.right=p.x+1;
}
}
if (p.y>0&&*(unsigned char*)(img->imageData+(p.y-1)*img->widthStep+p.x)==255){//top
*(img->imageData+(p.y-1)*img->widthStep+p.x)=0;
points.push(cvPoint(p.xp.y-1));
}
}
if (target.erea>erea_threshold){
if (target.erea>tar.erea){
tar=target;
}
}
}
}
}
targets=tar;
cvReleaseImage(&img);
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      41078  2010-11-26 16:34  www.NewXing.com\samples\down-000.bmp

     文件      41078  2010-11-26 16:35  www.NewXing.com\samples\down-001.bmp

     文件      41078  2010-11-26 16:35  www.NewXing.com\samples\down-002.bmp

     文件      41078  2010-11-26 16:35  www.NewXing.com\samples\down-003.bmp

     文件      41078  2010-11-26 16:35  www.NewXing.com\samples\down-004.bmp

     文件      41078  2010-11-26 16:35  www.NewXing.com\samples\down-005.bmp

     文件      41078  2010-11-26 16:36  www.NewXing.com\samples\down-006.bmp

     文件      41078  2010-11-26 16:36  www.NewXing.com\samples\down-007.bmp

     文件      41078  2010-11-26 16:36  www.NewXing.com\samples\down-008.bmp

     文件      41078  2010-11-26 16:36  www.NewXing.com\samples\down-009.bmp

     文件      41078  2010-11-26 16:36  www.NewXing.com\samples\down-010.bmp

     文件      41078  2010-11-26 16:36  www.NewXing.com\samples\down-011.bmp

     文件      41078  2010-11-26 16:36  www.NewXing.com\samples\down-012.bmp

     文件      41078  2010-11-26 16:36  www.NewXing.com\samples\down-013.bmp

     文件      41078  2010-11-26 16:37  www.NewXing.com\samples\down-014.bmp

     文件      41078  2010-11-26 16:37  www.NewXing.com\samples\down-015.bmp

     文件      41078  2010-11-26 16:37  www.NewXing.com\samples\down-016.bmp

     文件      41078  2010-11-26 16:37  www.NewXing.com\samples\down-017.bmp

     文件      41078  2010-11-26 16:37  www.NewXing.com\samples\down-018.bmp

     文件      41078  2010-11-26 16:37  www.NewXing.com\samples\down-019.bmp

     文件      41078  2010-11-26 16:38  www.NewXing.com\samples\down-020.bmp

     文件      41078  2010-11-26 16:38  www.NewXing.com\samples\down-021.bmp

     文件      41078  2010-11-26 16:38  www.NewXing.com\samples\down-022.bmp

     文件      41078  2010-11-26 16:38  www.NewXing.com\samples\down-023.bmp

     文件      41078  2010-11-26 16:38  www.NewXing.com\samples\down-024.bmp

     文件      41078  2010-11-26 16:38  www.NewXing.com\samples\down-025.bmp

     文件      41078  2010-11-26 16:38  www.NewXing.com\samples\down-026.bmp

     文件      41078  2010-11-26 16:38  www.NewXing.com\samples\down-027.bmp

     文件      41078  2010-11-26 16:39  www.NewXing.com\samples\down-028.bmp

     文件      41078  2010-11-26 16:39  www.NewXing.com\samples\down-029.bmp

............此处省略186个文件信息

评论

共有 条评论