FQAopencvhaartrainingWord格式.docx

上传人:b****4 文档编号:17343664 上传时间:2022-12-01 格式:DOCX 页数:6 大小:18.93KB
下载 相关 举报
FQAopencvhaartrainingWord格式.docx_第1页
第1页 / 共6页
FQAopencvhaartrainingWord格式.docx_第2页
第2页 / 共6页
FQAopencvhaartrainingWord格式.docx_第3页
第3页 / 共6页
FQAopencvhaartrainingWord格式.docx_第4页
第4页 / 共6页
FQAopencvhaartrainingWord格式.docx_第5页
第5页 / 共6页
点击查看更多>>
下载资源
资源描述

FQAopencvhaartrainingWord格式.docx

《FQAopencvhaartrainingWord格式.docx》由会员分享,可在线阅读,更多相关《FQAopencvhaartrainingWord格式.docx(6页珍藏版)》请在冰豆网上搜索。

FQAopencvhaartrainingWord格式.docx

Sooriginalpositiveimagesareresized 

andpackedasthumbstovecfile.Vecfilehasheader:

numberofpositivesamples,width,heightandcontainpositivethumbsinbody.

Isitpossibletomergevecfiles?

Yes,useGoogle,therearefreetools,writtenbyOpenCV’scommunity.

Ihave 

positiveimages,howcreatevecfileofpositivesamples?

ThereistoolinC:

\ProgramFiles\OpenCV\apps\HaarTraining\srccreatesamples.cpp. 

Usage:

createsamples-infopositive_description.txt-vecsamples.vec-w20-h20

What’spositivedescriptionfile?

Thematteristhat,oneachpositiveimage,therecanbeseveralobjects.Theyhaveboundingrectangles:

x,y,width,height. 

Soyoucanwritesuchdescriptioninfoofimage:

positive_image_name 

num_of_objectsxywidthheightxywidthheight…

Textfile,whichcontainssuchinfoaboutpositiveimagesiscalleddescriptionfile.Soduringvecfilegeneration, 

reallyobjectsarepacked,butnotwholeimage.Essentiallyvecfileisneededtospeedupmachinelearning.

DoIalwaysneeddescriptionfile,evenifIhaveonlyoneobjectonaimage?

Yes,withcreatesamplesyouneeddescriptionfile. 

Ifyouhaveonlyoneobject,it’sboundingrectanglemaybeboundingrectangleofwholeimage.Ifyouwant,writeyourowntoolforvecfilegeneration=)

Shouldlightningconditionsandbackgroundbevariousonpositiveimages?

Yes,it’sveryimportant.Oneachpositiveimage,besideobject,thereisbackground.Trytofillthisbackgroundwithrandomnoise,avoidconstantbackground.

Howmuchbackgroundshouldbeonpositiveimage?

Ifyouhavemuchbackgroundpixelsonyourpositiveimagesincomparisonwithobject’spixels–it’sbadsincethehaartrainingcouldrememberthebackgroundasfeatureofpositiveimage.

Ifyoudon’thavebackgroundpixelsatall–it’salsobad.Thereshouldbesmallbackgroundframeonpositiveimage

Shouldalloriginalpositiveimageshavethesamesize?

No,originalimagescanhaveanysize. 

Butit’simportantthatwidth,heightofthisrectanglehavethesameaspectratioas-w-h.

What’s 

-wand-hshouldIputincreatesamples?

Shoulditbealwayssquare?

Youcanputanyvalueto-wand-hdependonaspectratioofthetargetobjectwhichyouwanttodetect. 

Butobjectsofsmallersizewillnotbedetected!

Forfaces,commonlyusedvaluesare24×

24,20×

20.Butyoumayuse24×

20,20×

24,etc.

Errorsduringvecfilegeneration:

Incorrectsizeofinputarray,0kbvecfile,

-Firstcheckyoudescriptionfile:

positive_image_nameshouldbeabsolutepathnamewithoutspaceslike“C:

\content\image.jpg”not“C:

\content\image.jpg”orrelativepathname.

-Avoidemptylinesindescriptionfile

-Resolutionoforiginalpositiveimagefileshouldbenotless,then-w-hparametersyouput.

-Checkthatpositiveimagesareavailableinyourfilesystemsandnotcorrupted.

-Therecanbeunsupportedformats.Jpeg,Bmp,PPMaresupported!

Exampleofvecfilegeneration!

Let’sworkingdirectorybeC:

\haartraining.Initthereiscreatesamples.exe.Thereisfolder

C:

\haartraining\positives.Socreatedescriptionfilepositive_desc.txt.

positives\image1.jpg110102020

positives\image2.jpg23030505060607070

or

\haartraining\positives\image1.jpg110102020

\haartraining\positives\image2.jpg23030505060607070

Youshouldavoidemptylinesandemptyspaceinimage’spath

createsamples-infopositive_desc.txt-vecsamples.vec-w20-h20

Negativeimages

WhatnegativeimagesshouldItake?

YoucanuseanyimageofOpenCVsupportedformats,whichdoesnotcontaintargetobjects(whicharepresentonpositiveimages).Buttheyshouldbevarious–it’simportant!

Goodenoughdatabaseishere

Shouldnegativeimageshavethesamesize?

No.Butthesizeshouldnotbelessthan-w-h,whichwereputduringvecfilegeneration.

What’sdescriptionfilefornegativeimage?

It’sjusttextfile,oftencallednegative.dat,whichcontainsfullpathtonegativeimageslike:

image_name1.jpg

image_name2.jpg

Avoidemptylinesinit.

Howmanynegative/positiveimageshouldItake?

Itdependsonyourtask. 

Forrealcascadesthereshouldbeabout1000positiveimagesand2000negativeimagese.g.

Goodenoughproportionis 

positive:

negative=1:

2,butit’snothardrule!

Iwouldrecommendfirsttousesmallnumberofsamples,generatecascade,testit,thenenlargenumberofsamples.

Launchhaartraining.exe(OpenCV\apps\HaarTraining\src)

Exampleoflaunching

WorkingdirectoryisC:

\haartrainingwithhaartraining.exetoolandsamples.vecfile.

Let’snegativeimagesareinC:

\haartraining\negative,inthiscasenegative.datshouldbelikethis:

negative\neg1.jpg

negative\neg2.jpg

SoinC:

\haartraininglaunchthis:

 

haartraining-datahaarcascade-vecsamples.vec-bgnegatives.dat-nstages20 

-minhitrate0.999-maxfalsealarm0.5-npos1000-nneg2000-w20-h20-nonsym-mem1024

∙w 

isthesame,youputduringvecfilegeneration

∙nposnneg 

–numberofpositivesamplesandnegativesamples

∙mem–RAMmemory,thatprogrammayuse

∙maxfalsealarm–maximumfalsealarm,thatstagemayhave.Ifbigfalsealarm–itcouldbebaddetectionsystem

∙minhitrate–minimalhitrate,thatshouldstagehaveatleast

∙nstage–numberofstagesincascade

What’sfalsealarmandhitrateofstage?

Youshouldreadtheoryofadaboostaboutstrongclassifier.Stageisstrongclassifier.Inshort:

∙Forexampleyouhave1000positivesamples.Youwantyoursystemtodetect900ofthem.Sodesiredhitrate=900/1000=0.9.Commonly,putminhitrate=0.999

∙Forexampleyouhave1000negativesamples.Becauseit’snegative,youdon’twantyoursystemtodetectthem.Butyoursystem,becauseithaserror,willdetectsomeofthem.Leterrorbeabout490samples,sofalsealarm=490/1000=0.49.Commonly,putfalsealarm 

=0.5

Arefalsealarmandhitratedependoneachother?

Yes,thereisdependency.Youcouldnotputminhitrate=1.0andmaxfalsealarm=0.0..

Firstly,thesystembuildsclassifierwithdesiredhitrate,thenitwillcalculateit’sfalsealarm,ifthefalsealarmishigherthanmaxfalsealarm,thesystemwillrejectsuchclassifierandwillbuildthenextone.Duringhaartrainingyoumayseesuch:

N|%SMP|F|ST.THR|HR|FA|EXP.ERR|

+—-+—-+-+———+———+———+———+

|0|25%|-|-1423.312590|1.000000|1.000000|0.876272|

HR–hitrate

FA–falsealarm

What’sfalsealarmandhitrateofwholecascade?

Cascadeislinkedlist(orthree)ofstages.That’swhy:

∙Falsealarmofcascade=falsealarmof 

stage1*falsealarmof 

stage2*…

∙Hitrate=hitrateof 

stage1*hitrateofstage2*…

Howmanystagesshouldbeused?

∙Ifyousetbignumberofstages,thenyouwillachievebetterfalsealarm,butitwilltakemoretimeforgeneratingcascade.

∙Ifyousetbignumberofstages,thenthedetectiontimecouldbeslower

∙Ifyousetbignumberofstages,thentheworsehitratewillbe(0.99*0.99*…etc).Commonly14-25stagesareenough

∙It’suselesstosetmanystage,ifyouhavesmallnumberofpositive,negativesamples

What’sweighttrimming,eqw,bt,nonsymoptions?

ReallyalltheseparametersarerelatedtoAdaboost,readtheory.Inshort:

∙nonsym–IfyoupositivesamplesarenotXorYsymmetric,put-nonsym,-symisdefault!

∙eqw–ifyouhavedifferentnumberofposandnegimages,it’sbettertoputnoeqw

∙weighttrimming–forcalculationoptimization.Itcanreducecalculationtimealittle,butqualitymaybeworse

∙bt–whatAdaboostalgorithmtouse:

RealAB,GentleAB,etc.

What’s 

minpos,nsplits,maxtreesplitsoptions?

Theseparametersarerelatedtoclustering.InAdaboostdifferentweekclassifiermaybeused:

stump-basedortree-based. 

Ifyouchoosensplits>

0,tree-basedwillbeusedandyoushouldsetupminposandmaxtreesplits.

∙nsplits–minimunnumberofnodesintree

∙maxtreesplits–maximumnumberofnodesintree.Ifmaxtreesplits<

nsplits, 

treewillnotbebuilt

∙minpos–numberofpositiveimages,thatcanbeusedbyonenodeduringtraining. 

Allpositiveimagesaresplittedbetweennodes.Generallyminpos 

shouldbenotlessthan 

npos/nsplits.

Errorsandstrangesduringhaartraining!

∙Error(validonlyforDiscreteandRealAdaBoost):

misclass–it’swarning,butnoerror. 

SomeoptionsarespecifictoDandRAdaboost. 

Soyourhaartrainingisok.

∙Screenisfilledwithsuch|1000|25%|-|-1423.312590|1.000000|1.000000|0.876272|–yourtrainingiscycled,restartit.Firstcolumnshouldhavevalue<

100

∙cvAllocfails.Ourofmemory–yougivetoomuchnegativeimagesorsample.vecistoobig.AllthesepicturesareloadedtoRAM.

∙Payattentionyouputthesame-wand-h,asduringvecfilegeneration

∙Payattention,thatnumberofpositivesamplesandnegativesamples,youputin-npos-nnegarereallyavailable

∙Avoidemptylineinnegative.datfile

∙Requiredleaffalsealarmrateachieved.Branchtrainingterminated–it’simpossibletobuildclassifierwithgoodfalsealarmonthisnegativeimages.Checkyournegativeimagesarereall

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1