Browse Source

!12944 [MD] fix array deleting problem in Canny

From: @tiancixiao
Reviewed-by: @liucunwei,@heleiwang
Signed-off-by: @liucunwei
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 5 years ago
parent
commit
c9ac0da266
2 changed files with 9 additions and 9 deletions
  1. +5
    -5
      mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/CMakeLists.txt
  2. +4
    -4
      mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/canny.cc

+ 5
- 5
mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/CMakeLists.txt View File

@@ -1,8 +1,8 @@
file(GLOB_RECURSE _CURRENT_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
set_property(SOURCE ${_CURRENT_SRC_FILES} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_MD)
add_library(lite-cv OBJECT
image_process.cc
warp_affine.cc
gaussian_blur.cc
canny.cc
lite_mat.cc)
canny.cc
gaussian_blur.cc
image_process.cc
lite_mat.cc
warp_affine.cc)

+ 4
- 4
mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/canny.cc View File

@@ -98,7 +98,7 @@ bool Sobel(const LiteMat &src, LiteMat &dst, int flag_x, int flag_y, int ksize,
return ConvRowCol(src, kx, ky, dst, LDataType::FLOAT32, pad_type);
}

static float GetEdge(const float *temp, int width, int height, int x, int y) {
static float GetEdge(const std::vector<float> &temp, int width, int height, int x, int y) {
if (x >= 0 && y >= 0 && x < width && y < height) {
return temp[y * width + x];
} else {
@@ -114,7 +114,7 @@ static void NonMaximumSuppression(const LiteMat &gx, const LiteMat &gy, LiteMat
float *edges_ptr = edges;

int size = gx.height_ * gx.width_;
float *temp = new float[size];
std::vector<float> temp(size);
for (int i = 0; i < size; i++) {
float gx_value = gx_ptr[i];
float gy_value = gy_ptr[i];
@@ -177,9 +177,9 @@ static void Hysteresis(const LiteMat &edges, uint8_t *dst, double low_thresh, do
uint8_t *dst_ptr = dst;

int size = edges.height_ * edges.width_;
int *buffer = new int[size];
int buffer_step = edges.width_;
std::vector<int> stack;
std::vector<int> buffer(size);
int buffer_step = edges.width_;
for (int y = 0; y < edges.height_; y++) {
for (int x = 0; x < edges.width_; x++) {
int pos = y * edges.width_ + x;


Loading…
Cancel
Save