|
@@ -5,6 +5,9 @@
|
|
|
|
|
|
|
|
#include <boost/asio/post.hpp>
|
|
#include <boost/asio/post.hpp>
|
|
|
|
|
|
|
|
|
|
+#include <opencv2/imgcodecs.hpp>
|
|
|
|
|
+#include <opencv2/imgproc.hpp>
|
|
|
|
|
+
|
|
|
using boost::asio::post;
|
|
using boost::asio::post;
|
|
|
|
|
|
|
|
namespace orb_camera_impl {
|
|
namespace orb_camera_impl {
|
|
@@ -39,6 +42,15 @@ namespace orb_camera_impl {
|
|
|
return create_image(info);
|
|
return create_image(info);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ auto mjpeg_frame_to_image(const video_frame_type &frame) { // TODO: accelerate with CUDA
|
|
|
|
|
+ assert(frame->format() == OB_FORMAT_MJPG);
|
|
|
|
|
+ auto img_data = cv::_InputArray((uchar *) frame->data(), frame->dataSize());
|
|
|
|
|
+ auto img_bgr = cv::imdecode(img_data, cv::IMREAD_UNCHANGED);
|
|
|
|
|
+ auto img_rgb_info = create_image_info<uchar3>(img_bgr.size(), MEM_HOST);
|
|
|
|
|
+ cv::cvtColor(img_bgr, img_rgb_info.as_mat(), cv::COLOR_BGR2RGB);
|
|
|
|
|
+ return create_image(img_rgb_info);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
image_f32c1 depth_y16_to_mm(const image_u16c1 &y16, float scale) { // TODO: accelerate with CUDA
|
|
image_f32c1 depth_y16_to_mm(const image_u16c1 &y16, float scale) { // TODO: accelerate with CUDA
|
|
|
auto y16_info = y16->as_host_info();
|
|
auto y16_info = y16->as_host_info();
|
|
|
auto f32_info = create_image_info<float1>(y16_info.size, MEM_HOST);
|
|
auto f32_info = create_image_info<float1>(y16_info.size, MEM_HOST);
|
|
@@ -137,8 +149,13 @@ void orb_camera::impl::frames_callback(const frames_type &frames) {
|
|
|
auto c_img = image_u8c3();
|
|
auto c_img = image_u8c3();
|
|
|
if (auto c_frame = frames->colorFrame(); c_frame != nullptr) {
|
|
if (auto c_frame = frames->colorFrame(); c_frame != nullptr) {
|
|
|
assert(c_name != invalid_obj_name);
|
|
assert(c_name != invalid_obj_name);
|
|
|
- assert(c_frame->format() == OB_FORMAT_RGB);
|
|
|
|
|
- c_img = video_uc_frame_to_image<uchar3>(c_frame);
|
|
|
|
|
|
|
+ auto fmt = c_frame->format();
|
|
|
|
|
+ if (fmt == OB_FORMAT_RGB) {
|
|
|
|
|
+ c_img = video_uc_frame_to_image<uchar3>(c_frame);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ assert(fmt == OB_FORMAT_MJPG);
|
|
|
|
|
+ c_img = mjpeg_frame_to_image(c_frame);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
auto d_img = image_f32c1();
|
|
auto d_img = image_f32c1();
|