Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions models/handpose_estimation_mediapipe/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
11 changes: 9 additions & 2 deletions models/object_detection_nanodet/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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:
Expand Down