Sie sind auf Seite 1von 6

Real Time Analysis of

CrowdBehaviourforAutomatic and
Accurate Surveillance

EPadmalatha KaredlaAnanthaSashiSekhar MudiamDasaradaRamReddy


Email:padmalatha@cbit.ac.in Email:sekhar.karedla@gmail.com Email:dachi8958@gmail.com

Abstract— Inthisproposed system,we tryto implementan al-


Surveillanceinthismoderneraisaveryhugedemand.Creatinganal gorithmwhichaccuratelydetectsviolenceinreal-time.
ertincaseofemergenciesandminordisturbancesisofverymuchimp Throughthisalgorithmwetrytoobtainsafersurroundingsandhav
ortance.Asthenumberofsimultaneouscamerafeedsincrease,theb eaquickresponsetimetoviolentincidents.
urdenonthehumansupervisoralsoincreases.Thissystemisawayto
aidthehumansupervisorinthesurveillancejob.Creatingalertsinre 2. PreviousWork
altimemayleadtoveryquickresponsewhichmighthelpustoreactqu
ickly.Withthisinmind,weproposethefollowingthings: 2.1. OpticalFlow
(1)GenerationofViF(ViolentFlowDescriptors)ashigh-
levelfeaturesinrealtime.(2)UsinggeneratedViF’sofaVideoDataset OpticalFlowisthecorepartofViolenceDetection.OpticalFl
fortraininganeuralnetandtestingitsaccuracy.(3)Developingasyst owistherelativemotionbetweentwoimageframeswhicharetake
emthatcandetectthesignsofdisturbanceamongthecrowdinrealti nattimestandt+∆tateverypixelposition.Methodsfordeterminat
meandcanlearnfromthedecisionsitmakes. ionofOpticalFlowcanbelistedasPhase correlation, Block-
based method, Dif-
Keywords— ferentialmethodsandDiscreteOptimizationmethods.The
RealTimeSurveillance,ViolentFlowDescriptors,NeuralNetwork. mostcommonlyusedmethodsareLucasKanadeandHorn-
schunckopticalflowmethods,whichcomeunderDifferen-
tialmethodsbasedonsolvingfirstorderderivative.WeusedCLiu’
1. Introduction s[2]opticalflowalgorithmforourtaskwhichwillbeusedtofurther
obtainFlowVectorMagnitude.SupposeVxandVyarethevelociti
Costofsurveillanceequipmentinthisdigitaleraisalmostnoth esofapixelalongxandyaxisobtainedthroughopticalflowalgorit
ing.AlmostallofthepublicplacesareinstallingCCTVcamerase hm,thentheflowvector
verywheresoastokeepthepublicsafe.BehindtheseCCTVcamer
asarehumanssittingandwatch- 2 2

ingthefootagecontinuouslysoastoreactquicklyincase magnitudecan be obtained as, mt = Vx ,t + V y ,t .C Liu’s


ofemergencies.Thisisaroutineandtediousjobforthehumantoco OpticalflowalgorithmwasoriginallywritteninClanguageandm
ntinuouslypayattentiontomultiplescreens. exfiles werewrittenfor
Asweknowthereisalimittothehumancapacityandability,there compatibilitywithMATLAB.Weusedbobpackage[3]forusingt
maybesomeerrorsinthehumansurveillance.Nomatterhowman hatparticularalgorithminPython.
ysupervisorsarepresent,thereisaninsufficiencyinsuchprocess.
Ifweallocateacomputertodotheabovejob,thealertgenerationm 2.2. ViolentFlowDescriptors
ayaidthehumantoreactquickly.
ViF(ViolentFlowDescriptors)[1]havebeenusedpre-
GenerationofViF[1]isalreadybeenexperimentedpreviousl
viouslytoobtaingloballevelfeaturesofavideo.Afterobtainingth
y.SoastogenerateViF,thereisadetailedprocessthathastobefollo
eflowvectormagnitude(m),wecalculatethebinaryvector.Thisb
wed.Startingwiththevideos,theyhave
inaryvectoriscalculatedforeachpixelwhichreflectsthechangei
nmagnitude.
1, if | mx , y ,t +1 − mx , y ,t |≥ θ
standardaspectratioof3:4andareofverylowquality.As bxthecro
, y ,t =  wdbehavioris completely random, detecting
(1)
breakoutsinthecrowdbecomesarealchallenge.Alsothecontent 0 otherwise
Afterobtainingthebinaryvectorforeachframe,we

ofthevideoisconsideredtobeoriginatedfroma addbinaryvectorswhichareobtainedforalltheframesandnorma
CCTVcamerahenceanyothersourceofinformationsuchassubti lizethevaluewiththenumberofframestakenunderconsideration
tlesandaudiocannotbeused.Continuoussurveillance .
1
systemisofmuchimportanceandverylessattentionisgiventoit.
b x, y = bx, y ,t (2)
T t

978-1-5386-5313-5/18/$31.00 ©2018 IEEE 1469


ThisbgeneratedisdividedintoM*Nnon- 3.2.3. ViolentFlowDescriptors.ViolentFlowDescriptor[1](
overlappingcellsandcollectingmagnitudechangesofeachcellse GlobalFeatures)Algorithmisbeingusedwhichhas been
p- already been implemented previously in
arately.Thesemagnitudechangesarethenrepresentedbyafixeds MATLAB.Soastoincreasethescalabilityofthealgorithm,syste
izehistogram.TheseM*Nhistogramsarefurtherconcatenatedto m hasbeenimplementedthroughbasicmultiprocessingand
obtainasingledescriptorvectorwhichisknownastheViF. threads.ViolentFlow Descriptors use flowvector
magnitudeoutput.Furtheronthenormalizedbinaryvector,histo
gramequalizationforthewholesetofframesunderconsideration
3. Methodology isperformedtoobtainasinglefeaturevector.TheViF’sob-
tainedarethenusedfortrainingandclassificationpurposes.Ifthe
Doingrealtimeautomaticsurveillanceon numberofbinsarefixedas21(0.0to1.0,intervalof0.05)andconsi
CCTVfootagehasmanychallengesandlimitations.Therearetw derbothM,Nas4,thenforastandard
oassumptionswhichwemake,thefirstassumptionistokeeptheca definitionvideoofscale240:320,336featuresareobtained
meraawayfromtheareaundersurveillance,therehastobestandar exactly(21*4*4).Valuesofthese336featuresrangefrom0.0to1.
ddistancebetweentheCCTVcameraand 0.
theareatobemonitored.Themainchallengewefaceistokeepthep
rocessingintermsofreal- 3.3. NeuralNetwork
time,whichmeansalltheprocessinghastobedoneinlessthan1/25
thof 3.3.1. Structure.For
asecond.Oursystemshouldhavetheabilitytohandlemultiplevid thegivendatasetoncetheviolentflowdescriptorsaregenerated,tr
eosourcesatatime.Thishasbeenachievedbycontinuouslyaccep ainingtheneuralnetusingthesefeaturesisdone.Builtfourlayered
tingframesthroughmultiprocessing neuralnet,oneinput
usingthreads.FirstpartiswecalculatetheOpticalflowwhichisth layer,twodenselayersandoneoutputlayer.Inputlayeraccepts
emosttimeconsumingofalltheprocesses.Then 350inputsand gives336 outputs.Middle
weusethecalculatedopticalflowtoobtainflowvectormagnitude. denselayersaccept336inputsandgive336outputs.Outputlayera
NextwegenerateViFwhicharefurtherusedfortrainingandclassi ccepts336inputsandgives1output.ForinputanddenselayersRe
fication. LU(Rectifier Linear Unit) activation function is
usedandfortheoutputlayerSigmoidfunctionisbeing used.
3.1. Algorithm
3.3.2. Training.ForbuildingneuralnetKeras[6]andTensorflo
w[5]arebeingused.Initiallythedataneedstobeformattedsothatit
Themainpartofbuildingthesystem isto fitsintoinputlayerofNeuralNet.
haveawellbuiltalgorithm.Firstthevideoispreprocessed,thenwe TheViolentFlowFeaturesgeneratedforeachvideowillbeinthef
calculatetheopticalflowwhichismosttimecon- ormatofnumpyarrayofdimensions336*1.Arrayisreshapedinto
suming.FeatureExtractionisdonenextwhichisusedfortrainingt 1*336dimensions,sothatthefeaturesof
heneuralnet.Soastomakethesystemscalableformultiplevideos singlevideofitintotheinputlayerofneuralnetasonedatatuple.Fu
ources,wehaveembeddedthreadingandmulti- rther,concatenationofreshapedfeaturearrayofeachvideointoas
processing.Thebuiltalgorithmisrobustandcanhandlefaultyvid inglearrayisdonesothatthefinalinputtotheneuralnetwillbeanar
eosources. rayofdimensions246*336as
thereare246videos(violentandnon-violent)inthedataset.
3.2. GlobalFeatureExtraction Ontheotherhand,preknownoutputs(0(non-violent)or
1(violent))ofeachvideoarestoredinanarrayofdimensions
246*1totrainneuralnetandtocalculateaccuracy.Afterdataisrea
3.2.1. VideoPreprocessing.Videocomingfromsourceisprepr dywecanproceedtobuildtheneuralnetintothestructuremention
ocessed.Consideringthevideoaspectratioas3:4.Thesurveillanc edabove.UsingKerasSequentialneuralnetwithdenselayerscan
efootageisconsidertobestandarddefinition(scale=240:320).T bebuilt
heinputframescominginareresized .Amodeliscompiledforwhichwemustspecifya
to75:100sizeandthenconvertedtograyscale.Thelengthandbrea logarithmiclossfunctionwhichevaluatesasetofweightsandalso
dthofthevideosarealmostreducedbyone-third. anoptimizertosetlearningrate.Kerashasa
ForvideoprocessingOpenCV[7]packagehasbeenused. logarithmiclossfunctionforbinaryclassificationproblemdefine
dasbinary-
3.2.2. OpticalFlow.Ce.Liu[2]optical crossentropyandAdamOptimizerwhichisbestoptimizer.Numb
flowalgorithmhasbeenusedtocalculatetheopticalflow.Thisalg erofepochsforwhichthetrainingmustbecarriedoutisgiven,batc
orithmhasbeenusedparticularlysinceitishighlyefficientandrob hsize(numberofinstancesevaluatedtoperformweightchanges)
ust.Itreturnsthreevalues,vx(velocityvectoralongx- andtheinputdatafortrainingthemodelareprovidedasparameter
axis),vy(velocityvectoralongy- s.Trainedmodelisstoredintoafileofhd5formatusinghdpypytho
axis)andw(wrap).Thevectorsareinthesameshapeoftheresizedf npackage.
ramewidthandheight.

1470
3.3.3. ViolenceDetection.Thisphaseinvolvesdetectionofdist
urbanceorviolenceinlivecrowdsurveillancevideosinrealtime.
TheinputsurveillancevideoispreprocessedandViolentFlowDe
scriptorsaregenerateddynamicallyinRealTime.Foreachsecon
dofvideo,featuresareextractedandaregivenasinputtothetraine
dmodelforclassificationandviolencedetection.Ifsomedisturba
nceorviolenceis
detected,itwillbereportedasanalertstatingthatitis
violencealongwiththetimeithasoccurredwithinasecond
ofoccurrence.

3.3.4. Feedback.IntheViolenceDetectionphase,astherealtim
esurveillancetakesplace,thefeaturesgeneratedforeverysecond
aretestedagainsttrainedmodelforclassifi-
cationandviolencedetection.Thosefeatures,alongwith
theiractualoutput(providedbyhuman)generatedbythetrainedm
odelaregivenasfeedbacktothemodel.Thisallowscontinuoustra
iningofneuralnetmodelwhichhelpstoincreasetheaccuracyofcl
assificationandalsofasterdetectionofviolence.
Figure1.ProcessingSpeedswithIntelCentrinoProcessor
3.4. ExtractionofInterestingFeatures

AdaBoostisanensembleofweakclassifiers.AdaBoost
isanalgorithmwhichcouldtellustheimportantsetof
featuresthathelpusclassifyourfeatures.ForthistheFeatureSelec
tionAlgorithmthroughAdaBoost[4]isused.
Oncethefeaturesarearrangedinincreasingorderofthe
errorrates,wecanobtainthefeaturesamongtotal336
featureswhicharehighlyefficientinclassifyingvideos.Theweak
classifiersusedherearedecisionstumps(decisiontreeofheight1)
.

4. Implementation

Inthebelowsubsectionsweprovidetheimplementationdetai
lsandtheoutputsanalysis.Clearanalysisofthesystem
willbedoneinthenextsection.

4.1. ContinuousSurveillance
Figure2.ProcessingSpeedswithInteli5Processor

Weusedtwosetsofconfigurationsforcalculatingpro-
cessingspeedsofthesystem.FirstConfigurationconsistsof
4GBRAM,IntelCentrinoProcessorwithUbuntuOS.Sec- Abovearetwofiguresshowingtherunningtimeofthesystem.
ondConfigurationconsistsof8GBRAM,Inteli5Processor Thetotallengthofvideotakenunderconsiderationisnearly200se
withDebianOS. conds.Proposedsystemisabletodetectthe
Foravideowhichisnotinitiallyviolentbutlateronbecomesvi exactsecondofviolenceoccurrencei.ewheretheframesgofromn
olent,theproposedsystemisabletodetectthe on-
exactinstancewherethevideoframesgofromviolenttonon- violenttoviolent.WithIntelcentrinoprocessorFig.1,theprocess
violent.ConsideringReal- ingisbeingcompletednearlyin180
TimeCCTVfeed,withinasecondofoccurrenceofviolenceoursy seconds(20secondsfasterthanruntimeofvideo).WithInteli5pro
steminabledetect theviolenceandraiseanalert. cessorFig.2,theprocessingofentirevideoisbeingdonenearlyin1
40seconds(1minutefasterthanruntimeofvideo).Witheachdete
ctionofviolenceoutbreak,

1471
thecorrespondingtimetakenbythesystemtodetectthatisbeingsh maximumaccuracy.Themaximumobtainedisnearly96%andmini
own. mumaccuracyisof73%.

4.2. Accuracy

TheaccuracyobtainedbyViF’s[1]asglobalfeaturesusingali
nearSVMis81.30%forexistingsystem.Proposedsystemhasana
ccuracyofnearly85%.

Figure5.AccuracyObtainedbytrainingwith70%ofdataandtestingwith30%ofdata

p n
Figure3.BarPlotofObtainedAccuracyValuesinNFolds P 33 2
N 5 32
TABLE1.C ONFUSION MATRIXFOR 70:30 DATASET

ThebargraphinFig.3showstheresultofN-foldscross
verificationwithN=7.Therearetotal5runs(executionofn- Thedatasetwhichcontains246videosisdividedintheratioof
foldsonceinarun).Ineachrunweconsider7heapsin 70:30.70%ofthedataisusedtotraintheneural
total.Eachheapcontainingequalnumberofvideos.Among net,30%ofthedataisusedtotesttheaccuracyofgeneratedmodel.
thesevideosviolentandnon- OutputinFig.5showsthattheaccuracyobtainedis90.27%.Aswe
violentvideosaredistributedevenly.ViolentandNonViolentvid canseetheconfusionmatrixinTable1,thenumberofFalseNegati
eosareplacedrandomlyinheaps.Thisgivesusanideahowrobustt vesarejust2,thatmeansthereareonly2casesinthetestsetwhichar
heproposedsystemis.Theminimumaccuracyweobtainforahea eactuallyviolentbutoursystemwasnotabletodetectit.Whereast
pinanyrunisgreaterthan70%. herewere5casesinwhichvideoswerenotviolentbutoursystemd
etectedsomeviolence.
Followingaretheresultsobtained:
• Accuracy=TP/(total)=0.9027
• TruePositiveRate=TP/(Positives)=0.9428
• Precision=TP/(Predictedyes)=0.8684
• Specificity=TN/(Actualno)=0.8648
• MisclassificationRate=(FP+FN)/(total)=0.097
Theaboveaccuracytestsweredoneonadataset[1]containing
246videos.ShortestVideoisof1secondandLongestVideoisof6s
econds.Thesecollectionsofvideoshaveequalnumberofviolent
andnon-
violentvideos.Thiskindofdatasetisknownas”inthewild”datase
t.VideospresentinthedatasetareofstandardCCTVresolution(sc
ale
Figure4.LinePlotofObtainedAccuracyValuesinNFolds =240:320)andofsimilaraspectratio(3:4).

5. ResultsandDiscussion
Fig.4showsthelinegraph,itissame asFig. Considerthefollowingscenesobtainedthroughsurveillance
4,butgivesustheclearpictureofaccuraciesofeachsetinitscorres footage:
pondingrun.Eachrunhasbeenassignedadifferentcolor.Fromthi
swecanclearlyidentifytheminimumand

1472
Figure6.ViolenceNotstarted Figure9.Violencefuriouslystarted

Aboveare4figureswhichshowfourdifferentphasesofsurvei
llancevideo.InitiallyinFig.6,Violencehasnotyetstarted.InFig.7
Violenceisabouttostart,peopleareslightlypushingeachother.Fi
g.8showsthestartofviolenceandinFig.9Violencehasstartedfuri
ously.

Figure7.Violenceabouttostart
Figure10.TerminalOutputforthevideo

InFig.10,itshowstheoutputofthesystemfortheparticularvid
eoshowninpreviousfigures.Aswecanseefortheinitialframe,out
putvalueisveryless,asthescenegets tense in Fig. 7, the system
output value increases. When
theviolencestartsinFig.9,outputvalueincreasesto0.999
indicatingviolence.Lateroninthevideoviolencedecreases
graduallyandhencetheoutputvaluefallsdownto0.06.

6. ConclusionandFurtherWork
Timelydetectionofviolenceinrealtimeisofmuchimportanc
e.System’sabilitytodetectviolencewithinasecondisimportantb
ecausethedifferencebetween
thetimeofoccurrenceandthetimeofdetectionmaybethe
differencebetweenlifeanddeath.Resultshaveshownthatsystem
Figure8.Violenceslightlystarted isperformingfastenoughtodetectoutbreaksinrealtime.Thissyst
em’slearningcapabilitiesandaccuracycanbefurtherimprovedt
hroughAdaBoost.Whateverworkhasbeendoneistogiveattentio
nandimportancetoaccuraterealtimesurveillance.Thissystemof
coursemaynotreplacehumansattheirjobbutwillgreatlyreducet
heburdenon

1473
them.Thiswillgivehumanstheabilitytomonitormultipleareasatatim
e.
Furthertheaccuracycanbegreatlyimprovedbyusingtheresu
ltsofFeatureSelectionalgorithmofAdaBoost[4].
Asexplainedabove,oncewearrangethefeaturesinincreas-
ingorderoftheirerrorrate,wegetorderofimportanceof
336features.Inthatparticularorder,wecanassociatetheweights
ofinputlayerinneuralnet.Thefeatureswhichare
highlyimportantcanhaveahigherweightattheirinputnodeandas
theimportancedecreases,weightscanalsobedecreased.Thisma
ymakeadifferenceinincreasingtheaccuracyofneuralnet.

Acknowledgments
WewouldliketothankDr.THassner[1]forhiscon-
tributionstowardsrealtimesurveillance,thisprojectwouldnotha
vebeenpossiblewithoutthegenerationofViolentFlowDescripto
rs(VIFs).

References
[1]T.Hassner,Y.Itcher,O.KliperGross.ViolentFlows:Real-
TimeDetectionofViolentCrowdBehavior,3rdIEEEInternationalWork-
shoponSocially Intelligent Surveillanceand Monitoring
(SISM)attheIEEEConf.onComputerVisionandPatternRecognition(CV
PR),June2012
[2]Ce.Liu.BeyondPixels:ExploringNewRepresentationsandApplica-
tionsforMotionAnalysis,MassachusettsInstituteofTechnology,Ph.D.
Thesis,2009
[3]Anjos,AndréANDElShafey,LaurentANDWallace,RoyAND Günther,
ManuelAND McCool,Christopher ANDMarcel, Sébastien.
Bob:afreesignalprocessingandmachinelearningtoolboxforre-
searchers,20thACMConferenceonMultimediaSystems(ACMMM),
NaraJapan,2012
[4]RuihuWang.AdaBoostforFeatureSelection,ClassificationandItsRelationw
ith SVM,A Review, Department ofScienceand
TechnologyChongqingUniversityofArtsandSciencesYongchuan,Chon
gqing402160,CHINA
[5]MartnAbadi,AshishAgarwal, Paul Barham,EugeneBrevdo,
ZhifengChen,CraigCitro,GregS.Corrado,AndyDavis,JeffreyDean,Mat
thieuDevin,SanjayGhemawat,IanGoodfellow,AndrewHarp,GeoffreyIr
ving,MichaelIsard,RafalJozefowicz,YangqingJia,LukaszKaiser,Manju
nathKudlur,JoshLevenberg,DanMan,MikeSchuster,RajatMonga,Sherr
yMoore,DerekMurray,ChrisOlah,JonathonShlens,BenoitSteiner,IlyaS
utskever,KunalTalwar,PaulTucker,VincentVanhoucke,VijayVasudevan,
FernandaVigas,OriolVinyals,PeteWarden,MartinWattenberg,MartinWi
cke,YuanYu,andXiaoqiangZheng.TensorFlow:Large-
scalemachinelearningonheterogeneoussystems,2015.Sourceavailablea
thttps://www.tensorflow.org
[6] Chollet,Françoisandothers.Keras,2015.Sourceavailableathttps:
//keras.io
[7]
Itseez.OpenSourceComputerVisionLibrary,2015.Sourceavailableathttp
s://github.com/itseez/opencv

1474

Das könnte Ihnen auch gefallen