Skip to content

Commit 7c32272

Browse files
njoomastuqdogpurplenicole730bhaney
authored
rc-0.21.0 (#621)
Co-authored-by: Ethan <[email protected]> Co-authored-by: Nicole Jung <[email protected]> Co-authored-by: Bijan Haney <[email protected]>
1 parent 622976b commit 7c32272

File tree

23 files changed

+1695
-912
lines changed

23 files changed

+1695
-912
lines changed

docs/examples/example.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,13 @@
161161
"source": [
162162
"from viam.components.camera import Camera\n",
163163
"from viam.media.video import CameraMimeType\n",
164+
"from viam.media.utils.pil import viam_to_pil_image\n",
164165
"\n",
165166
"robot = await connect_with_channel()\n",
166167
"camera = Camera.from_robot(robot, \"camera0\")\n",
167168
"image = await camera.get_image(CameraMimeType.JPEG)\n",
168-
"image.save(\"foo.png\")\n",
169+
"pil = viam_to_pil_image(image)\n",
170+
"pil.save(\"foo.png\")\n",
169171
"\n",
170172
"# Don't forget to close the robot when you're done!\n",
171173
"await robot.close()"
@@ -1356,7 +1358,7 @@
13561358
"source": [
13571359
"my_organizations = await app_client.list_organizations()\n",
13581360
"MY_ORG_ID = my_organizations[0].id\n",
1359-
"my_locations = await app_client.list_locations()\n",
1361+
"my_locations = await app_client.list_locations(org_id=MY_ORG_ID)\n",
13601362
"robots = []\n",
13611363
"\n",
13621364
"for location in my_locations:\n",
@@ -1489,7 +1491,7 @@
14891491
"name": "python",
14901492
"nbconvert_exporter": "python",
14911493
"pygments_lexer": "ipython3",
1492-
"version": "3.11.6 (main, Oct 2 2023, 20:46:14) [Clang 14.0.3 (clang-1403.0.22.14.1)]"
1494+
"version": "3.11.9 (main, Apr 2 2024, 08:25:04) [Clang 15.0.0 (clang-1500.1.0.2.5)]"
14931495
},
14941496
"vscode": {
14951497
"interpreter": {

examples/apis.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,5 @@
1919
"pose_tracker": { "func": "get_poses" },
2020
"power_sensor": { "func": "get_power" },
2121
"motion": { "func": "get_pose" },
22-
"vision": {
23-
"func": "get_classifications_from_camera",
24-
"args": ["YOURCAMERANAME", "1"],
25-
"comment": "Note that the Camera supplied is a placeholder. Please change this to a valid Camera. Also note that the get_classifications method is a placeholder and is commented out to give you a choice to use get_detections method instead if you are doing detections."
26-
}
22+
"vision": { "func": "get_properties" }
2723
}

examples/server/v1/components.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import AsyncIterator
1111

1212
from datetime import timedelta
13+
from io import BytesIO
1314
from multiprocessing import Lock
1415
from pathlib import Path
1516
from typing import Any, Dict, List, Mapping, Optional, Tuple
@@ -33,7 +34,7 @@
3334
from viam.errors import ResourceNotFoundError
3435
from viam.streams import StreamWithIterator
3536
from viam.media.audio import Audio, AudioStream
36-
from viam.media.video import NamedImage
37+
from viam.media.video import CameraMimeType, NamedImage, ViamImage
3738
from viam.operations import run_with_operation
3839
from viam.proto.common import (
3940
Capsule,
@@ -324,14 +325,17 @@ async def get_geometries(self, extra: Optional[Dict[str, Any]] = None, **kwargs)
324325
class ExampleCamera(Camera):
325326
def __init__(self, name: str):
326327
p = Path(__file__)
327-
self.image = Image.open(p.parent.absolute().joinpath("viam.webp"))
328+
img = Image.open(p.parent.absolute().joinpath("viam.webp"))
329+
buf = BytesIO()
330+
img.copy().save(buf, format="JPEG")
331+
self.image = ViamImage(buf.getvalue(), CameraMimeType.JPEG)
328332
super().__init__(name)
329333

330334
def __del__(self):
331335
self.image.close()
332336

333-
async def get_image(self, mime_type: str = "", extra: Optional[Dict[str, Any]] = None, **kwargs) -> Image.Image:
334-
return self.image.copy()
337+
async def get_image(self, mime_type: str = "", extra: Optional[Dict[str, Any]] = None, **kwargs) -> ViamImage:
338+
return self.image
335339

336340
async def get_images(self, timeout: Optional[float] = None, **kwargs) -> Tuple[List[NamedImage], ResponseMetadata]:
337341
raise NotImplementedError()

poetry.lock

Lines changed: 348 additions & 349 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "viam-sdk"
3-
version = "0.20.0"
3+
version = "0.21.0b2"
44
description = "Viam Robotics Python SDK"
55
authors = [ "Naveed <[email protected]>" ]
66
license = "Apache-2.0"
@@ -18,7 +18,6 @@ include = ["LICENSE", "src/viam/rpc/libviam_rust_utils.*"]
1818
]
1919
googleapis-common-protos = ">=1.60.0,<2"
2020
typing-extensions = ">=4.8.0,<5"
21-
Pillow = ">=9.1.0,<11"
2221
protobuf = ">=4.24.3,<5"
2322
numpy = { version = ">=1.21,<2", optional = true }
2423

@@ -50,6 +49,7 @@ include = ["LICENSE", "src/viam/rpc/libviam_rust_utils.*"]
5049
{version = "<1.25.0", python = "<3.9"},
5150
{version = ">=1.26.2", python = ">=3.9"},
5251
]
52+
Pillow = ">=9.1.0,<11"
5353
pyright = "^1.1.339"
5454

5555
[tool.poetry.extras]

0 commit comments

Comments
 (0)