Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/init-tracking.py @ 1021:16932cefabc1
work on paths in line with new configurations from tracker
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Tue, 05 Jun 2018 17:02:28 -0400 |
| parents | 933670761a57 |
| children | cc5cb04b04b0 |
comparison
equal
deleted
inserted
replaced
| 1020:9fb82fe0156f | 1021:16932cefabc1 |
|---|---|
| 9 # check if there is already a tracking.cfg file | 9 # check if there is already a tracking.cfg file |
| 10 | 10 |
| 11 parser = argparse.ArgumentParser(description='The program initilizes the files for tracking: copy tracking.cfg, sets up with the video filename, generates a frame image (frame.png) and prints the next commands') | 11 parser = argparse.ArgumentParser(description='The program initilizes the files for tracking: copy tracking.cfg, sets up with the video filename, generates a frame image (frame.png) and prints the next commands') |
| 12 | 12 |
| 13 parser.add_argument('-i', dest = 'videoFilename', help = 'filename of the video sequence', required = True) | 13 parser.add_argument('-i', dest = 'videoFilename', help = 'filename of the video sequence', required = True) |
| 14 parser.add_argument('-n', dest = 'nFrames', help = 'number of frames to extract', type = int) | |
| 14 | 15 |
| 15 args = parser.parse_args() | 16 args = parser.parse_args() |
| 16 | 17 |
| 17 # assumes tracking.cfg is in the parent directory to the directory of the traffic intelligence python modules | 18 # assumes tracking.cfg is in the parent directory to the directory of the traffic intelligence python modules |
| 18 matchingPaths = [s for s in sys.path if 'traffic-intelligence' in s] | 19 matchingPaths = [s for s in sys.path if 'traffic-intelligence' in s] |
| 43 if os.path.exists(directoryName+'/../classifier.cfg') and not os.path.exists('./classifier.cfg'): | 44 if os.path.exists(directoryName+'/../classifier.cfg') and not os.path.exists('./classifier.cfg'): |
| 44 copy(directoryName+'/../classifier.cfg', 'classifier.cfg') | 45 copy(directoryName+'/../classifier.cfg', 'classifier.cfg') |
| 45 print('Configuration file classifier.cfg successfully copied to the current directory') | 46 print('Configuration file classifier.cfg successfully copied to the current directory') |
| 46 | 47 |
| 47 # extract image from video | 48 # extract image from video |
| 48 image = getImagesFromVideo(args.videoFilename, saveImage = True, outputPrefix = 'frame') | 49 if args.nFrames is not None: |
| 50 image = getImagesFromVideo(args.videoFilename, 0, args.nFrames, saveImage = True, outputPrefix = 'frame') | |
| 51 else: | |
| 52 image = getImagesFromVideo(args.videoFilename, saveImage = True, outputPrefix = 'frame') | |
| 49 print('first video frame successfully copied to the current directory') | 53 print('first video frame successfully copied to the current directory') |
| 50 | 54 |
| 51 # next commands | 55 # next commands |
| 52 print('--------------------------------------\nHere are a sample of the next command to compute the homography,\ntrack features, group them in objects and display object trajectories\n--------------------------------------') | 56 print('''-------------------------------------- |
| 53 print('compute_homography -i [frame.png] -w [world_image] -n [npoints] -u [unit_per_pixel]') | 57 Here are a sample of the next command to compute the homography, |
| 58 track features, group them in objects and display object trajectories | |
| 59 --------------------------------------''') | |
| 60 print('compute-homography -i [frame.png] -w [world_image] -n [npoints] -u [unit_per_pixel]') | |
| 61 print('(beware of camera distortion)') | |
| 54 print('feature-based-tracking tracking.cfg --tf') | 62 print('feature-based-tracking tracking.cfg --tf') |
| 55 print('feature-based-tracking tracking.cfg --gf') | 63 print('feature-based-tracking tracking.cfg --gf') |
| 56 print('display-trajectories --cfg tracking.cfg -t object') | 64 print('display-trajectories --cfg tracking.cfg -t object') |
