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

Update for WEI v0.7.0 #4

Merged
merged 1 commit into from
Oct 16, 2024
Merged
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
21 changes: 14 additions & 7 deletions src/camera_rest_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import cv2
import numpy as np
from fastapi.datastructures import State
from typing_extensions import Annotated
from wei.modules.rest_module import RESTModule
from wei.types.module_types import LocalFileModuleActionResult
from wei.types.step_types import (
ActionRequest,
StepFileResponse,
Expand All @@ -20,25 +20,32 @@
rest_module = RESTModule(
name="camera_node",
version=extract_version(Path(__file__).parent.parent / "pyproject.toml"),
description="An example REST camera implementation",
description="An example REST camera implementation",
model="camera",
)
rest_module.arg_parser.add_argument(
"--camera_address", type=str, help="the camera address", default="/dev/video1"
"--camera_address",
type=str,
help="the address of the camera to attach",
default="/dev/video1",
)


@rest_module.action(
name="take_picture", description="An action that atkes and returns a picture"
name="take_picture",
description="An action that takes and returns a picture",
results=[
LocalFileModuleActionResult(
label="image", description="the image taken from the camera"
),
],
)
def take_picture(
state: State,
action: ActionRequest,
file_name: Annotated[str, "Name of the file to save"] = "image.jpg",
) -> StepResponse:
"""Function to take a picture"""
image_name = file_name
image_path = Path("~/.wei/temp").expanduser() / image_name
image_path = Path("~/.wei/temp").expanduser() / "image.jpg"
image_path.parent.mkdir(parents=True, exist_ok=True)
try:
camera = cv2.VideoCapture(state.camera_address)
Expand Down
Loading