Apollo 10.0
自动驾驶开放平台
driver.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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
18
19namespace apollo {
20namespace drivers {
21namespace video {
22
25
27 config_ = *h265_cfg;
28}
29
30bool CameraDriver::Poll(std::shared_ptr<CompressedImage> h265) {
31 return PollByFrame(h265);
32}
33
34bool CameraDriver::PollByFrame(std::shared_ptr<CompressedImage> h265Pb) {
35 int ret = input_->GetFramePacket(h265Pb);
36 if (ret < 0) {
37 return false;
38 }
39
40 h265Pb->set_frame_id(config_.frame_id());
41 uint64_t camera_timestamp = h265Pb->mutable_header()->camera_timestamp();
42 uint64_t current_time = cyber::Time().Now().ToNanosecond();
43 AINFO << "Get frame from port: " << config_.udp_port()
44 << ", size: " << h265Pb->data().size() << ", ts: camera/host "
45 << camera_timestamp << "/" << current_time << ", diff: "
46 << static_cast<double>(current_time - camera_timestamp) * 1e-6;
47
48 return true;
49}
50
52 input_.reset(new SocketInput());
53 input_->Init(config_.udp_port());
54}
55
56} // namespace video
57} // namespace drivers
58} // namespace apollo
Cyber has builtin time type Time.
Definition time.h:31
uint64_t ToNanosecond() const
convert time to nanosecond.
Definition time.cc:83
static Time Now()
get the current time.
Definition time.cc:57
std::shared_ptr< SocketInput > input_
Definition driver.h:44
bool PollByFrame(std::shared_ptr< CompressedImage > h265)
Definition driver.cc:34
bool Poll(std::shared_ptr< CompressedImage > h265)
Definition driver.cc:30
CameraDriver(const CameraH265Config *h265_cfg)
Definition driver.cc:26
Live Velodyne input from socket.
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37