资源简介
用OpenCV实现的交通标志动态识别,方法是自己想的,希望对大家有帮助,有好的想法可以互相交流。
代码片段和文件信息
#ifdef _CH_
#pragma package
#endif
#define CV_NO_BACKWARD_COMPATIBILITY
#include “cv.h“
#include “highgui.h“
#include “cxcore.h“
#include
#include
#include
IplImage* stop=0;
IplImage* left=0;
IplImage* m1=0;
IplImage* m2=0;
IplImage* m3=0;
IplImage* m4=0;
IplImage* m5=0;
IplImage* m6=0;
IplImage* m7=0;
IplImage* m8=0;
IplImage* m9=0;
IplImage* m10=0;
IplImage* m11=0;
IplImage* m12=0;
IplImage* m13=0;
IplImage* m14=0;
IplImage* m15=0;
IplImage* image=0;
IplImage* show;
CvMemStorage* tempStorage=0;
CvMemStorage* stopStorage=0;
CvMemStorage* leftStorage=0;
CvMemStorage* m1Storage=0;
CvMemStorage* m2Storage=0;
CvMemStorage* m3Storage=0;
CvMemStorage* m4Storage=0;
CvMemStorage* m5Storage=0;
CvMemStorage* m6Storage=0;
CvMemStorage* m7Storage=0;
CvMemStorage* m8Storage=0;
CvMemStorage* m9Storage=0;
CvMemStorage* m10Storage=0;
CvMemStorage* m11Storage=0;
CvMemStorage* m12Storage=0;
CvMemStorage* m13Storage=0;
CvMemStorage* m14Storage=0;
CvMemStorage* m15Storage=0;
const char* wndname = “Flag“;
int itempFlag=0trigonFlag=0squareFlag=0;
CvSeq* result;
CvSeq* slice;
double s t hu;
CvSeqReader reader;
CvSeq* tctr;
CvSeq* p_temp;
CvSeq temp;
CvSeq* p_stopCtr;
CvSeq stopCtr;
CvSeq* p_leftCtr;
CvSeq leftCtr;
CvSeq* p_m1Ctr;
CvSeq m1Ctr;
CvSeq* p_m2Ctr;
CvSeq m2Ctr;
CvSeq* p_m3Ctr;
CvSeq m3Ctr;
CvSeq* p_m4Ctr;
CvSeq m4Ctr;
CvSeq* p_m5Ctr;
CvSeq m5Ctr;
CvSeq* p_m6Ctr;
CvSeq m6Ctr;
CvSeq* p_m7Ctr;
CvSeq m7Ctr;
CvSeq* p_m8Ctr;
CvSeq m8Ctr;
CvSeq* p_m9Ctr;
CvSeq m9Ctr;
CvSeq* p_m10Ctr;
CvSeq m10Ctr;
CvSeq* p_m11Ctr;
CvSeq m11Ctr;
CvSeq* p_m12Ctr;
CvSeq m12Ctr;
CvSeq* p_m13Ctr;
CvSeq m13Ctr;
CvSeq* p_m14Ctr;
CvSeq m14Ctr;
CvSeq* p_m15Ctr;
CvSeq m15Ctr;
// helper function:
// finds a cosine of angle between vectors
// from pt0->pt1 and from pt0->pt2
double angle( CvPoint* pt1 CvPoint* pt2 CvPoint* pt0 )
{
double dx1 = pt1->x - pt0->x;
double dy1 = pt1->y - pt0->y;
double dx2 = pt2->x - pt0->x;
double dy2 = pt2->y - pt0->y;
return (dx1*dx2 + dy1*dy2)/sqrt((dx1*dx1 + dy1*dy1)*(dx2*dx2 + dy2*dy2) + 1e-10);
}
void preorder(CvSeq* ctrCvSeq* saveCvMemStorage* storage)
{
if(ctr)
{
result = cvApproxPoly( ctr sizeof(CvContour) storage
CV_POLY_APPROX_DP cvContourPerimeter(ctr)*0.008 0 );
if( result->total ==3 && fabs(cvContourArea(resultCV_WHOLE_SEQ)) > 1000)
{
tctr=ctr;
ctr=ctr->v_next;
if(ctr)
{
slice=cvSeqSlice(ctrcvSlice(0CV_WHOLE_SEQ_END_INDEX)storage0);
*save=*slice;
trigonFlag=1;
}
else
ctr=tctr;
}
if( result->total ==4 && fabs(cvContourArea(resultCV_WHOLE_SEQ)) > 1000)
{
s = 1;
for( i = 0; i < (result->total+1); i++ )
{
// find minimum angle between joint
// edges (maximum of cosine)
if( i >= 2 )
{
t = fabs(angle(
(CvPoint*)cvGetSeqElem( result i )
(CvPoint*)cvGetSeqElem( result i-2 )
(CvPoint*)cvGetSeqElem( result i-1 )));
s = s < t ? s : t;
}
}
if(s<0.1)
{
tctr=ctr;
- 上一篇:电动汽车无线充电系统的电磁安全
- 下一篇:UMAT子程序详解
相关资源
- 基于OpenCV的摄像头动态手势轨迹识别
- 编译好的opencv_conrib库.txt
- ubuntu 12.04 +Qt+opencv采集、显示视频并拍
- opencv300.props
- OpenCV使用特殊颜色标记彩色图像轮廓
- VS2015+opencv3.2+opencv contrib3.2+cmake3.8.2
- Kinect获取彩色图像并保存为jpg图片
- 如何用OpenCV训练自己的分类器.doc
- opencv_calib3d310d.dll
- 利用OpenCV,通过SVM识别图像中图形链
- opencv2.4.11配置文件
- 图像特征之方向直方图OPENCV程序
- viewpager动态控制页数
- 遗传算法波段选择
- 图像二值化 opencv 基本全局阈值法
- OpenCV-根据颜色进行目标检测
- OpenCV轮廓提取的源代码
- STM32L053C8T6驱动240×240彩屏钟表显示时
- 创意网页动态小人时钟
- delphi中使用bpl模式合作开发的模式
- opencv 中模板匹配的完整
- lee的caffe配置install-opencv-master.zip
- 动态分区存储管理方式的主存分配回
- 专业图形工具Opencv For Unity的插件 v
- opengl动态云彩的模拟
- 车牌定位cascade文件
- opencv摄像机双目标定代码
- 基于Cascade的车牌检测文件 haar算法输
- Qt Creator+OpenCV410(vc14)开发的图片查
- 随机动态规划
评论
共有 条评论