Skip to content

Commit

Permalink
update camera example
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarriba committed Sep 25, 2023
1 parent 502fe1b commit 37c3074
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions py/examples/camera_client/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import cv2
import numpy as np
from kornia_rs import ImageDecoder
from farm_ng.core.event_client import EventClient
from farm_ng.core.event_service_pb2 import EventServiceConfig
from farm_ng.core.events_file_reader import proto_from_json_file
Expand All @@ -34,15 +35,16 @@ async def main(service_config_path: Path) -> None:
# create a client to the camera service
config: EventServiceConfig = proto_from_json_file(service_config_path, EventServiceConfig())

# instantiate the image decoder
image_decoder = ImageDecoder()

async for event, message in EventClient(config).subscribe(config.subscriptions[0], decode=True):
print(f"Timestamps: {event.timestamps[-2]}")
print(f"Meta: {message.meta}")
print("###################\n")

# cast image data bytes to numpy and decode
# NOTE: explore frame.[rgb, disparity, left, right]
image = np.frombuffer(message.image_data, dtype="uint8")
image = cv2.imdecode(image, cv2.IMREAD_UNCHANGED)
image = np.from_dlpack(image_decoder.decode(message.image_data))

# visualize the image
cv2.namedWindow("image", cv2.WINDOW_NORMAL)
Expand Down
1 change: 1 addition & 0 deletions py/examples/camera_client/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
farm-ng-amiga
opencv-python==4.6.0.66
numpy==1.23.2
kornia_rs==0.0.8

0 comments on commit 37c3074

Please sign in to comment.