Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ip camera in demo.py #1802

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's too complex to understand, plz simplify it.

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":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about elif any(args.demo in xxx)

imageflow_demo(predictor, vis_folder, current_time, args)


Expand Down
Loading