diff --git a/models/handpose_estimation_mediapipe/demo.py b/models/handpose_estimation_mediapipe/demo.py index 37c3cf03..b130cb35 100644 --- a/models/handpose_estimation_mediapipe/demo.py +++ b/models/handpose_estimation_mediapipe/demo.py @@ -285,9 +285,11 @@ def classify(self, landmarks): confThreshold=args.conf_threshold, backendId=backend_id, targetId=target_id) + + + #if Input is NOT a digit(i.e input is a file path like thumbs up) + if args.input is not None and not args.input.isdigit(): - # If input is an image - if args.input is not None: image = cv.imread(args.input) # Palm detector inference @@ -319,8 +321,11 @@ def classify(self, landmarks): cv.imshow(args.input, image) cv.imshow('3D HandPose Demo', view_3d) cv.waitKey(0) - else: # Omit input to call default camera - deviceId = 0 + else: + #If args.input is None,choose 0 as default else leave it as - + # the digit the string was before the conversion to an integer i.e "1" as 1 + + deviceId = int(args.input) if args.input else 0 cap = cv.VideoCapture(deviceId) tm = cv.TickMeter() diff --git a/models/object_detection_nanodet/demo.py b/models/object_detection_nanodet/demo.py index ab6e980a..51766921 100644 --- a/models/object_detection_nanodet/demo.py +++ b/models/object_detection_nanodet/demo.py @@ -133,7 +133,9 @@ def vis(preds, res_img, letterbox_scale, fps=None): tm = cv.TickMeter() tm.reset() - if args.input is not None: + + #if Input is NOT a digit(i.e input is a file path like dog.jpg or cat.jpg) + if args.input is not None and not args.input.isdigit(): image = cv.imread(args.input) input_blob = cv.cvtColor(image, cv.COLOR_BGR2RGB) @@ -157,9 +159,14 @@ def vis(preds, res_img, letterbox_scale, fps=None): cv.imshow(args.input, img) cv.waitKey(0) + #If it is a digit(or None),go to webcam mode else: print("Press any key to stop video capture") - deviceId = 0 + + #If args.input is None,choose 0 as default else leave it as - + # the digit the string was before the conversion to an integer i.e "1" as 1 + + deviceId = int(args.input) if args.input else 0 cap = cv.VideoCapture(deviceId) while cv.waitKey(1) < 0: