Skip to content

Commit

Permalink
feat: add ip camera in demo.py
Browse files Browse the repository at this point in the history
  • Loading branch information
null-qwerty committed Oct 5, 2024
1 parent f00a798 commit b861101
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
def make_parser():
parser = argparse.ArgumentParser("YOLOX Demo!")
parser.add_argument(
"demo", default="image", help="demo type, eg. image, video and webcam"
"demo", default="image", help="demo type, eg. image, video and webcam or ipcam"
)
parser.add_argument("-expn", "--experiment-name", type=str, default=None)
parser.add_argument("-n", "--name", type=str, default=None, help="model name")
Expand All @@ -31,6 +31,7 @@ def make_parser():
"--path", default="./assets/dog.jpg", help="path to images or video"
)
parser.add_argument("--camid", type=int, default=0, help="webcam demo camera id")
parser.add_argument("--ipcam", type=str, default=None, help="ipcam demo camera address")
parser.add_argument(
"--save_result",
action="store_true",
Expand Down Expand Up @@ -207,7 +208,7 @@ def image_demo(predictor, vis_folder, path, current_time, save_result):


def imageflow_demo(predictor, vis_folder, current_time, args):
cap = cv2.VideoCapture(args.path if args.demo == "video" else args.camid)
cap = cv2.VideoCapture(args.path if args.demo == "video" else args.camid if args.demo == "webcam" else args.ipcam)
width = cap.get(cv2.CAP_PROP_FRAME_WIDTH) # float
height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT) # float
fps = cap.get(cv2.CAP_PROP_FPS)
Expand Down Expand Up @@ -309,7 +310,7 @@ def main(exp, args):
current_time = time.localtime()
if args.demo == "image":
image_demo(predictor, vis_folder, args.path, current_time, args.save_result)
elif args.demo == "video" or args.demo == "webcam":
elif args.demo == "video" or args.demo == "webcam" or args.demo == "ipcam":
imageflow_demo(predictor, vis_folder, current_time, args)


Expand Down

0 comments on commit b861101

Please sign in to comment.