Homework 7
Computer Vision, Spring 2024
Due Date: April 26, 2024
Total Points: 20
Thishomeworkcontainstwoprogrammingchallenges.Allsubmissionsaredueat
midnightonApril26,2024,andshouldbesubmittedaccordingtotheinstructions
inthedocument“GuidelinesforProgrammingAssignments.pdf”.
runHw7.py willbeyourmaininterfaceforexecutingandtestingyourcode.
Parametersforthedifferentprogramsorunittestscanalsobesetinthatfile.
Beforesubmission,makesureyoucanrunallyourprogramswiththecommand
python runHw7.py withnoerrors.
Thenumpy package isoptimizedforoperationsinvolvingmatricesand
vectors.Avoidusingloops(e.g.,for,while)wheneverpossible—loopingcan
resultinlongrunningcode.Instead,youshould“vectorize”loopstooptimize
yourcodeforperformance.Inmanycases,vectorizationalsoresultsinmore
compactcode(fewerlinestowrite!).
Challenge1: Inthischallengeyouareaskedtodevelopanopticalflowsystem.You
aregivenasequenceof6images(flow1.png– flow6.png)ofadynamicscene.Your
taskistodevelopanalgorithmthatcomputersopticalflowestimatesateachimage
pointusingthe5pairs(1&2,2&3,3&4,4&5,5&6)ofconsecutiveimages.
Opticalflowestimatescanbecomputedusingtheopticalflowconstraintequation
andLucas-Kanadesolutionpresentedinclass.Forsmoothmotions,thisalgorithm
shouldproducerobustflowestimates.However,giventhatthesiximageswere
takenwithfairlylargetimeintervalsinbetweenconsecutiveimages,thebrightness
andtemporalderivativesusedbythealgorithmareexpectedtobeunreliable.
Therefore,youareadvisedtoimplementadifferent(andsimpler)opticalflow
algorithm.Giventwoconsecutiveimages(say1and2),establishcorrespondences
betweenpointsinthetwoimagesusingtemplatematching.Foreachimagepointin
thefirstimage,takeasmallwindow(say7x7)aroundthepointanduseitasthe
templatetofindthesamepointinthesecondimage.Whilesearchingforthe
correspondingpointinthesecondimage,youcanconfinethesearchtoasmall
windowaroundthepixelinthesecondimagethathasthesamecoordinatesasthe
2
oneinthefirstimage.Thecenterofthe7x7imagewindowinthesecondimagethat
ismaximallycorrelatedwiththe7x7windowinthefirstimageisassumedtobethe
correspondingpoint.Thevectorbetweentwocorrespondingpointsistheoptical
flow(u,v).
WriteaprogramcomputeFlow thatcomputesopticalflowbetweentwogray-level
images,andproducestheopticalflowvectorfieldasa“needlemap”ofagiven
resolution,overlaidonthefirstofthetwoimages.
result = computeFlow(img1, img2, win_radius, template_radius,
grid_MN)
Youneedtochooseavalueforthegridspacingthatgivesgoodresultswithout
takingexcessivelylongtocompute.(6 points)
Fordebuggingpurposesusethetestcaseindebug1a.Inthissyntheticcase,theflow
fieldconsistsofhorizontalvectorsofthesamemagnitude(translationalmotion
paralleltotheimageplane).Notethatintherealcase,foreshorteningeffects,
occlusions,andreflectancevariations(aswellasnoise)complicatetheresult.
(2point)
Challenge2: Yourtaskistodevelopavisionsystemthattracksthelocationofan
objectacrossvideoframes.Objecttrackingisachallengingproblemsincean
object’sappearance,poseandscaletendtochangeastimeprogresses.Inclasswe
havediscussedthreepopulartrackingmethods:template-based tracking,
histogram-based trackinganddetection-based tracking.Inthischallenge,wewill
assumethecolordistributionofanobjectstaysrelativelyconstantovertime.
Therefore,wewilltrackanobjectusingitscolorhistogram.
Acolorhistogramdescribesthecolordistributionofacolorimage.Thecolor
histogramthatyouwillneedtocomputeisdefinedasfollows.Eachbinofthecolor
histogramrepresentsarangeofcolors,andthenumberofvotesineachbin
indicatesthenumberofpixelsthathavethecolorswithinthecorrespondingcolor
range.
Becareful,intheinitializationofyourprogram,youshouldgenerateacolormap
fromtheregion ofinterest (ROI),andcomputeallsubsequentcolorhistograms
basedonthesame colormap.Itisonlymeaningfultocomparetwohistograms
computedbasedonthesamecolormap. UsetheprovidedfunctionchooseTarget
todragarectangle aroundatrackingtarget.
3
WriteaprogramnamedtrackingTester thatestimatesthelocationofanobjectin
videoframes.
trackingTester(data_params, tracking_params)
trackingTester shoulddrawaboxaroundthetargetineachvideoframe,and
savealltheannotatedvideoframesasPNGsintoasubfoldergivenin
data_params.out_dir.
Aftergeneratingtheannotatedvideoframes,usetheprovidedfunction
generateVideo tocreateavideofilecontainingalltheframes.
(12points)
Includeallthecodeyouhavewritten,aswellastheresultingvideofiles,but
DONOTincludethethreetrackingdatasetsandtheindividualoutputframes
inyoursubmission.
版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:821613408 微信:horysk8 电子信箱:[email protected]
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。