diff --git a/.github/workflows/sdk_protos_map.csv b/.github/workflows/sdk_protos_map.csv index 24605701a8..dc244f2e3a 100644 --- a/.github/workflows/sdk_protos_map.csv +++ b/.github/workflows/sdk_protos_map.csv @@ -58,7 +58,7 @@ board,GetResourceName,No,get_resource_name,,getResourceName board,Close,No,close,Close, ## Camera -camera,GetImage,,get_image,Stream,image +camera,GetImage,,get_image,Image,image camera,GetImages,,get_images,Images, camera,RenderFrame,,,, camera,GetPointCloud,,get_point_cloud,NextPointCloud,pointCloud diff --git a/.github/workflows/update_sdk_methods.py b/.github/workflows/update_sdk_methods.py index 9f1ae8ea80..5b04083715 100755 --- a/.github/workflows/update_sdk_methods.py +++ b/.github/workflows/update_sdk_methods.py @@ -1411,6 +1411,10 @@ def parse(type, names): ## Determine method link: method_link = tag.find("span", class_="name").a['href'].replace("..", sdk_url) + # HACK: link 404s + if method_link == "https://api.flutter.dev/flutter/dart-core/Future-class.html": + print("faulty link detected") + method_link = "https://api.flutter.dev/flutter/dart-async/Future-class.html" this_method_dict["method_link"] = method_link ## While some method info is available to us on this current Flutter SDK page, the code sample is only found on the diff --git a/static/include/components/apis/generated/camera.md b/static/include/components/apis/generated/camera.md index f1be2a8c3a..6029a84dcd 100644 --- a/static/include/components/apis/generated/camera.md +++ b/static/include/components/apis/generated/camera.md @@ -67,36 +67,34 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ {{% /tab %}} {{% tab name="Go" %}} -{{% alert title="Info" color="info" %}} - -Unlike most Viam [component APIs](/dev/reference/apis/#component-apis), the methods of the Go camera client do not map exactly to the names of the other SDK's camera methods. -To get an image in the Go SDK, you first need to construct a `Stream` and then you can get the next image from that stream. - -{{% /alert %}} - **Parameters:** - `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries. -- `errHandlers` [(...gostream.ErrorHandler)](https://pkg.go.dev/go.viam.com/rdk/gostream#ErrorHandler): A handler for errors allowing for logic based on consecutively retrieved errors. +- `mimeType` [(string)](https://pkg.go.dev/builtin#string): The desired MIME type of the image. This does not guarantee output type. +- `extra` [(map[string]interface{})](https://go.dev/blog/maps): Extra options to pass to the underlying RPC call. **Returns:** -- [(gostream.VideoStream)](https://pkg.go.dev/go.viam.com/rdk/gostream#VideoStream): A `VideoStream` that streams video until closed. +- [([]byte)](https://pkg.go.dev/builtin#byte): The frame as bytes. +- [(ImageMetadata)](https://pkg.go.dev/go.viam.com/rdk/components/camera#ImageMetadata): The associated metadata, containing the image MIME type. - [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred. **Example:** ```go {class="line-numbers linkable-line-numbers"} myCamera, err := camera.FromRobot(machine, "my_camera") +imageBytes, mimeType, err := myCamera.Image(context.Background(), utils.MimeTypeJPEG, nil) +``` -// gets the stream from a camera -stream, err := myCamera.Stream(context.Background()) +You can also directly decode as an `Image.Image` with the camera's `DecodeImageFromCamera` function: -// gets an image from the camera stream -img, release, err := stream.Next(context.Background()) -defer release() +```go {class="line-numbers linkable-line-numbers"} +myCamera, err := camera.FromRobot(machine, "my_camera") +img, err = camera.DecodeImageFromCamera(context.Background(), utils.MimeTypeJPEG, nil, myCamera) ``` +If you use this method, be sure to import `"go.viam.com/rdk/utils"` at the beginning of your file. + For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/components/camera#VideoSource). {{% /tab %}} @@ -105,11 +103,11 @@ For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/c **Parameters:** - `mimeType` [MimeType](https://flutter.viam.dev/viam_sdk/MimeType-class.html)? (optional) -- `extra` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)\<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic\>? (optional) +- `extra` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic>? (optional) **Returns:** -- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html)\<[ViamImage](https://flutter.viam.dev/viam_sdk/ViamImage-class.html)\> +- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html)<[ViamImage](https://flutter.viam.dev/viam_sdk/ViamImage-class.html)> **Example:** @@ -248,11 +246,11 @@ For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/c **Parameters:** -- `extra` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)\<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic\>? (optional) +- `extra` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic>? (optional) **Returns:** -- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html)\<[ViamImage](https://flutter.viam.dev/viam_sdk/ViamImage-class.html)\> +- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html)<[ViamImage](https://flutter.viam.dev/viam_sdk/ViamImage-class.html)> **Example:** @@ -313,7 +311,7 @@ For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/c **Returns:** -- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html)\<[CameraProperties](https://flutter.viam.dev/viam_sdk/CameraProperties.html)\> +- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html)<[CameraProperties](https://flutter.viam.dev/viam_sdk/CameraProperties.html)> **Example:** @@ -363,11 +361,11 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ **Parameters:** -- `command` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)\<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic\> (required) +- `command` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic> (required) **Returns:** -- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html)\<[Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)\<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic\>\> +- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html)<[Map](https://api.flutter.dev/flutter/dart-core/Map-class.html)<[String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic>\> **Example:** @@ -449,6 +447,12 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/ - [ResourceName](https://flutter.viam.dev/viam_sdk/ResourceName-class.html) +**Example:** + +```dart {class="line-numbers linkable-line-numbers"} +final myCameraResourceName = myCamera.getResourceName("my_camera"); +``` + For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/Camera/getResourceName.html). {{% /tab %}} diff --git a/static/include/components/apis/overrides/methods/go.camera.Image.ImageMetadata.return.md b/static/include/components/apis/overrides/methods/go.camera.Image.ImageMetadata.return.md new file mode 100644 index 0000000000..b17bf22104 --- /dev/null +++ b/static/include/components/apis/overrides/methods/go.camera.Image.ImageMetadata.return.md @@ -0,0 +1 @@ +The associated metadata, containing the image MIME type. \ No newline at end of file diff --git a/static/include/components/apis/overrides/methods/go.camera.Image.after.md b/static/include/components/apis/overrides/methods/go.camera.Image.after.md new file mode 100644 index 0000000000..c49b0587ea --- /dev/null +++ b/static/include/components/apis/overrides/methods/go.camera.Image.after.md @@ -0,0 +1,8 @@ +You can also directly decode as an `Image.Image` with the camera's `DecodeImageFromCamera` function: + +```go {class="line-numbers linkable-line-numbers"} +myCamera, err := camera.FromRobot(machine, "my_camera") +img, err = camera.DecodeImageFromCamera(context.Background(), utils.MimeTypeJPEG, nil, myCamera) +``` + +If you use this method, be sure to import `"go.viam.com/rdk/utils"` at the beginning of your file. diff --git a/static/include/components/apis/overrides/methods/go.camera.Image.byte.return.md b/static/include/components/apis/overrides/methods/go.camera.Image.byte.return.md new file mode 100644 index 0000000000..26127ba6be --- /dev/null +++ b/static/include/components/apis/overrides/methods/go.camera.Image.byte.return.md @@ -0,0 +1 @@ +The frame as bytes. \ No newline at end of file diff --git a/static/include/components/apis/overrides/methods/go.camera.Image.mimeType.md b/static/include/components/apis/overrides/methods/go.camera.Image.mimeType.md new file mode 100644 index 0000000000..15cb03f259 --- /dev/null +++ b/static/include/components/apis/overrides/methods/go.camera.Image.mimeType.md @@ -0,0 +1 @@ +The desired MIME type of the image. This does not guarantee output type. \ No newline at end of file diff --git a/static/include/services/apis/generated/vision.md b/static/include/services/apis/generated/vision.md index 3a9b775864..c9e1a6e39a 100644 --- a/static/include/services/apis/generated/vision.md +++ b/static/include/services/apis/generated/vision.md @@ -147,11 +147,9 @@ if err != nil { logger.Error(err) return } -// Get the stream from a camera -camStream, err := myCam.Stream(context.Background()) -// Get an image from the camera stream -img, release, err := camStream.Next(context.Background()) -defer release() + +// Get an image from the camera decoded as an image.Image +img, err = camera.DecodeImageFromCamera(context.Background(), utils.MimeTypeJPEG, nil, myCam) myDetectorService, err := vision.FromRobot(machine, "my_detector") if err != nil { @@ -168,6 +166,8 @@ if len(detections) > 0 { } ``` +Import `"go.viam.com/rdk/utils"` at the beginning of your file. + For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/services/vision#Service). {{% /tab %}} @@ -341,15 +341,9 @@ if err != nil { logger.Error(err) return } -// Get the stream from a camera -camStream, err := myCam.Stream(context.Background()) -if err!=nil { - logger.Error(err) - return -} -// Get an image from the camera stream -img, release, err := camStream.Next(context.Background()) -defer release() + +// Get an image from the camera decoded as an image.Image +img, err = camera.DecodeImageFromCamera(context.Background(), utils.MimeTypeJPEG, nil, myCam) myClassifierService, err := vision.FromRobot(machine, "my_classifier") if err != nil { @@ -366,6 +360,8 @@ if len(classifications) > 0 { } ``` +Import `"go.viam.com/rdk/utils"` at the beginning of your file. + For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/services/vision#Service). {{% /tab %}}