Browse Source

!7997 [Data]fix lite_cv bug for codex_c++ warning

Merge pull request !7997 from xulei/lite_test0905
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
a4465a2b04
3 changed files with 13 additions and 8 deletions
  1. +6
    -5
      mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc
  2. +2
    -2
      mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.h
  3. +5
    -1
      mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/lite_mat.cc

+ 6
- 5
mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.cc View File

@@ -130,7 +130,7 @@ static void ResizeBilinear3C(const unsigned char *src, int src_width, int src_he
for (int k = 0; k < dst_width * 3; k++) {
int16_t t0 = (int16_t)((y_weight[0] * (int16_t)(*row0_ptr0++)) >> 16);
int16_t t1 = (int16_t)((y_weight[1] * (int16_t)(*row1_ptr1++)) >> 16);
*dst_ptr++ = (unsigned char)((t0 + t1 + 2) >> 2);
*dst_ptr++ = static_cast<unsigned char>((t0 + t1 + 2) >> 2);
}
y_weight += 2;
}
@@ -202,7 +202,7 @@ static void ResizeBilinear1C(const unsigned char *src, int src_width, int src_he
for (int k = 0; k < dst_width; k++) {
int16_t t0 = (int16_t)((y_weight[0] * (int16_t)(*row0_ptr0++)) >> 16);
int16_t t1 = (int16_t)((y_weight[1] * (int16_t)(*row1_ptr1++)) >> 16);
*dst_ptr++ = (unsigned char)((t0 + t1 + 2) >> 2);
*dst_ptr++ = static_cast<unsigned char>((t0 + t1 + 2) >> 2);
}

y_weight += 2;
@@ -873,7 +873,8 @@ std::vector<int> ApplyNms(const std::vector<std::vector<float>> &all_boxes, std:
}

template <typename Pixel_Type>
bool ImplementAffine(LiteMat &src, LiteMat &out_img, double M[6], std::vector<size_t> &dsize, Pixel_Type borderValue) {
bool ImplementAffine(LiteMat &src, LiteMat &out_img, const double M[6], std::vector<size_t> &dsize,
Pixel_Type borderValue) {
if (dsize.size() != 2 || CheckZero(dsize)) {
return false;
}
@@ -912,11 +913,11 @@ bool ImplementAffine(LiteMat &src, LiteMat &out_img, double M[6], std::vector<si
return true;
}

bool Affine(LiteMat &src, LiteMat &out_img, double M[6], std::vector<size_t> dsize, UINT8_C1 borderValue) {
bool Affine(LiteMat &src, LiteMat &out_img, const double M[6], std::vector<size_t> dsize, UINT8_C1 borderValue) {
return ImplementAffine(src, out_img, M, dsize, borderValue);
}

bool Affine(LiteMat &src, LiteMat &out_img, double M[6], std::vector<size_t> dsize, UINT8_C3 borderValue) {
bool Affine(LiteMat &src, LiteMat &out_img, const double M[6], std::vector<size_t> dsize, UINT8_C3 borderValue) {
return ImplementAffine(src, out_img, M, dsize, borderValue);
}



+ 2
- 2
mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/image_process.h View File

@@ -91,10 +91,10 @@ bool Split(const LiteMat &src, std::vector<LiteMat> &mv);
bool Merge(const std::vector<LiteMat> &mv, LiteMat &dst);

/// \brief Apply affine transformation for 1 channel image
bool Affine(LiteMat &src, LiteMat &out_img, double M[6], std::vector<size_t> dsize, UINT8_C1 borderValue);
bool Affine(LiteMat &src, LiteMat &out_img, const double M[6], std::vector<size_t> dsize, UINT8_C1 borderValue);

/// \brief Apply affine transformation for 3 channel image
bool Affine(LiteMat &src, LiteMat &out_img, double M[6], std::vector<size_t> dsize, UINT8_C3 borderValue);
bool Affine(LiteMat &src, LiteMat &out_img, const double M[6], std::vector<size_t> dsize, UINT8_C3 borderValue);

/// \brief Get default anchor boxes for Faster R-CNN, SSD, YOLO etc
std::vector<std::vector<float>> GetDefaultBoxes(const BoxesConfig config);


+ 5
- 1
mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/lite_mat.cc View File

@@ -26,6 +26,7 @@ LiteMat::LiteMat() {
channel_ = 0;
c_step_ = 0;
dims_ = 0;
size_ = 0;
data_type_ = LDataType::UINT8;
ref_count_ = 0;
}
@@ -199,7 +200,10 @@ void *LiteMat::AlignMalloc(unsigned int size) {
return nullptr;
}

void LiteMat::AlignFree(void *ptr) { (void)free(reinterpret_cast<void **>(ptr)[-1]); }
void LiteMat::AlignFree(void *ptr) {
(void)free(reinterpret_cast<void **>(ptr)[-1]);
ptr = nullptr;
}

inline void LiteMat::InitElemSize(LDataType data_type) { elem_size_ = data_type.SizeInBytes(); }



Loading…
Cancel
Save