Apollo  6.0
Open source self driving car software
camera_component.h
Go to the documentation of this file.
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/drivers/proto/sensor_image.pb.h"
27 
29 
30 namespace apollo {
31 namespace drivers {
32 namespace camera {
33 
37 using apollo::drivers::Image;
38 using apollo::drivers::camera::config::Config;
39 
40 class 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::unique_ptr<UsbCam> camera_device_;
50  std::shared_ptr<Config> camera_config_;
51  CameraImagePtr raw_image_ = nullptr;
52  std::vector<std::shared_ptr<Image>> pb_image_buffer_;
53  uint32_t spin_rate_ = 200;
54  uint32_t device_wait_ = 2000;
55  int index_ = 0;
56  int buffer_size_ = 16;
57  const int32_t MAX_IMAGE_SIZE = 20 * 1024 * 1024;
58  std::future<void> async_result_;
59  std::atomic<bool> running_ = {false};
60 };
61 
63 } // namespace camera
64 } // namespace drivers
65 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Reader subscribes a channel, it has two main functions:
Definition: reader.h:68
std::shared_ptr< CameraImage > CameraImagePtr
Definition: usb_cam.h:100
#define CYBER_REGISTER_COMPONENT(name)
Definition: component.h:551
Definition: camera_component.h:40
The Component can process up to four channels of messages. The message type is specified when the com...
Definition: component.h:58
apollo::cyber::Writer< T > Writer
Definition: sensor_canbus.h:67