Skip to content

Consolidate camera api demo #679

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
84 changes: 75 additions & 9 deletions proto/viam/component/camera/v1/camera.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,47 @@ option java_package = "com.viam.component.camera.v1";

// A CameraService services all cameras associated with a robot
service CameraService {
// GetImage returns a frame from a camera of the underlying robot. A specific MIME type
// can be requested but may not necessarily be the same one returned.
// GetImage returns a frame from a camera of the underlying robot. A specific
// MIME type can be requested but may not necessarily be the same one
// returned.
rpc GetImage(GetImageRequest) returns (GetImageResponse) {
option deprecated = true;
option (google.api.http) = {get: "/viam/api/v1/component/camera/{name}/image"};
}

rpc GetImages(GetImagesRequest) returns (GetImagesResponse) {
option deprecated = true;
option (google.api.http) = {get: "/viam/api/v1/component/camera/{name}/images"};
}

// RenderFrame renders a frame from a camera of the underlying robot to an HTTP response. A specific MIME type
// can be requested but may not necessarily be the same one returned.
// RenderFrame renders a frame from a camera of the underlying robot to an
// HTTP response. A specific MIME type can be requested but may not
// necessarily be the same one returned.
rpc RenderFrame(RenderFrameRequest) returns (google.api.HttpBody) {
option deprecated = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering why we needed this custom API endpoint for the frontend to begin with since the web app can handle GRPC responses.

option (google.api.http) = {get: "/viam/api/v1/component/camera/{name}/render_frame"};
}

// GetPointCloud returns a point cloud from a camera of the underlying robot. A specific MIME type
// can be requested but may not necessarily be the same one returned.
// GetPointCloud returns a point cloud from a camera of the underlying robot.
// A specific MIME type can be requested but may not necessarily be the same
// one returned.
rpc GetPointCloud(GetPointCloudRequest) returns (GetPointCloudResponse) {
option deprecated = true;
option (google.api.http) = {get: "/viam/api/v1/component/camera/{name}/point_cloud"};
Comment on lines +17 to 41
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wouldn't deprecate these APIs immediately as part of this proposal, but rather, we would remove them at the end of the project once all important camera models have been migrated to the new API that can express all of them.

}

// GetProperties returns the camera intrinsic parameters and camera distortion parameters from a camera of the underlying robot, if available.
// BinaryReadings returns the readings of all sensors on the camera at a given point in time.
// The caller may specify requested sensor_names and/or formats to be sent. The server is
// expected to return all results if the caller doesn't specify requested sensor_names and/or formats
// and only return requested sensor_names and/or formats when the caller specifies them.
// This is important to conserve bandwidth when the caller is only interested in certain
// sensor readings or formats.
rpc BinaryReadings(BinaryReadingsRequest) returns (BinaryReadingsResponse) {
option (google.api.http) = {get: "/viam/api/v1/component/camera/{name}/binary_readings"};
}

// GetProperties returns the camera intrinsic parameters and camera distortion
// parameters from a camera of the underlying robot, if available.
rpc GetProperties(GetPropertiesRequest) returns (GetPropertiesResponse) {
option (google.api.http) = {get: "/viam/api/v1/component/camera/{name}/properties"};
}
Expand All @@ -44,7 +62,8 @@ service CameraService {
option (google.api.http) = {post: "/viam/api/v1/component/camera/{name}/do_command"};
}

// GetGeometries returns the geometries of the component in their current configuration
// GetGeometries returns the geometries of the component in their current
// configuration
rpc GetGeometries(common.v1.GetGeometriesRequest) returns (common.v1.GetGeometriesResponse) {
option (google.api.http) = {get: "/viam/api/v1/component/camera/{name}/geometries"};
}
Expand Down Expand Up @@ -126,7 +145,8 @@ message GetPropertiesRequest {
}

message GetPropertiesResponse {
// A boolean property determining whether the camera supports the return of pointcloud data
// A boolean property determining whether the camera supports the return of
// pointcloud data
bool supports_pcd = 1;
// Parameters for doing a perspective of a 3D scene to a 2D plane
// If camera does not provide intrinsic parameters, leave the field empty
Expand Down Expand Up @@ -183,3 +203,49 @@ message DistortionParameters {
string model = 1;
repeated double parameters = 2;
}

enum ReadingFormat {
READING_FORMAT_UNSPECIFIED = 0;
READING_FORMAT_BITMAP_RAW_RGBA = 1;
READING_FORMAT_BITMAP_RAW_DEPTH = 2;
READING_FORMAT_IMAGE_JPEG = 3;
READING_FORMAT_IMAGE_PNG = 4;
READING_FORMAT_POINTCLOUD_PCD = 5;
}

message BinaryReadingsRequest {
// Name of a camera
string name = 1;

// Requested sensor_names
// If empty all readings are requested
repeated string sensor_names = 2;

// Requested reading_formats
// If empty all readings are requested
repeated ReadingFormat formats = 3;
}

message BinaryReadingsResponse {
// list of binary readings returned from the camera system
repeated BinaryReading readings = 1;
// contains timestamp data
common.v1.ResponseMetadata response_metadata = 84260;
}

message BinaryReading {
// the name of the sensor where the reading came from
string source_name = 1;
// format of the data
ReadingFormat format = 2;
// the reading data
bytes data = 3;
// image pixel_dimensions
// may not be set if the reading isn't an image or a bitmap
Dimensions pixel_dimensions = 4;
}

message Dimensions {
uint32 x = 1;
uint32 y = 2;
}
Loading