Skip to content

Commit

Permalink
adding camera as dev argument
Browse files Browse the repository at this point in the history
  • Loading branch information
tginsbu1 committed May 30, 2024
1 parent 4ae6fa8 commit 5464912
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/camera_rest_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@
model="camera"

)
rest_module.arg_parser.add_argument("--camera_address", type=str, help="the camera address", default="/dev/video0")




@rest_module.startup()
def startup(state: State):
args = rest_module.arg_parser.parse_args
state.camera_address = args.camera_address

@rest_module.action(name="take_picture", description="An action that atkes and returns a picture")
def take_picture(state: State,
action: ActionRequest,
Expand All @@ -38,7 +42,7 @@ def take_picture(state: State,
image_path = Path("~/.wei/temp").expanduser() / image_name
image_path.parent.mkdir(parents=True, exist_ok=True)
try:
camera = cv2.VideoCapture(0)
camera = cv2.VideoCapture(state.camera_address)
_, frame = camera.read()
cv2.imwrite(str(image_path), frame)
camera.release()
Expand Down

0 comments on commit 5464912

Please sign in to comment.