OrbbecSDK2 2.0.2
OrbbecSDK2: New generation Software-Development-Kit for Orbbec 3D-Sensor devices
载入中...
搜索中...
未找到
OB2Extension.hpp
浏览该文件的文档.
1#pragma once
2
3#include "OB2Types.hpp"
4#include "OB2Device.hpp"
5
6extern "C" {
7#include "h/ob2extension.h"
8#include "h/ob2camera.h"
9}
10
11#include <memory>
12
13namespace ob2 {
14
30public:
54 ob2_status_t status;
55 m_transformation_handle = ob2_transformation_create(&calibration, &status);
57 }
58
79 transformation(transformation &&trans) : m_transformation_handle(trans.m_transformation_handle) {
80 VALIDATE_NOT_NULL(m_transformation_handle);
81 trans.m_transformation_handle = nullptr;
82 }
83
96 virtual ~transformation() noexcept {
97 ob2_status_t status;
98 if(m_transformation_handle != nullptr) {
99 ob2_transformation_destroy(m_transformation_handle, &status);
100 }
101 }
102
123 virtual std::shared_ptr<image> depth_image_to_point_cloud(std::shared_ptr<image> depth_image, float position_scale) {
124 ob2_status_t status;
125 auto depth_image_handle = depth_image->get_handle();
126 auto result_image_handle = ob2_transformation_depth_image_to_point_cloud(m_transformation_handle, depth_image_handle, position_scale, &status);
128 return std::make_shared<image>(std::move(result_image_handle));
129 }
130
156 virtual std::shared_ptr<image> depth_image_to_colored_point_cloud(std::shared_ptr<image> depth_image, std::shared_ptr<image> color_image,
157 float position_scale, ob2_enable_ctrl_t color_normalization) {
158 ob2_status_t status;
159 auto depth_image_handle = depth_image->get_handle();
160 auto color_image_handle = color_image->get_handle();
161 auto result_image_handle = ob2_transformation_depth_image_to_colored_point_cloud(m_transformation_handle, depth_image_handle, color_image_handle,
162 position_scale, color_normalization, &status);
164 return std::make_shared<image>(std::move(result_image_handle));
165 }
166
167private:
168 ob2_transformation_t m_transformation_handle;
169};
170
188public:
202 ob2_status_t status;
203 m_compressor_handle = ob2_image_compressor_create(&status);
205 }
206
227 image_compressor(image_compressor &&converter) : m_compressor_handle(converter.m_compressor_handle) {
228 VALIDATE_NOT_NULL(m_compressor_handle);
229 converter.m_compressor_handle = nullptr;
230 }
231
244 virtual ~image_compressor() noexcept {
245 ob2_status_t status;
246 if(m_compressor_handle != nullptr) {
247 ob2_image_compressor_destroy(m_compressor_handle, &status);
248 }
249 }
250
269 virtual std::shared_ptr<image> compress_lossless(const std::shared_ptr<image> source_image) {
270 ob2_status_t status;
271 auto source_image_handle = source_image->get_handle();
272 auto result_image_handle = ob2_image_compress_lossless(m_compressor_handle, source_image_handle, &status);
274 return std::make_shared<image>(std::move(result_image_handle));
275 }
276
302 virtual std::shared_ptr<image> compress_lossy(const std::shared_ptr<image> source_image, uint8_t threshold) {
303 ob2_status_t status;
304 auto source_image_handle = source_image->get_handle();
305 auto result_image_handle = ob2_image_compress_lossy(m_compressor_handle, source_image_handle, threshold, &status);
307 return std::make_shared<image>(std::move(result_image_handle));
308 }
309
310private:
311 ob2_compression_t m_compressor_handle;
312};
313
329public:
343 ob2_status_t status;
344 m_decompressor_handle = ob2_image_decompressor_create(&status);
346 }
347
368 image_decompressor(image_decompressor &&converter) : m_decompressor_handle(converter.m_decompressor_handle) {
369 VALIDATE_NOT_NULL(m_decompressor_handle);
370 converter.m_decompressor_handle = nullptr;
371 }
372
385 virtual ~image_decompressor() noexcept {
386 ob2_status_t status;
387 if(m_decompressor_handle != nullptr) {
388 ob2_image_decompressor_destroy(m_decompressor_handle, &status);
389 }
390 }
391
410 virtual std::shared_ptr<image> decompress(const std::shared_ptr<image> source_image) {
411 ob2_status_t status;
412 auto source_image_handle = source_image->get_handle();
413 auto result_image_handle = ob2_image_decompress(m_decompressor_handle, source_image_handle, &status);
415 return std::make_shared<image>(std::move(result_image_handle));
416 }
417
418private:
419 ob2_decompression_t m_decompressor_handle;
420};
421
435public:
449 ob2_status_t status;
450 m_converter_handle = ob2_image_format_converter_create(&status);
452 }
453
474 image_format_converter(image_format_converter &&converter) : m_converter_handle(converter.m_converter_handle) {
475 VALIDATE_NOT_NULL(m_converter_handle);
476 converter.m_converter_handle = nullptr;
477 }
478
491 virtual ~image_format_converter() noexcept {
492 ob2_status_t status;
493 if(m_converter_handle != nullptr) {
494 ob2_image_format_converter_destroy(m_converter_handle, &status);
495 }
496 }
497
516 virtual std::shared_ptr<image> yuyv_to_rgb(const std::shared_ptr<image> source_image) {
517 ob2_status_t status;
518 auto source_image_handle = source_image->get_handle();
519 auto result_image_handle = ob2_image_format_converter_yuyv_to_rgb(m_converter_handle, source_image_handle, &status);
521 return std::make_shared<image>(std::move(result_image_handle));
522 }
523
542 virtual std::shared_ptr<image> uyvy_to_rgb(const std::shared_ptr<image> source_image) {
543 ob2_status_t status;
544 auto source_image_handle = source_image->get_handle();
545 auto result_image_handle = ob2_image_format_converter_uyvy_to_rgb(m_converter_handle, source_image_handle, &status);
547 return std::make_shared<image>(std::move(result_image_handle));
548 }
549
568 virtual std::shared_ptr<image> i420_to_rgb(const std::shared_ptr<image> source_image) {
569 ob2_status_t status;
570 auto source_image_handle = source_image->get_handle();
571 auto result_image_handle = ob2_image_format_converter_uyvy_to_rgb(m_converter_handle, source_image_handle, &status);
573 return std::make_shared<image>(std::move(result_image_handle));
574 }
575
594 virtual std::shared_ptr<image> nv21_to_rgb(const std::shared_ptr<image> source_image) {
595 ob2_status_t status;
596 auto source_image_handle = source_image->get_handle();
597 auto result_image_handle = ob2_image_format_converter_uyvy_to_rgb(m_converter_handle, source_image_handle, &status);
599 return std::make_shared<image>(std::move(result_image_handle));
600 }
601
620 virtual std::shared_ptr<image> nv12_to_rgb(const std::shared_ptr<image> source_image) {
621 ob2_status_t status;
622 auto source_image_handle = source_image->get_handle();
623 auto result_image_handle = ob2_image_format_converter_nv12_to_rgb(m_converter_handle, source_image_handle, &status);
625 return std::make_shared<image>(std::move(result_image_handle));
626 }
627
646 virtual std::shared_ptr<image> rgb_to_bgr(const std::shared_ptr<image> source_image) {
647 ob2_status_t status;
648 auto source_image_handle = source_image->get_handle();
649 auto result_image_handle = ob2_image_format_converter_rgb_to_bgr(m_converter_handle, source_image_handle, &status);
651 return std::make_shared<image>(std::move(result_image_handle));
652 }
653
672 virtual std::shared_ptr<image> mjpg_to_i420(const std::shared_ptr<image> source_image) {
673 ob2_status_t status;
674 auto source_image_handle = source_image->get_handle();
675 auto result_image_handle = ob2_image_format_converter_mjpg_to_i420(m_converter_handle, source_image_handle, &status);
677 return std::make_shared<image>(std::move(result_image_handle));
678 }
679
698 virtual std::shared_ptr<image> mjpg_to_nv21(const std::shared_ptr<image> source_image) {
699 ob2_status_t status;
700 auto source_image_handle = source_image->get_handle();
701 auto result_image_handle = ob2_image_format_converter_mjpg_to_nv21(m_converter_handle, source_image_handle, &status);
703 return std::make_shared<image>(std::move(result_image_handle));
704 }
705
724 virtual std::shared_ptr<image> mjpg_to_rgb(const std::shared_ptr<image> source_image) {
725 ob2_status_t status;
726 auto source_image_handle = source_image->get_handle();
727 auto result_image_handle = ob2_image_format_converter_mjpg_to_rgb(m_converter_handle, source_image_handle, &status);
729 return std::make_shared<image>(std::move(result_image_handle));
730 }
731
750 virtual std::shared_ptr<image> mjpg_to_bgr(const std::shared_ptr<image> source_image) {
751 ob2_status_t status;
752 auto source_image_handle = source_image->get_handle();
753 auto result_image_handle = ob2_image_format_converter_mjpg_to_bgr(m_converter_handle, source_image_handle, &status);
755 return std::make_shared<image>(std::move(result_image_handle));
756 }
757
776 virtual std::shared_ptr<image> mjpg_to_bgra(const std::shared_ptr<image> source_image) {
777 ob2_status_t status;
778 auto source_image_handle = source_image->get_handle();
779 auto result_image_handle = ob2_image_format_converter_mjpg_to_bgra(m_converter_handle, source_image_handle, &status);
781 return std::make_shared<image>(std::move(result_image_handle));
782 }
783
784private:
785 ob2_image_format_converter_t m_converter_handle;
786};
787
788} // namespace ob2
#define CHECK_OB2_STATUS_ERROR_THROW(status)
用于将 C API 中的 ob2_status_t 转换成异常抛出
Definition: OB2Types.hpp:22
#define VALIDATE_NOT_NULL(ARG)
用户参数非空校验
Definition: OB2Types.hpp:45
图像数据压缩器
image_compressor(image_compressor &&converter)
通过其他压缩器对象构造(移动构造,主要用于派生类的实现)
image_compressor()
图像数据压缩器构造函数
virtual std::shared_ptr< image > compress_lossless(const std::shared_ptr< image > source_image)
图像数据无损压缩
virtual ~image_compressor() noexcept
图像数据压缩器析构函数
virtual std::shared_ptr< image > compress_lossy(const std::shared_ptr< image > source_image, uint8_t threshold)
图像数据有损压缩
图像数据解压器
image_decompressor()
图像数据解压器构造函数
virtual std::shared_ptr< image > decompress(const std::shared_ptr< image > source_image)
图像数据解压
image_decompressor(image_decompressor &&converter)
通过其他解压器对象构造(移动构造,主要用于派生类的实现)
virtual ~image_decompressor() noexcept
图像数据解压器析构函数
图像格式转换器
virtual std::shared_ptr< image > yuyv_to_rgb(const std::shared_ptr< image > source_image)
YUYV 转 RGB
virtual std::shared_ptr< image > mjpg_to_rgb(const std::shared_ptr< image > source_image)
MJPG 转 RGB
virtual std::shared_ptr< image > mjpg_to_nv21(const std::shared_ptr< image > source_image)
MJPG 转 NV21
virtual std::shared_ptr< image > i420_to_rgb(const std::shared_ptr< image > source_image)
I420 转 RGB
virtual std::shared_ptr< image > mjpg_to_i420(const std::shared_ptr< image > source_image)
MJPG 转 I420
image_format_converter()
图像格式转换器构造函数
virtual std::shared_ptr< image > mjpg_to_bgr(const std::shared_ptr< image > source_image)
MJPG 转 BGR
virtual std::shared_ptr< image > nv12_to_rgb(const std::shared_ptr< image > source_image)
NV12 转 RGB
virtual ~image_format_converter() noexcept
图像格式转换器析构函数
virtual std::shared_ptr< image > nv21_to_rgb(const std::shared_ptr< image > source_image)
NV21 转 RGB
virtual std::shared_ptr< image > uyvy_to_rgb(const std::shared_ptr< image > source_image)
UYVY 转 RGB
virtual std::shared_ptr< image > rgb_to_bgr(const std::shared_ptr< image > source_image)
RGB 转 BGR
virtual std::shared_ptr< image > mjpg_to_bgra(const std::shared_ptr< image > source_image)
MJPG 转 BGRA
image_format_converter(image_format_converter &&converter)
通过其他转换器对象构造(移动构造,主要用于派生类的实现)
图像转换器
transformation(transformation &&trans)
通过其他转换器对象构造(移动构造,主要用于派生类的实现)
virtual std::shared_ptr< image > depth_image_to_colored_point_cloud(std::shared_ptr< image > depth_image, std::shared_ptr< image > color_image, float position_scale, ob2_enable_ctrl_t color_normalization)
深度图转彩色点云图
virtual ~transformation() noexcept
图像转换器析构函数
transformation(const ob2_cameras_calibration_t &calibration)
图像转换器构造函数
virtual std::shared_ptr< image > depth_image_to_point_cloud(std::shared_ptr< image > depth_image, float position_scale)
深度图转点云图
ob2_image_format_converter_t ob2_image_format_converter_create(ob2_status_t *status)
创建图像格式转换器
ob2_image_t ob2_transformation_depth_image_to_colored_point_cloud(ob2_transformation_t transformation_handle, const ob2_image_t depth_image_handle, const ob2_image_t color_image_handle, float position_scale, ob2_enable_ctrl_t color_normalization, ob2_status_t *status)
深度图转点云图
ob2_compression_t ob2_image_compressor_create(ob2_status_t *status)
创建图像数据压缩器
ob2_image_t ob2_image_format_converter_nv12_to_rgb(ob2_image_format_converter_t converter_handle, const ob2_image_t source_image_handle, ob2_status_t *status)
NV12 转 RGB
ob2_image_t ob2_image_format_converter_yuyv_to_rgb(ob2_image_format_converter_t converter_handle, const ob2_image_t source_image_handle, ob2_status_t *status)
YUYV 转 RGB
void ob2_transformation_destroy(ob2_transformation_t transformation_handle, ob2_status_t *status)
销毁图像转换器
ob2_image_t ob2_image_format_converter_mjpg_to_bgra(ob2_image_format_converter_t converter_handle, const ob2_image_t source_image_handle, ob2_status_t *status)
MJPG 转 BGRA
void ob2_image_compressor_destroy(ob2_compression_t compression_handle, ob2_status_t *status)
销毁图像数据压缩器
ob2_image_t ob2_image_compress_lossless(ob2_compression_t compression_handle, const ob2_image_t source_image_handle, ob2_status_t *status)
图像数据无损压缩
void ob2_image_format_converter_destroy(ob2_image_format_converter_t converter_handle, ob2_status_t *status)
销毁图像格式转换器
ob2_transformation_t ob2_transformation_create(const ob2_cameras_calibration_t *calibration, ob2_status_t *status)
创建图像转换器
ob2_image_t ob2_image_compress_lossy(ob2_compression_t compression_handle, const ob2_image_t source_image_handle, uint8_t threshold, ob2_status_t *status)
图像数据有损压缩
ob2_image_t ob2_image_format_converter_mjpg_to_bgr(ob2_image_format_converter_t converter_handle, const ob2_image_t source_image_handle, ob2_status_t *status)
MJPG 转 BGR
ob2_image_t ob2_image_format_converter_mjpg_to_i420(ob2_image_format_converter_t converter_handle, const ob2_image_t source_image_handle, ob2_status_t *status)
MJPG 转 I420
ob2_image_t ob2_image_format_converter_mjpg_to_rgb(ob2_image_format_converter_t converter_handle, const ob2_image_t source_image_handle, ob2_status_t *status)
MJPG 转 RGB
ob2_image_t ob2_transformation_depth_image_to_point_cloud(ob2_transformation_t transformation_handle, const ob2_image_t depth_image_handle, float position_scale, ob2_status_t *status)
深度图转点云图
ob2_decompression_t ob2_image_decompressor_create(ob2_status_t *status)
创建图像数据解压器
ob2_image_t ob2_image_format_converter_uyvy_to_rgb(ob2_image_format_converter_t converter_handle, const ob2_image_t source_image_handle, ob2_status_t *status)
UYVY 转 RGB
void ob2_image_decompressor_destroy(ob2_decompression_t decompression_handle, ob2_status_t *status)
销毁图像数据解压器
ob2_image_t ob2_image_decompress(ob2_decompression_t decompression_handle, const ob2_image_t source_image_handle, ob2_status_t *status)
图像数据解压
ob2_image_t ob2_image_format_converter_mjpg_to_nv21(ob2_image_format_converter_t converter_handle, const ob2_image_t source_image_handle, ob2_status_t *status)
MJPG 转 NV21
ob2_image_t ob2_image_format_converter_rgb_to_bgr(ob2_image_format_converter_t converter_handle, const ob2_image_t source_image_handle, ob2_status_t *status)
RGB 转 BGR
ob2_enable_ctrl_t
使能 / 去使能定义
Definition: ob2types.h:639
struct OB2CompressionImpl * ob2_compression_t
图像数据压缩器句柄定义
Definition: ob2types.h:151
struct OB2TransformationImpl * ob2_transformation_t
图像转换器句柄定义
Definition: ob2types.h:103
struct OB2DecompressionImpl * ob2_decompression_t
图像数据解压器句柄定义
Definition: ob2types.h:163
struct OB2ImageFormatConverterImpl * ob2_image_format_converter_t
图像格式转换器句柄定义
Definition: ob2types.h:115
用户函数调用返回的状态结构体
Definition: ob2types.h:312