File: pyri_device_manager_client.py

package info (click to toggle)
robotraconteur 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 101,380 kB
  • sloc: cpp: 1,149,268; cs: 87,653; java: 58,127; python: 26,897; ansic: 356; sh: 152; makefile: 90; xml: 51
file content (27 lines) | stat: -rw-r--r-- 859 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# pyri_device_manager_client.py - Example of using the PyriDeviceManagerClient class to connect to a device

# The package pyri-common must be installed to use this example. See https://github.com/pyri-project/pyri-core
# for more information.

from pyri.device_manager_client import DeviceManagerClient
from RobotRaconteur.Client import *
from RobotRaconteurCompanion.Util.ImageUtil import ImageUtil
import cv2

# Create the DeviceManagerClient object
d = DeviceManagerClient()

# Refresh the available devices from the service
d.refresh_devices(1)

# Get the default client and capture and image
c = d.get_device_client("camera", timeout=10)
raw_img = c.capture_frame()
image_util = ImageUtil(client_obj=c)

# Display the image
img = image_util.image_to_array(raw_img)
cv2.namedWindow("Image")
cv2.imshow("Image", img)
cv2.waitKey()
cv2.destroyAllWindows()