|
@@ -2,6 +2,7 @@
|
|
|
#define DEPTHGUIDE_IMAGE_UTILITY_HPP
|
|
#define DEPTHGUIDE_IMAGE_UTILITY_HPP
|
|
|
|
|
|
|
|
#include "cuda_helper.hpp"
|
|
#include "cuda_helper.hpp"
|
|
|
|
|
+#include "image_process/cuda_impl/image_utility.cuh"
|
|
|
#include "memory_pool.h"
|
|
#include "memory_pool.h"
|
|
|
#include "object_manager.h"
|
|
#include "object_manager.h"
|
|
|
|
|
|
|
@@ -19,6 +20,7 @@ constexpr inline int get_cv_type() {
|
|
|
// @formatter:off
|
|
// @formatter:off
|
|
|
if constexpr (std::is_same_v<T, uchar1>) { return CV_8UC1; }
|
|
if constexpr (std::is_same_v<T, uchar1>) { return CV_8UC1; }
|
|
|
if constexpr (std::is_same_v<T, uchar3>) { return CV_8UC3; }
|
|
if constexpr (std::is_same_v<T, uchar3>) { return CV_8UC3; }
|
|
|
|
|
+ if constexpr (std::is_same_v<T, uchar4>) { return CV_8UC4; }
|
|
|
if constexpr (std::is_same_v<T, ushort1>) { return CV_16UC1; }
|
|
if constexpr (std::is_same_v<T, ushort1>) { return CV_16UC1; }
|
|
|
if constexpr (std::is_same_v<T, float1>) { return CV_32FC1; }
|
|
if constexpr (std::is_same_v<T, float1>) { return CV_32FC1; }
|
|
|
// @formatter:on
|
|
// @formatter:on
|
|
@@ -198,6 +200,19 @@ struct image_info_type {
|
|
|
return {size, get_cv_type<T>(), ptr.get(), pitch};
|
|
return {size, get_cv_type<T>(), ptr.get(), pitch};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ image_type_v2<T> as_cuda() const {
|
|
|
|
|
+ assert(loc == MEM_CUDA);
|
|
|
|
|
+ auto ret = image_type_v2<T>();
|
|
|
|
|
+ assert(size.width <= std::numeric_limits<ushort>::max());
|
|
|
|
|
+ ret.width = size.width;
|
|
|
|
|
+ assert(size.height <= std::numeric_limits<ushort>::max());
|
|
|
|
|
+ ret.height = size.height;
|
|
|
|
|
+ assert(pitch <= std::numeric_limits<ushort>::max());
|
|
|
|
|
+ ret.pitch = pitch;
|
|
|
|
|
+ ret.ptr = ptr.get();
|
|
|
|
|
+ return ret;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
image_mem_info mem_info() const {
|
|
image_mem_info mem_info() const {
|
|
|
return {std::static_pointer_cast<void>(ptr),
|
|
return {std::static_pointer_cast<void>(ptr),
|
|
|
loc, sizeof(T) * (size_t) size.width, pitch, (size_t) size.height};
|
|
loc, sizeof(T) * (size_t) size.width, pitch, (size_t) size.height};
|
|
@@ -303,14 +318,18 @@ public:
|
|
|
return host_info;
|
|
return host_info;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- cv::Mat as_host(smart_cuda_stream *stream = nullptr) {
|
|
|
|
|
|
|
+ cv::Mat as_mat(smart_cuda_stream *stream = nullptr) {
|
|
|
return as_host_info(stream).as_mat();
|
|
return as_host_info(stream).as_mat();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- cv::cuda::GpuMat as_cuda(smart_cuda_stream *stream = nullptr) {
|
|
|
|
|
|
|
+ cv::cuda::GpuMat as_gpu_mat(smart_cuda_stream *stream = nullptr) {
|
|
|
return as_cuda_info(stream).as_gpu_mat();
|
|
return as_cuda_info(stream).as_gpu_mat();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ image_type_v2<T> as_cuda(smart_cuda_stream *stream = nullptr) {
|
|
|
|
|
+ return as_cuda_info(stream).as_cuda();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
cv::Size size() const {
|
|
cv::Size size() const {
|
|
|
if (cuda_info.ptr != nullptr) {
|
|
if (cuda_info.ptr != nullptr) {
|
|
|
return cuda_info.size;
|
|
return cuda_info.size;
|