提交 306900b3 编写于 作者: D Dong Li 提交者: Calvin Miao

usb_cam: use cybertron task in usb_cam (#371)

上级 2cfe009e
......@@ -41,13 +41,11 @@ bool UsbCamComponent::Init() {
spin_rate_ = camera_config_->spin_rate();
if (camera_config_->output_type() == YUYV) {
raw_image_->image_size =
raw_image_->width * raw_image_->height * 2;
raw_image_->image_size = raw_image_->width * raw_image_->height * 2;
pb_image_->set_encoding("yuyv");
pb_image_->set_step(2 * raw_image_->width);
} else if (camera_config_->output_type() == RGB) {
raw_image_->image_size =
raw_image_->width * raw_image_->height * 3;
raw_image_->image_size = raw_image_->width * raw_image_->height * 3;
pb_image_->set_encoding("rgb8");
pb_image_->set_step(3 * raw_image_->width);
}
......@@ -63,9 +61,8 @@ bool UsbCamComponent::Init() {
writer_ = node_->CreateWriter<Image>(camera_config_->channel_name());
device_thread_ = std::shared_ptr<std::thread>(
new std::thread(std::bind(&UsbCamComponent::run, this)));
device_thread_->detach();
task_.reset(new apollo::cybertron::Task<>(
"usb_cam_task", std::bind(&UsbCamComponent::run, this), 1));
return true;
}
......
......@@ -47,7 +47,7 @@ class UsbCamComponent : public Component<> {
std::shared_ptr<Config> camera_config_;
CameraImagePtr raw_image_ = nullptr;
std::shared_ptr<Image> pb_image_ = nullptr;
std::shared_ptr<std::thread> device_thread_;
std::unique_ptr<apollo::cybertron::Task<>> task_;
float spin_rate_ = 0.005;
float device_wait_ = 2.0;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册