fix 'cvtcolor' error in the preprocessing of single channel images ()

pull/1670/head
Li Zhang 2023-01-20 00:04:42 +08:00 committed by GitHub
parent 513b1c3cfb
commit 8bb3fcc6d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions
csrc/mmdeploy
operation/cuda
preprocess/transform

View File

@ -90,10 +90,11 @@ class CvtColorImpl : public CvtColor {
auto height = src.height();
auto width = src.width();
auto channels = src.channel();
auto stride = width * channels;
auto src_channels = src.channel();
auto src_stride = width * src_channels;
Mat dst_mat(height, width, dst_fmt, src.type(), device());
auto dst_stride = width * dst_mat.channel();
auto convert = [&](auto type) -> Result<void> {
using T = typename decltype(type)::type;
@ -101,8 +102,8 @@ class CvtColorImpl : public CvtColor {
if (!converter) {
return Status(eNotSupported);
}
auto ret =
converter(cuda_stream, height, width, stride, src.data<T>(), stride, dst_mat.data<T>());
auto ret = converter(cuda_stream, height, width, src_stride, src.data<T>(), dst_stride,
dst_mat.data<T>());
if (ret != ppl::common::RC_SUCCESS) {
return Status(eFail);
}

View File

@ -61,7 +61,7 @@ class PrepareImage : public Transform {
if (color_type_ == "color" || color_type_ == "color_ignore_orientation") {
OUTCOME_TRY(cvt_color_.Apply(src_mat, dst_mat, PixelFormat::kBGR));
} else {
OUTCOME_TRY(cvt_color_.Apply(dst_mat, dst_mat, PixelFormat::kGRAYSCALE));
OUTCOME_TRY(cvt_color_.Apply(src_mat, dst_mat, PixelFormat::kGRAYSCALE));
}
auto tensor = to_tensor(dst_mat);
if (to_float32_) {