<s> '''<STR_LIT>''' <EOL> import unittest <EOL> import os . path <EOL> import pyvision as pv <EOL> BUGS_VIDEO = os . path . join ( pv . __path__ [ <NUM_LIT:0> ] , '<STR_LIT:data>' , '<STR_LIT:test>' , '<STR_LIT>' ) <EOL> TAZ_VIDEO = os . path . join ( pv . __path__ [ <NUM_LIT:0> ] , '<STR_LIT:data>' , '<STR_LIT:test>' , '<STR_LIT>' ) <EOL> TOYCAR_VIDEO = os . path . join ( pv . __path__ [ <NUM_LIT:0> ] , '<STR_LIT:data>' , '<STR_LIT:test>' , '<STR_LIT>' ) <EOL> class MotionDetectTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> pass <EOL> def tearDown ( self ) : <EOL> pass <EOL> def testMotionDetectAMF ( self ) : <EOL> ilog = None <EOL> md = pv . MotionDetector ( method = pv . BG_SUBTRACT_AMF , minArea = <NUM_LIT:200> ) <EOL> video = pv . Video ( BUGS_VIDEO ) <EOL> i = <NUM_LIT:0> <EOL> for frame in video : <EOL> _ = md . detect ( frame ) <EOL> _ = md . getStandardizedRects ( ) <EOL> _ = md . getBoundingRects ( ) <EOL> _ = md . getPolygons ( return_all = True ) <EOL> if ilog != None : <EOL> print "<STR_LIT>" , i <EOL> key_frame = md . getKeyFrame ( ) <EOL> md . annotateFrame ( key_frame ) <EOL> if key_frame != None : <EOL> ilog ( key_frame , format = '<STR_LIT>' ) <EOL> i += <NUM_LIT:1> <EOL> if i > <NUM_LIT:20> : break <EOL> if ilog != None : <EOL> ilog . show ( ) <EOL> def testMotionDetectMF ( self ) : <EOL> ilog = None <EOL> md = pv . MotionDetector ( method = pv . BG_SUBTRACT_MF , minArea = <NUM_LIT:200> ) <EOL> video = pv . Video ( BUGS_VIDEO ) <EOL> i = <NUM_LIT:0> <EOL> for frame in video : <EOL> _ = md . detect ( frame ) <EOL> _ = md . getStandardizedRects ( ) <EOL> _ = md . getBoundingRects ( ) <EOL> _ = md . getPolygons ( return_all = True ) <EOL> if ilog != None : <EOL> print "<STR_LIT>" , i <EOL> key_frame = md . getKeyFrame ( ) <EOL> md . annotateFrame ( key_frame ) <EOL> if key_frame != None : <EOL> ilog ( key_frame , format = '<STR_LIT>' ) <EOL> i += <NUM_LIT:1> <EOL> if i > <NUM_LIT:20> : break <EOL> if ilog != None : <EOL> ilog . show ( ) <EOL> def testMotionDetectFD ( self ) : <EOL> ilog = None <EOL> md = pv . MotionDetector ( method = pv . BG_SUBTRACT_FD , minArea = <NUM_LIT:200> ) <EOL> video = pv . Video ( BUGS_VIDEO ) <EOL> i = <NUM_LIT:0> <EOL> for frame in video : <EOL> _ = md . detect ( frame ) <EOL> _ = md . getStandardizedRects ( ) <EOL> _ = md . getBoundingRects ( ) <EOL> _ = md . getPolygons ( return_all = True ) <EOL> if ilog != None : <EOL> print "<STR_LIT>" , i <EOL> key_frame = md . getKeyFrame ( ) <EOL> md . annotateFrame ( key_frame ) <EOL> if key_frame != None : <EOL> ilog ( key_frame , format = '<STR_LIT>' ) <EOL> i += <NUM_LIT:1> <EOL> if i > <NUM_LIT:20> : break <EOL> if ilog != None : <EOL> ilog . show ( ) <EOL> def testMotionDetectMCFD ( self ) : <EOL> ilog = None <EOL> md = pv . MotionDetector ( method = pv . BG_SUBTRACT_MCFD , minArea = <NUM_LIT:200> , rect_type = pv . STANDARDIZED_RECTS ) <EOL> video = pv . Video ( TOYCAR_VIDEO ) <EOL> i = <NUM_LIT:0> <EOL> for frame in video : <EOL> md . detect ( frame ) <EOL> if ilog != None : <EOL> print "<STR_LIT>" , i <EOL> key_frame = md . getKeyFrame ( ) <EOL> md . annotateFrame ( key_frame ) <EOL> if key_frame != None : <EOL> ilog ( key_frame , format = '<STR_LIT>' ) <EOL> i += <NUM_LIT:1> <EOL> if ilog != None : <EOL> ilog . show ( ) <EOL> class OpticalFlowTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> pass <EOL> def tearDown ( self ) : <EOL> pass <EOL> def testOpticalFlow ( self ) : <EOL> ilog = None <EOL> flow = pv . OpticalFlow ( ) <EOL> video = pv . Video ( TAZ_VIDEO ) <EOL> i = <NUM_LIT:0> <EOL> for frame in video : <EOL> flow . update ( frame ) <EOL> flow . annotateFrame ( frame ) <EOL> if ilog != None : <EOL> print "<STR_LIT>" , i <EOL> ilog ( frame , format = '<STR_LIT>' ) <EOL> i += <NUM_LIT:1> <EOL> if i > <NUM_LIT:10> : break <EOL> if ilog != None : <EOL> ilog . show ( ) <EOL> def testHomographies ( self ) : <EOL> ilog = None <EOL> flow = pv . OpticalFlow ( ) <EOL> video = pv . Video ( TAZ_VIDEO ) <EOL> i = <NUM_LIT:0> <EOL> prev_frame = None <EOL> for frame in video : <EOL> flow . update ( frame ) <EOL> flow . annotateFrame ( frame ) <EOL> if ilog != None : <EOL> print "<STR_LIT>" , i <EOL> if hasattr ( frame , '<STR_LIT>' ) : <EOL> prev_im = frame . to_prev ( frame ) <EOL> ilog ( prev_im , '<STR_LIT>' , format = '<STR_LIT>' ) <EOL> if prev_frame != None : <EOL> forward_im = prev_frame . to_next ( prev_frame ) <EOL> ilog ( forward_im , '<STR_LIT>' , format = '<STR_LIT>' ) <EOL> ilog ( frame , "<STR_LIT>" , format = '<STR_LIT>' ) <EOL> i += <NUM_LIT:1> <EOL> if i > <NUM_LIT:10> : break <EOL> prev_frame = frame <EOL> if ilog != None : <EOL> ilog . show ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( testRunner = unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) ) </s>
