Apollo  6.0
Open source self driving car software
smartereye_component.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2020 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/proto/sensor_image.pb.h"
26 #include "modules/drivers/proto/smartereye.pb.h"
27 #include "modules/drivers/smartereye/proto/config.pb.h"
29 #include "third_party/camera_library/smartereye/include/frameext.h"
30 #include "third_party/camera_library/smartereye/include/obstacleData.h"
31 #include "third_party/camera_library/smartereye/include/obstaclepainter.h"
32 #include "third_party/camera_library/smartereye/include/roadwaypainter.h"
33 #include "third_party/camera_library/smartereye/include/yuv2rgb.h"
34 
35 namespace apollo {
36 namespace drivers {
37 namespace smartereye {
38 
42 using apollo::drivers::Image;
43 using apollo::drivers::smartereye::config::Config;
44 
45 class SmartereyeComponent : public Component<> {
46  public:
47  bool Init() override;
49 
50  protected:
51  void run();
52  bool SetCallback();
53  bool Callback(RawImageFrame *rawFrame);
54  void processFrame(int frameId, char *image, char *extended, int64_t time,
55  int width, int height);
56  void processFrame(int frameId, char *image, uint32_t dataSize, int width,
57  int height, int frameFormat);
58 
59  private:
60  std::shared_ptr<Writer<Image>> writer_ = nullptr;
61  std::shared_ptr<Writer<SmartereyeObstacles>> SmartereyeObstacles_writer_ =
62  nullptr;
63  std::shared_ptr<Writer<SmartereyeLanemark>> SmartereyeLanemark_writer_ =
64  nullptr;
65  std::unique_ptr<SmartereyeDevice> camera_device_ = nullptr;
66  std::shared_ptr<Config> camera_config_ = nullptr;
67  uint32_t spin_rate_ = 200;
68  uint32_t device_wait_ = 2000;
69  std::future<void> async_result_;
70  std::atomic<bool> running_ = {false};
71  bool b_ispolling_ = false;
72 };
73 
75 } // namespace smartereye
76 } // namespace drivers
77 } // 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
void processFrame(int frameId, char *image, char *extended, int64_t time, int width, int height)
Definition: smartereye_component.h:45
#define CYBER_REGISTER_COMPONENT(name)
Definition: component.h:551
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