Viam C++ SDK current
Loading...
Searching...
No Matches
camera_client.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <grpcpp/channel.h>
7
8#include <viam/api/common/v1/common.pb.h>
9#include <viam/api/component/camera/v1/camera.grpc.pb.h>
10
13#include <viam/sdk/config/resource.hpp>
15
16namespace viam {
17namespace sdk {
18namespace impl {
19
23class CameraClient : public Camera {
24 public:
25 using interface_type = Camera;
26 CameraClient(std::string name, std::shared_ptr<grpc::Channel> channel);
27 ProtoStruct do_command(const ProtoStruct& command) override;
28 raw_image get_image(std::string mime_type, const ProtoStruct& extra) override;
30 point_cloud get_point_cloud(std::string mime_type, const ProtoStruct& extra) override;
32 std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) override;
33
34 // the `extra` param is frequently unnecessary but needs to be supported. Ideally, we'd
35 // like to live in a world where implementers of derived classes don't need to go out of
36 // their way to support two versions of a method (an `extra` version and a non-`extra`
37 // version), and users don't need to pass an unnecessary parameters to all method calls.
38 //
39 // To do this, we define in the parent resource class a non-virtual version of the methods
40 // that calls the virtual method and passes a `nullptr` by default in place of the `extra`
41 // param. In order to access these versions of the methods within the client code, however,
42 // we need to include these `using` lines.
46
47 protected:
48 // This constructor leaves the `channel_` as a nullptr. This is useful for testing
49 // purposes, but renders it unusable for production use. Care should be taken to
50 // avoid use of this constructor outside of tests.
51 CameraClient(std::string name,
52 std::unique_ptr<viam::component::camera::v1::CameraService::StubInterface> stub)
53 : Camera(std::move(name)), stub_(std::move(stub)){};
54
55 private:
56 using StubType = viam::component::camera::v1::CameraService::StubInterface;
57 std::unique_ptr<StubType> stub_;
58 std::shared_ptr<grpc::Channel> channel_;
59};
60
61} // namespace impl
62} // namespace sdk
63} // namespace viam
Defines a Camera component.
Implements a gRPC server for the Camera component.
A Camera represents any physical hardware that can capture frames.
Definition camera.hpp:28
raw_image get_image(std::string mime_type)
Get the next image from the camera as a raw image.
Definition camera.hpp:145
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling camera.
Definition camera.hpp:175
point_cloud get_point_cloud(std::string mime_type)
Get the next point_cloud from the camera.
Definition camera.hpp:163
virtual std::string name() const
Return the resource's name.
gRPC client implementation of a Camera component.
Definition camera_client.hpp:23
image_collection get_images() override
Get the next images from the camera as a vector of raw images with names and metadata.
properties get_properties() override
Get the camera's properties.
std::vector< GeometryConfig > get_geometries(const ProtoStruct &extra) override
Returns GeometryConfigs associated with the calling camera.
ProtoStruct do_command(const ProtoStruct &command) override
Send/receive arbitrary commands to the resource.
raw_image get_image(std::string mime_type, const ProtoStruct &extra) override
Get the next image from the camera as a raw image.
point_cloud get_point_cloud(std::string mime_type, const ProtoStruct &extra) override
Get the next point_cloud from the camera.
gRPC client implementation for a robot.
a collection of images that were collected from a camera all at the same time.
Definition camera.hpp:91
The points and mime type of a point cloud.
Definition camera.hpp:73
The camera's supported features and settings.
Definition camera.hpp:53
the raw bytes, mime type of an image, and name of the source that produced it.
Definition camera.hpp:83