资源简介
ex6btr.zip

代码片段和文件信息
#include “cv.h“
#include “highgui.h“
#include “stdio.h“
#include “math.h“
#include “iostream.h“
int main()
{
//-----------------------------------开创内存空间,载入图像--------------------------------
IplImage *img*gimg*edge*cedge*rimg*result1*result2*result3;//*result4;
img=cvLoadImage(“水果1.jpg“);
cvNamedWindow(“水果“1);
cvShowImage(“水果“img);
int N_line=0;
int count=0;
gimg=cvCreateImage(cvSize(img->widthimg->height)81);
edge=cvCreateImage(cvSize(img->widthimg->height)81);
cedge=cvCreateImage(cvSize(img->widthimg->height)81);
rimg=cvCreateImage(cvSize(img->widthimg->height)81);
cvNot(rimgrimg);
result1=cvCreateImage(cvSize(img->widthimg->height)81);
result2=cvCreateImage(cvSize(img->widthimg->height)81);
result3=cvCreateImage(cvSize(img->widthimg->height)81);
cvNot(result1result1);
cvNot(result2result2);
cvNot(result3result3);
//------------------------图像阈值化处理----------------------------------------
cvCvtColor(imggimgCV_BGR2GRAY);//灰度图转化
cvSmooth(gimgedgeCV_BLUR330);//高斯模糊
cvDilate(gimggimgNULL1);
cvNamedWindow(“灰度图像“1);
cvShowImage(“灰度图像“gimg);
CvMemStorage *store;
CvSeq *outline;
double thread=200;//设立阈值
cvSmooth(gimgedgeCV_BLUR330);
cvNot(gimgedge);
cvThreshold(gimgedgethread255CV_THRESH_BINARY);
cvNot(edgeedge);
IplConvKernel *space=cvCreateStructuringElementEx(4422CV_SHAPE_ELLIPSENULL);
cvDilate(edgeedgespace1);
cvErode(edgeedgespace1);
cvNamedWindow(“二值图像“1);
cvShowImage(“二值图像“edge);
//------------------------边缘提取----------------------------------------
cvCanny(edgecedgethreadthread*73);
// cvThreshold(gimgedge(double)edge_t255CV_THRESH_BINARY);
store=cvCreateMemStorage(0);
cvCreateSeq(CV_SEQ_ELTYPE_POINTsizeof(CvSeq)sizeof(CvPoint)store);
N_line=cvFindContours(cedgestore&outlinesizeof(CvContour)CV_RETR_LISTCV_CHAIN_APPROX_SIMPLEcvPoint(00));
cout<<“ the number of outline:“< // printf(“nCon=%d“nCon);
//------------------------建立分类标准,图像分类----------------------------------------
for(;outline;outline=outline->h_next)
{
if(outline->total<8)
continue;
if(count%2==0)
{
cvDrawContours(rimgoutlineCV_RGB(000)CV_RGB(000)018cvPoint(00));
cvNamedWindow(“边缘轮廓“1);
cvShowImage(“边缘轮廓“rimg);
double arealength;
area=(cvContourArea(outlineCV_WHOLE_SEQ)+fabs(cvContourArea(outline->h_nextCV_WHOLE_SEQ)));
area/=2;
length=(cvArcLength(outlineCV_WHOLE_SEQ-1)+fabs(cvArcLength(outline->h_nextCV_WHOLE_SEQ-1)));
length/=2;
printf(“\n area=%f\n length=%f\n“arealength);
double roundper;
roundper=4*3.14*fabs(area)/(fabs(length)*fabs(length));
printf(“ roundper=%5f\n“roundper);
if(roundper<0.6&&area>=4000)
{
cvDrawContours(result1outlineCV_RGB(000)CV_RGB(000)0CV_FILLED8cvPoint
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-10-20 12:11 水果识别\
文件 4100 2012-06-13 17:19 水果识别\123.cpp
文件 34860 2012-06-08 16:03 水果识别\水果1.jpg
相关资源
- PID_AutoTune_v0.rar
- vspd7.2.308.zip
- 价值2k的H漫画小说系统
- Pythonamp;课堂amp;笔记(高淇amp;400;集第
- ddos压力测试工具99657
- UML建模大全
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- FTP课程设计(服务端+客户端)
- 计算机图形学 边填充算法实现代码
- 电力系统潮流计算程序集合
- oracle数据迁移项目实施方案
- Web Api 通过文件流 文件到本地
- Visio图标-最新最全的网络通信图标库
- Spire API文档
- OpenGL参考手册
- Python中Numpy库最新教程
- SPD博士V5.3.exe
- 直流无刷电机方波驱动 stm32 例程代码
- layui后台管理模板
- 仿知乎界面小程序源代码
- 云平台-阿里云详细介绍
- photoshop经典1000例
- scratch垃圾分类源码(最终版本).sb
- IAR ARM 7.8破解
- TI CCS V5.4 安装步骤及破解文件
- 松下plc FP-XH的驱动
- 局域网硬件信息收集工具
- 加快Windows XP操作系统开机速度
评论
共有 条评论