Apollo 10.0
自动驾驶开放平台
camera_component.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <atomic>
20#include <future>
21#include <memory>
22#include <vector>
23
24#include "cyber/cyber.h"
25#include "modules/drivers/camera/proto/config.pb.h"
26#include "modules/common_msgs/sensor_msgs/sensor_image.pb.h"
27
29
30namespace apollo {
31namespace drivers {
32namespace camera {
33
39
40class CameraComponent : public Component<> {
41 public:
42 bool Init() override;
44
45 private:
46 void run();
47
48 std::shared_ptr<Writer<Image>> writer_ = nullptr;
49 std::shared_ptr<Writer<Image>> raw_writer_ = nullptr;
50 std::unique_ptr<UsbCam> camera_device_;
51 std::shared_ptr<Config> camera_config_;
52 CameraImagePtr raw_image_ = nullptr;
53 CameraImagePtr raw_image_for_compress_ = nullptr;
54 std::vector<std::shared_ptr<Image>> pb_image_buffer_;
55 std::vector<std::shared_ptr<Image>> raw_image_buffer_;
56 uint32_t spin_rate_ = 200;
57 uint32_t device_wait_ = 2000;
58 int index_ = 0;
59 int buffer_size_ = 16;
60 const int32_t MAX_IMAGE_SIZE = 20 * 1024 * 1024;
61 std::future<void> async_result_;
62 std::atomic<bool> running_ = {false};
63};
64
66} // namespace camera
67} // namespace drivers
68} // namespace apollo
Reader subscribes a channel, it has two main functions:
Definition reader.h:69
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:656
std::shared_ptr< CameraImage > CameraImagePtr
Definition usb_cam.h:100
class register implement
Definition arena_queue.h:37