Skip to content

Commit 8ec34d7

Browse files
committed
blaze_detect_live.py: Add new argument for specify video input (ie. /dev/video#).
1 parent fd2e99a commit 8ec34d7

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

blaze_detect_live.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ def get_video_dev_by_name(src):
149149

150150
# construct the argument parser and parse the arguments
151151
ap = argparse.ArgumentParser()
152-
ap.add_argument('-i', '--image' , default=False, action='store_true', help="Use 'womand_hands.jpg' image as input. Default is usbcam")
152+
ap.add_argument('-i', '--input' , type=str, default="", help="Video input device. Default is auto-detect (first usbcam)")
153+
ap.add_argument('-I', '--image' , default=False, action='store_true', help="Use 'womand_hands.jpg' image as input. Default is usbcam")
153154
ap.add_argument('-b', '--blaze' , type=str, default="hand,face,pose", help="Command seperated list of targets (hand, face, pose). Default is 'hand, face, pose'")
154155
ap.add_argument('-t', '--target' , type=str, default="blaze_tflite,blaze_pytorch,blaze_vitisai,blaze_hailo", help="Command seperated list of targets (blaze_tflite, blaze_pytorch, blaze_vitisai). Default is 'blaze_tflite,blaze_pytorch,blaze_vitisai,blaze_hailo'")
155156
ap.add_argument('-p', '--pipeline' , type=str, default="all", help="Command seperated list of pipelines (Use --list to get list of targets). Default is 'all'")
@@ -162,6 +163,7 @@ def get_video_dev_by_name(src):
162163
args = ap.parse_args()
163164

164165
print('Command line options:')
166+
print(' --input : ', args.input)
165167
print(' --image : ', args.image)
166168
print(' --blaze : ', args.blaze)
167169
print(' --target : ', args.target)
@@ -218,7 +220,9 @@ def get_video_dev_by_name(src):
218220
print(dev_media)
219221

220222
if dev_video == None:
221-
input_video = 0
223+
input_video = 0
224+
elif args.input != "":
225+
input_video = args.input
222226
else:
223227
input_video = dev_video
224228
print("[INFO] Input Video : ",input_video)

blaze_hailo/blaze_detect_live.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def get_video_dev_by_name(src):
8484

8585
# construct the argument parser and parse the arguments
8686
ap = argparse.ArgumentParser()
87-
ap.add_argument('-i', '--image' , default=False, action='store_true', help="Use 'womand_hands.jpg' image as input. Default is usbcam")
87+
ap.add_argument('-i', '--input' , type=str, default="", help="Video input device. Default is auto-detect (first usbcam)")
88+
ap.add_argument('-I', '--image' , default=False, action='store_true', help="Use 'womand_hands.jpg' image as input. Default is usbcam")
8889
ap.add_argument('-b', '--blaze', type=str, default="hand", help="Application (hand, face, pose). Default is hand")
8990
ap.add_argument('-m', '--model1', type=str, help='Path of blazepalm model. Default is models/palm_detection_lite.hef')
9091
ap.add_argument('-n', '--model2', type=str, help='Path of blazehandlardmark model. Default is models/hand_landmark_lite.hef')
@@ -96,6 +97,7 @@ def get_video_dev_by_name(src):
9697
args = ap.parse_args()
9798

9899
print('Command line options:')
100+
print(' --input : ', args.input)
99101
print(' --image : ', args.image)
100102
print(' --blaze : ', args.blaze)
101103
print(' --model1 : ', args.model1)
@@ -114,7 +116,9 @@ def get_video_dev_by_name(src):
114116
print(dev_media)
115117

116118
if dev_video == None:
117-
input_video = 0
119+
input_video = 0
120+
elif args.input != "":
121+
input_video = args.input
118122
else:
119123
input_video = dev_video
120124
print("[INFO] Input Video : ",input_video)

blaze_pytorch/blaze_detect_live.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def get_video_dev_by_name(src):
8282

8383
# construct the argument parser and parse the arguments
8484
ap = argparse.ArgumentParser()
85-
ap.add_argument('-i', '--image' , default=False, action='store_true', help="Use 'womand_hands.jpg' image as input. Default is usbcam")
85+
ap.add_argument('-i', '--input' , type=str, default="", help="Video input device. Default is auto-detect (first usbcam)")
86+
ap.add_argument('-I', '--image' , default=False, action='store_true', help="Use 'womand_hands.jpg' image as input. Default is usbcam")
8687
ap.add_argument('-b', '--blaze', type=str, default="hand", help="Application (hand, face, pose). Default is hand")
8788
ap.add_argument('-m', '--model1', type=str, help='Path of blazepalm model. Default is models/blazepalm.pth')
8889
ap.add_argument('-n', '--model2', type=str, help='Path of blazehandlardmark model. Default is models/blazehand_landmark.pth')
@@ -94,6 +95,7 @@ def get_video_dev_by_name(src):
9495
args = ap.parse_args()
9596

9697
print('Command line options:')
98+
print(' --input : ', args.input)
9799
print(' --image : ', args.image)
98100
print(' --blaze : ', args.blaze)
99101
print(' --model1 : ', args.model1)
@@ -112,7 +114,9 @@ def get_video_dev_by_name(src):
112114
print(dev_media)
113115

114116
if dev_video == None:
115-
input_video = 0
117+
input_video = 0
118+
elif args.input != "":
119+
input_video = args.input
116120
else:
117121
input_video = dev_video
118122
print("[INFO] Input Video : ",input_video)

blaze_tflite/blaze_detect_live.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def get_video_dev_by_name(src):
8484

8585
# construct the argument parser and parse the arguments
8686
ap = argparse.ArgumentParser()
87-
ap.add_argument('-i', '--image' , default=False, action='store_true', help="Use 'womand_hands.jpg' image as input. Default is usbcam")
87+
ap.add_argument('-i', '--input' , type=str, default="", help="Video input device. Default is auto-detect (first usbcam)")
88+
ap.add_argument('-I', '--image' , default=False, action='store_true', help="Use 'womand_hands.jpg' image as input. Default is usbcam")
8889
ap.add_argument('-b', '--blaze', type=str, default="hand", help="Application (hand, face, pose). Default is hand")
8990
ap.add_argument('-m', '--model1', type=str, help='Path of blazepalm model. Default is models/palm_detection_without_custom_op.tflite')
9091
ap.add_argument('-n', '--model2', type=str, help='Path of blazehandlardmark model. Default is models/hand_landmark.tflite')
@@ -96,6 +97,7 @@ def get_video_dev_by_name(src):
9697
args = ap.parse_args()
9798

9899
print('Command line options:')
100+
print(' --input : ', args.input)
99101
print(' --image : ', args.image)
100102
print(' --blaze : ', args.blaze)
101103
print(' --model1 : ', args.model1)
@@ -114,7 +116,9 @@ def get_video_dev_by_name(src):
114116
print(dev_media)
115117

116118
if dev_video == None:
117-
input_video = 0
119+
input_video = 0
120+
elif args.input != "":
121+
input_video = args.input
118122
else:
119123
input_video = dev_video
120124
print("[INFO] Input Video : ",input_video)

blaze_vitisai/blaze_detect_live.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ def detect_dpu_architecture():
9999

100100
# construct the argument parser and parse the arguments
101101
ap = argparse.ArgumentParser()
102-
ap.add_argument('-i', '--image' , default=False, action='store_true', help="Use 'womand_hands.jpg' image as input. Default is usbcam")
102+
ap.add_argument('-i', '--input' , type=str, default="", help="Video input device. Default is auto-detect (first usbcam)")
103+
ap.add_argument('-I', '--image' , default=False, action='store_true', help="Use 'womand_hands.jpg' image as input. Default is usbcam")
103104
ap.add_argument('-b', '--blaze', type=str, default="hand", help="Application (hand, face, pose). Default is hand")
104105
ap.add_argument('-m', '--model1', type=str, help='Path of blazepalm model. Default is '+blazepalm_model)
105106
ap.add_argument('-n', '--model2', type=str, help='Path of blazehandlardmark model. Default is '+blazehandlandmark_model)
@@ -111,6 +112,7 @@ def detect_dpu_architecture():
111112
args = ap.parse_args()
112113

113114
print('Command line options:')
115+
print(' --input : ', args.input)
114116
print(' --image : ', args.image)
115117
print(' --blaze : ', args.blaze)
116118
print(' --model1 : ', args.model1)
@@ -129,7 +131,9 @@ def detect_dpu_architecture():
129131
print(dev_media)
130132

131133
if dev_video == None:
132-
input_video = 0
134+
input_video = 0
135+
elif args.input != "":
136+
input_video = args.input
133137
else:
134138
input_video = dev_video
135139
print("[INFO] Input Video : ",input_video)

0 commit comments

Comments
 (0)