forked from joseaccruz/SimpleMouseTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_data.py
More file actions
50 lines (37 loc) · 2.11 KB
/
get_data.py
File metadata and controls
50 lines (37 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
import argparse
from tracker.analysis import *
from tracker.command import *
from tracker.data import *
from tracker.utils import *
# Mandatory function to work with 'generic_gui' module. Should return a fully parametrized 'Command' object.
def cfg():
command = Command( "Track" )
command.add_arg( Argument( name="Project File", atype="dir", cmd_name="project", desc="project directory name" ) )
command.add_arg( Argument( name="Show Video", atype="bool", cmd_name="--show_video", cmd_option="-s", default=True, desc="show the video while processing." ) )
command.add_arg( Argument( name="Frame delay", atype="int", cmd_name="--delay", cmd_option="-d", default=1, minimum=0, maximum=100000, desc="set the delay between frames (ms)." ) )
command.add_arg( Argument( name="Jump to frame", atype="int", cmd_name="--jump", cmd_option="-j", default=0, minimum=0, maximum=100000, desc="jump to a specific frame." ) )
command.add_arg( Argument( name="Fade margin", atype="bool", cmd_name="--fade_margin", cmd_option="-f", default=True, desc="Paint the mask border with a margin average color." ) )
return command
# Mandatory function to work with 'generic_gui' module. Receives the arguments as they were entered on the gui or in the command line
def run( args, io ):
# open the project
check_dir( io, args.project, "Project File" )
prj = Project( args.project )
print args.fade_margin
# analyses the video file
frame_data = detect( io, prj.video_file, prj.thresh, prj.laser, prj.poly, args.show_video, args.delay, args.jump, args.fade_margin )
# Try to fix the head-tail choices
#show( "Fixing the data. Wait a few seconds, please...\n" )
#frame_data = analysis.fix( frame_data )
# save the frame data
frame_data.save( prj.data_file )
io.show( "Data saved to '%s'.\n" %prj.data_file )
cv2.destroyAllWindows()
#
# If the script is called directly from the command line
#
if __name__ == "__main__":
# get the arguments from the command line
args = cfg().get_parser().parse_args()
run( args, InOutTerminal() )