mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-10 02:50:19 +08:00
[CVCUDA] PaddleDetection preprocessor support CV-CUDA (#1493)
* ppdet preproc use manager * pad_to_size chw opencv * pad_to_size chw flycv * fix pad_to_size flycv * add warning message * cvcuda convert cubic to linear, padToSize cvcuda * stridedpad cvcuda * fix flycv include * fix flycv include * fix flycv build * cast cvcuda * fix pybind * fix normalize permute cuda * base processor move funcs to cc * Update pad_to_size.cc
This commit is contained in:
@@ -186,9 +186,8 @@ cv::Mat ConvertFlyCVMatToOpenCV(fcv::Mat& fim) {
|
||||
}
|
||||
#endif
|
||||
|
||||
cv::Mat CreateZeroCopyOpenCVMatFromBuffer(
|
||||
int height, int width, int channels,
|
||||
FDDataType type, void* data) {
|
||||
cv::Mat CreateZeroCopyOpenCVMatFromBuffer(int height, int width, int channels,
|
||||
FDDataType type, void* data) {
|
||||
cv::Mat ocv_mat;
|
||||
switch (type) {
|
||||
case FDDataType::UINT8:
|
||||
@@ -219,61 +218,61 @@ cv::Mat CreateZeroCopyOpenCVMatFromBuffer(
|
||||
return ocv_mat;
|
||||
}
|
||||
|
||||
cv::Mat CreateZeroCopyOpenCVMatFromTensor(const FDTensor& tensor) {
|
||||
// TODO(qiuyanjun): Should add a Layout checking. Now, we
|
||||
// assume that the input tensor is already in Layout::HWC.
|
||||
FDASSERT(tensor.shape.size() == 3, "When create OepnCV Mat from tensor,"
|
||||
"tensor shape should be 3-Dim, HWC layout");
|
||||
cv::Mat CreateZeroCopyOpenCVMatFromTensor(const FDTensor& tensor,
|
||||
Layout layout) {
|
||||
FDASSERT(tensor.shape.size() == 3,
|
||||
"When create OepnCV Mat from tensor,"
|
||||
"tensor shape should be 3-Dim");
|
||||
FDDataType type = tensor.dtype;
|
||||
int height = static_cast<int>(tensor.shape[0]);
|
||||
int width = static_cast<int>(tensor.shape[1]);
|
||||
int channels = static_cast<int>(tensor.shape[2]);
|
||||
return CreateZeroCopyOpenCVMatFromBuffer(
|
||||
height, width, channels, type,
|
||||
const_cast<void*>(tensor.CpuData()));
|
||||
if (layout == Layout::CHW) {
|
||||
channels = static_cast<int>(tensor.shape[0]);
|
||||
height = static_cast<int>(tensor.shape[1]);
|
||||
width = static_cast<int>(tensor.shape[2]);
|
||||
}
|
||||
return CreateZeroCopyOpenCVMatFromBuffer(height, width, channels, type,
|
||||
const_cast<void*>(tensor.CpuData()));
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FLYCV
|
||||
fcv::Mat CreateZeroCopyFlyCVMatFromBuffer(
|
||||
int height, int width, int channels,
|
||||
FDDataType type, void* data) {
|
||||
fcv::Mat CreateZeroCopyFlyCVMatFromBuffer(int height, int width, int channels,
|
||||
FDDataType type, void* data) {
|
||||
fcv::Mat fcv_mat;
|
||||
auto fcv_type = CreateFlyCVDataType(type, channels);
|
||||
switch (type) {
|
||||
case FDDataType::UINT8:
|
||||
fcv_mat =
|
||||
fcv::Mat(width, height, fcv_type, data);
|
||||
fcv_mat = fcv::Mat(width, height, fcv_type, data);
|
||||
break;
|
||||
case FDDataType::FP32:
|
||||
fcv_mat =
|
||||
fcv::Mat(width, height, fcv_type, data);
|
||||
fcv_mat = fcv::Mat(width, height, fcv_type, data);
|
||||
break;
|
||||
case FDDataType::FP64:
|
||||
fcv_mat =
|
||||
fcv::Mat(width, height, fcv_type, data);
|
||||
break;
|
||||
fcv_mat = fcv::Mat(width, height, fcv_type, data);
|
||||
break;
|
||||
default:
|
||||
FDASSERT(false,
|
||||
"Tensor type %d is not supported While calling "
|
||||
"CreateZeroCopyFlyCVMat.",
|
||||
"Tensor type %d is not supported While calling "
|
||||
"CreateZeroCopyFlyCVMat.",
|
||||
type);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
return fcv_mat;
|
||||
}
|
||||
|
||||
fcv::Mat CreateZeroCopyFlyCVMatFromTensor(const FDTensor& tensor) {
|
||||
// TODO(qiuyanjun): Should add a Layout checking. Now, we
|
||||
// assume that the input tensor is already in Layout::HWC.
|
||||
FDASSERT(tensor.shape.size() == 3, "When create FlyCV Mat from tensor,"
|
||||
"tensor shape should be 3-Dim, HWC layout");
|
||||
// TODO(qiuyanjun): Should add a Layout checking. Now, we
|
||||
// assume that the input tensor is already in Layout::HWC.
|
||||
FDASSERT(tensor.shape.size() == 3,
|
||||
"When create FlyCV Mat from tensor,"
|
||||
"tensor shape should be 3-Dim, HWC layout");
|
||||
FDDataType type = tensor.dtype;
|
||||
int height = static_cast<int>(tensor.shape[0]);
|
||||
int width = static_cast<int>(tensor.shape[1]);
|
||||
int channels = static_cast<int>(tensor.shape[2]);
|
||||
return CreateZeroCopyFlyCVMatFromBuffer(
|
||||
height, width, channels, type,
|
||||
const_cast<void*>(tensor.Data()));
|
||||
return CreateZeroCopyFlyCVMatFromBuffer(height, width, channels, type,
|
||||
const_cast<void*>(tensor.Data()));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user