Question: : = , + Code + Text Q v v MotionDetection class def ( self , num _ sigmas = 4 . , discount =
: Code Text
Q MotionDetection class
def self numsigmas discount:
Motion detection implemented via averagerator.
@param numsigmas: by how many standard deviations should a pixel
differ from the average for motion to be detected. This is
the kappa of the above explanation.
@param discount: discount factor for the averagerator.
self.numsigmas numsigmas
self.discount discount
self. average None
def detectmotionself img:
Detects motion.
@param img: an image.
areturns: an boolean matrix, indicating where motion occurred.
A pixel is considered a motion pixel if one of its color bands deviates
by more than numsigmas standard deviations from the average.""."
if self.average is None:
self. average loatimg
return npzeroslikeimg dtypebool
diff absnpfloatimg self.average
diffthreshold self.numsigmas npstddiff axis keepdimsTrue
motionmask any diff diffthreshold, axis
self.average self.discount self.average self.discount
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
