資源簡(jiǎn)介
基于opencv的交通標(biāo)志識(shí)別,主要運(yùn)用輪廓識(shí)別和模板匹配。適用于簡(jiǎn)單自然條件下的識(shí)別

代碼片段和文件信息
//?opcv1.cpp?:?定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。
//
#include?“stdafx.h“
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?“cv.h“
#include?
using?namespace?std;
CvSeq*?findSquares4(?IplImage*?img?CvMemStorage*?storage?int?minarea?int?maxarea?int?minangle?int?maxangle);
void?drawSquares1(?IplImage*?img?CvSeq*?squares?const?char*?wndname);
void?findCircle(IplImage*?imgCvMemStorage*?storage);
int?thresh?=?50;
IplImage*?img?=?0;
IplImage*?img0?=?0;
CvMemStorage*?storage?=?0;
CvPoint?pt[4];
const?char*?wndname?=?“Square?Detection?Demo“;
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);
//????double?angle_line?=?(dx1*dx2?+?dy1*dy2)/sqrt((dx1*dx1?+?dy1*dy1)*(dx2*dx2?+?dy2*dy2)?+?1e-10);//余弦值
//????return?acos(angle_line)*180/3.141592653;
}
//?returns?sequence?of?squares?detected?on?the?image.
//?the?sequence?is?stored?in?the?specified?memory?storage
CvSeq*?findSquares3(?IplImage*?img?CvMemStorage*?storage?)
{
????CvSeq*?contours;
????int?i?c?l?N?=?11;
????CvSize?sz?=?cvSize(?img->width?&?-2?img->height?&?-2?);
????IplImage*?timg?=?cvCloneImage(?img?);?//?make?a?copy?of?input?image
????IplImage*?gray?=?cvCreateImage(?sz?8?1?); //1/2
????IplImage*?pyr?=?cvCreateImage(?cvSize(sz.width/2?sz.height/2)?8?3?); //1/4
????IplImage*?tgray;
????CvSeq*?result;
????double?s?t;
????//?create?empty?sequence?that?will?contain?points?-
????//?4?points?per?square?(the?square‘s?vertices)
????CvSeq*?squares?=?cvCreateSeq(?0?sizeof(CvSeq)?sizeof(CvPoint)?storage?);
????
????//?select?the?maximum?ROI?in?the?image
????//?with?the?width?and?height?divisible?by?2
????cvSetImageROI(?timg?cvRect(?0?0?sz.width?sz.height?)); //去圖像1/2大小的圖片,即將圖片分為四份,去左上角的部分????
????//?down-scale?and?upscale?the?image?to?filter?out?the?noise
????cvPyrDown(?timg?pyr?7?);
????cvPyrUp(?pyr?timg?7?);
????tgray?=?cvCreateImage(?sz?8?1?);????
????//?find?squares?in?every?color?plane?of?the?image
????for(?c?=?0;?c?3;?c++?)//在三通道下
????{
????????//?extract?the?c-th?color?plane
????????cvSetImageCOI(?timg?c+1?);
????????cvCopy(?timg?tgray?0?);????????
????????//?try?several?threshold?levels
????????for(?l?=?0;?l?????????{
????????????//?hack:?use?Canny?instead?of?zero?threshold?level.
????????????//?Canny?helps?to?catch?squares?with?gradient?shading???
????????????if(?l?==?0?)
????????????{
????????????????//?apply?Canny.?Take?the?upper?threshold?from?slider
????????????????//?and?set?the?lower?to?0?(which?forces?edges?merging)?//thresh
????????????????cvCanny(?tgray?gray?1000?900?5?);
// ?cvThreshold(?tgray?gray?(l+
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-10-17?10:18??opcv1\
?????目錄???????????0??2016-10-08?18:35??opcv1\Debug\
?????目錄???????????0??2016-10-17?09:37??opcv1\ipch\
?????目錄???????????0??2016-10-17?09:37??opcv1\ipch\opcv1-de206ace\
?????文件?????2359296??2016-10-17?09:37??opcv1\ipch\opcv1-de206ace\opcv1-df31438d.ipch
?????目錄???????????0??2016-10-12?11:47??opcv1\opcv1\
?????文件????18042880??2016-10-17?10:18??opcv1\opcv1.sdf
?????文件????????1236??2016-10-08?18:36??opcv1\opcv1.sln
?????文件???????14336??2016-10-17?10:18??opcv1\opcv1.suo
?????目錄???????????0??2016-10-08?18:35??opcv1\opcv1\Debug\
?????文件????????1402??2016-10-08?18:35??opcv1\opcv1\Debug\cl.command.1.tlog
?????文件???????13984??2016-10-08?18:35??opcv1\opcv1\Debug\CL.read.1.tlog
?????文件?????????714??2016-10-08?18:35??opcv1\opcv1\Debug\CL.write.1.tlog
?????文件???????????2??2016-10-08?18:35??opcv1\opcv1\Debug\li
?????文件???????????2??2016-10-08?18:35??opcv1\opcv1\Debug\li
?????文件???????????2??2016-10-08?18:35??opcv1\opcv1\Debug\li
?????文件???????????2??2016-10-08?18:35??opcv1\opcv1\Debug\opcv1.exe.em
?????文件??????????68??2016-10-08?18:35??opcv1\opcv1\Debug\opcv1.exe.em
?????文件??????????56??2016-10-08?18:35??opcv1\opcv1\Debug\opcv1.lastbuildstate
?????文件????????2702??2016-10-08?18:35??opcv1\opcv1\Debug\opcv1.log
?????文件???????61018??2016-10-08?18:35??opcv1\opcv1\Debug\opcv1.obj
?????文件?????1179648??2016-10-08?18:35??opcv1\opcv1\Debug\opcv1.pch
?????文件???????????0??2016-10-08?18:35??opcv1\opcv1\Debug\opcv1.unsuccessfulbuild
?????文件?????????713??2016-10-08?18:35??opcv1\opcv1\Debug\opcv1.vcxprojResolveAssemblyReference.cache
?????文件???????????0??2016-10-08?18:35??opcv1\opcv1\Debug\opcv1.write.1.tlog
?????文件?????????200??2016-10-08?18:35??opcv1\opcv1\Debug\opcv1_manifest.rc
?????文件?????????484??2016-10-08?18:35??opcv1\opcv1\Debug\rc.command.1.tlog
?????文件?????????258??2016-10-08?18:35??opcv1\opcv1\Debug\rc.read.1.tlog
?????文件?????????266??2016-10-08?18:35??opcv1\opcv1\Debug\rc.write.1.tlog
?????文件???????11743??2016-10-08?18:35??opcv1\opcv1\Debug\stdafx.obj
?????文件??????388096??2016-10-08?18:35??opcv1\opcv1\Debug\vc100.idb
............此處省略75個(gè)文件信息
評(píng)論
共有 條評(píng)論