| @@ -59,31 +59,41 @@ uint32_t parse_bytes(const uint8_t *buf, bool intel_align) { | |||
| int parseExif(const uint8_t *buf, uint32_t len) { | |||
| bool intel_align = true; | |||
| uint32_t offset = 0; | |||
| if (!buf || len < 6) return UNKNOW_ORIENTATION; | |||
| if (!buf || len < 6) { | |||
| return UNKNOW_ORIENTATION; | |||
| } | |||
| if (!std::equal(buf, buf + 6, "Exif\0\0")) return UNKNOW_ORIENTATION; | |||
| if (!std::equal(buf, buf + 6, "Exif\0\0")) { | |||
| return UNKNOW_ORIENTATION; | |||
| } | |||
| offset += 6; | |||
| if (offset + 8 > len) return UNKNOW_ORIENTATION; | |||
| if (offset + 8 > len) { | |||
| return UNKNOW_ORIENTATION; | |||
| } | |||
| if (buf[offset] == 'I' && buf[offset + 1] == 'I') { | |||
| intel_align = true; | |||
| } else if (buf[offset] == 'M' && buf[offset + 1] == 'M') { | |||
| intel_align = false; | |||
| } else { | |||
| if (buf[offset] == 'M' && buf[offset + 1] == 'M') | |||
| intel_align = false; | |||
| else | |||
| return UNKNOW_ORIENTATION; | |||
| return UNKNOW_ORIENTATION; | |||
| } | |||
| offset += 2; | |||
| if (parse_bytes<uint16_t>(buf + offset, intel_align) != 0x2a) return UNKNOW_ORIENTATION; | |||
| if (parse_bytes<uint16_t>(buf + offset, intel_align) != 0x2a) { | |||
| return UNKNOW_ORIENTATION; | |||
| } | |||
| offset += 2; | |||
| uint32_t first_ifd_offset = parse_bytes<uint32_t>(buf + offset, intel_align); | |||
| offset += first_ifd_offset - 4; | |||
| if (offset >= len) return UNKNOW_ORIENTATION; | |||
| if (offset >= len || offset + 2 > len) { | |||
| return UNKNOW_ORIENTATION; | |||
| } | |||
| if (offset + 2 > len) return UNKNOW_ORIENTATION; | |||
| int num_entries = parse_bytes<uint16_t>(buf + offset, intel_align); | |||
| if (offset + 6 + 12 * num_entries > len) return UNKNOW_ORIENTATION; | |||
| if (offset + 6 + 12 * num_entries > len) { | |||
| return UNKNOW_ORIENTATION; | |||
| } | |||
| offset += 2; | |||
| while (num_entries > 0) { | |||
| uint16_t tag = parse_bytes<uint16_t>(buf + offset, intel_align); | |||
| @@ -26,8 +26,11 @@ | |||
| #endif | |||
| #endif | |||
| #define ANGLE_22_5 0.39269908169872414 | |||
| #define ANGLE_67_5 1.1780972450961724 | |||
| constexpr float kAngle22_5 = 0.39269908169872414; | |||
| constexpr float kAngle67_5 = 1.1780972450961724; | |||
| constexpr int kCertainBorder = 2; | |||
| constexpr int kUncertainBorder = 1; | |||
| constexpr int kNotBorder = 0; | |||
| namespace mindspore { | |||
| namespace dataset { | |||
| @@ -153,8 +156,8 @@ static void NonMaximumSuppression(const LiteMat &gx, const LiteMat &gy, LiteMat | |||
| float angle_value = atan2(gy_value_abs, gx_value_abs); | |||
| float edge_value = temp[y * gx.width_ + x]; | |||
| float edge_pre, edge_nex; | |||
| if (angle_value < ANGLE_22_5 || angle_value > ANGLE_67_5) { | |||
| if (angle_value < ANGLE_22_5) { | |||
| if (angle_value < kAngle22_5 || angle_value > kAngle67_5) { | |||
| if (angle_value < kAngle22_5) { | |||
| edge_pre = GetEdge(temp, gx.width_, gx.height_, x - 1, y); | |||
| edge_nex = GetEdge(temp, gx.width_, gx.height_, x + 1, y); | |||
| } else { | |||
| @@ -196,12 +199,12 @@ static void Hysteresis(const LiteMat &edges, uint8_t *dst, double low_thresh, do | |||
| int pos = y * edges.width_ + x; | |||
| float edge_value = edges_ptr[pos]; | |||
| if (edge_value > high_thresh) { | |||
| buffer[pos] = 2; | |||
| buffer[pos] = kCertainBorder; | |||
| stack.push_back(pos); | |||
| } else if (edge_value <= low_thresh) { | |||
| buffer[pos] = 0; | |||
| buffer[pos] = kNotBorder; | |||
| } else { | |||
| buffer[pos] = 1; | |||
| buffer[pos] = kUncertainBorder; | |||
| } | |||
| } | |||
| } | |||
| @@ -220,8 +223,8 @@ static void Hysteresis(const LiteMat &edges, uint8_t *dst, double low_thresh, do | |||
| continue; | |||
| } | |||
| int next = next_y * buffer_step + next_x; | |||
| if (buffer[next] == 1) { | |||
| buffer[next] = 2; | |||
| if (buffer[next] == kUncertainBorder) { | |||
| buffer[next] = kCertainBorder; | |||
| stack.push_back(next); | |||
| } | |||
| } | |||
| @@ -229,7 +232,7 @@ static void Hysteresis(const LiteMat &edges, uint8_t *dst, double low_thresh, do | |||
| } | |||
| for (int i = 0; i < size; i++) { | |||
| if (buffer[i] == 2) { | |||
| if (buffer[i] == kCertainBorder) { | |||
| dst[i] = 255; | |||
| } else { | |||
| dst[i] = 0; | |||
| @@ -14,7 +14,7 @@ | |||
| * limitations under the License. | |||
| */ | |||
| #include <math.h> | |||
| #include <cmath> | |||
| #include "lite_cv/lite_mat.h" | |||
| #include "lite_cv/image_process.h" | |||
| @@ -18,38 +18,36 @@ | |||
| #include <cfloat> | |||
| #include <climits> | |||
| #include <cstring> | |||
| #include <cmath> | |||
| #include <cstring> | |||
| #include <limits> | |||
| #include <vector> | |||
| #include <utility> | |||
| #include <random> | |||
| #include <utility> | |||
| #include <vector> | |||
| #ifdef ENABLE_NEON | |||
| #include <arm_neon.h> | |||
| #endif | |||
| #define R2GRAY 9798 | |||
| #define G2GRAY 19235 | |||
| #define B2GRAY 3735 | |||
| #define GRAYSHIFT 15 | |||
| #define GRAYSHIFT_DELTA (1 << (GRAYSHIFT - 1)) | |||
| #define U32TOU8CAST(value) ((uint8_t)std::min(value, (uint32_t)UCHAR_MAX)) | |||
| #define YSCALE 0x0101 | |||
| #define UTOB (-128) | |||
| #define UTOG 25 | |||
| #define VTOR (-102) | |||
| #define VTOG 52 | |||
| #define YTOG 18997 | |||
| #define YTOGB (-1160) | |||
| #define BTOB (UTOB * 128 + YTOGB) | |||
| #define BTOG (UTOG * 128 + VTOG * 128 + YTOGB) | |||
| #define BTOR (VTOR * 128 + YTOGB) | |||
| #define Equ(a, b) ((std::fabs((a) - (b)) < 1e-6)) | |||
| namespace mindspore { | |||
| namespace dataset { | |||
| constexpr uint32_t kR2Gray = 9798; | |||
| constexpr uint32_t kG2Gray = 19235; | |||
| constexpr uint32_t kB2Gray = 3735; | |||
| constexpr int32_t kGrayShift = 15; | |||
| constexpr int32_t kGrayShiftDelta = 1 << (kGrayShift - 1); | |||
| constexpr int32_t kYScale = 0x0101; | |||
| constexpr int32_t kU2B = -128; | |||
| constexpr int32_t kU2G = 25; | |||
| constexpr int32_t kV2R = -102; | |||
| constexpr int32_t kV2G = 52; | |||
| constexpr int32_t kY2G = 18997; | |||
| constexpr int32_t kY2GB = -1160; | |||
| constexpr int32_t kB2B = kU2B * 128 + kY2GB; | |||
| constexpr int32_t kB2G = kU2G * 128 + kV2G * 128 + kY2GB; | |||
| constexpr int32_t kB2R = kV2R * 128 + kY2GB; | |||
| static bool Equal(const float &a, const float &b) { return std::fabs(a - b) < 1e-6; } | |||
| static inline void InitBilinearWeight(int *data_ptr, int16_t *weight_ptr, double scale, int dst_length, int src_length, | |||
| int a) { | |||
| @@ -240,7 +238,7 @@ static void ResizeBilinear1C(const unsigned char *src, int src_width, int src_he | |||
| delete[] data_buf; | |||
| } | |||
| static inline uint8_t clip(float value, int min = 0, int max = 255) { | |||
| static inline uint8_t clip(float value) { | |||
| int int_val = roundf(value); | |||
| return std::max<int32_t>(std::numeric_limits<uint8_t>::min(), | |||
| std::min<int32_t>(std::numeric_limits<uint8_t>::max(), int_val)); | |||
| @@ -467,18 +465,18 @@ static bool ConvertYUV420SPToBGR(const uint8_t *data, LDataType data_type, bool | |||
| u = uv_buf[0]; | |||
| v = uv_buf[1]; | |||
| } | |||
| uint32_t tmp_y = (uint32_t)(y_buf[0] * YSCALE * YTOG) >> 16; | |||
| uint32_t tmp_y = (uint32_t)(y_buf[0] * kYScale * kY2G) >> 16; | |||
| // b | |||
| bgr_buf[0] = std::clamp((int32_t)(-(u * UTOB) + tmp_y + BTOB) >> 6, 0, 255); | |||
| bgr_buf[0] = std::clamp((int32_t)(-(u * kU2B) + tmp_y + kB2B) >> 6, 0, 255); | |||
| // g | |||
| bgr_buf[1] = std::clamp((int32_t)(-(u * UTOG + v * VTOG) + tmp_y + BTOG) >> 6, 0, 255); | |||
| bgr_buf[1] = std::clamp((int32_t)(-(u * kU2G + v * kV2G) + tmp_y + kB2G) >> 6, 0, 255); | |||
| // r | |||
| bgr_buf[2] = std::clamp((int32_t)(-(v * VTOR) + tmp_y + BTOR) >> 6, 0, 255); | |||
| bgr_buf[2] = std::clamp((int32_t)(-(v * kV2R) + tmp_y + kB2R) >> 6, 0, 255); | |||
| tmp_y = (uint32_t)(y_buf[1] * YSCALE * YTOG) >> 16; | |||
| bgr_buf[3] = std::clamp((int32_t)(-(u * UTOB) + tmp_y + BTOB) >> 6, 0, 255); | |||
| bgr_buf[4] = std::clamp((int32_t)(-(u * UTOG + v * VTOG) + tmp_y + BTOG) >> 6, 0, 255); | |||
| bgr_buf[5] = std::clamp((int32_t)(-(v * VTOR) + tmp_y + BTOR) >> 6, 0, 255); | |||
| tmp_y = (uint32_t)(y_buf[1] * kYScale * kY2G) >> 16; | |||
| bgr_buf[3] = std::clamp((int32_t)(-(u * kU2B) + tmp_y + kB2B) >> 6, 0, 255); | |||
| bgr_buf[4] = std::clamp((int32_t)(-(u * kU2G + v * kV2G) + tmp_y + kB2G) >> 6, 0, 255); | |||
| bgr_buf[5] = std::clamp((int32_t)(-(v * kV2R) + tmp_y + kB2R) >> 6, 0, 255); | |||
| y_buf += 2; | |||
| uv_buf += 2; | |||
| @@ -494,10 +492,10 @@ static bool ConvertYUV420SPToBGR(const uint8_t *data, LDataType data_type, bool | |||
| u = uv_buf[0]; | |||
| v = uv_buf[1]; | |||
| } | |||
| uint32_t tmp_y = (uint32_t)(y_buf[0] * YSCALE * YTOG) >> 16; | |||
| bgr_buf[0] = std::clamp((int32_t)(-(u * UTOB) + tmp_y + BTOB) >> 6, 0, 255); | |||
| bgr_buf[1] = std::clamp((int32_t)(-(u * UTOG + v * VTOG) + tmp_y + BTOG) >> 6, 0, 255); | |||
| bgr_buf[2] = std::clamp((int32_t)(-(v * VTOR) + tmp_y + BTOR) >> 6, 0, 255); | |||
| uint32_t tmp_y = (uint32_t)(y_buf[0] * kYScale * kY2G) >> 16; | |||
| bgr_buf[0] = std::clamp((int32_t)(-(u * kU2B) + tmp_y + kB2B) >> 6, 0, 255); | |||
| bgr_buf[1] = std::clamp((int32_t)(-(u * kU2G + v * kV2G) + tmp_y + kB2G) >> 6, 0, 255); | |||
| bgr_buf[2] = std::clamp((int32_t)(-(v * kV2R) + tmp_y + kB2R) >> 6, 0, 255); | |||
| } | |||
| bgr_ptr += bgr_stride; | |||
| @@ -520,7 +518,7 @@ static bool ConvertRGBAToGRAY(const unsigned char *data, LDataType data_type, in | |||
| const unsigned char *data_ptr = data; | |||
| for (int y = 0; y < h; y++) { | |||
| for (int x = 0; x < w; x++) { | |||
| *ptr = (data_ptr[2] * B2GRAY + data_ptr[1] * G2GRAY + data_ptr[0] * R2GRAY + GRAYSHIFT_DELTA) >> GRAYSHIFT; | |||
| *ptr = (data_ptr[2] * kB2Gray + data_ptr[1] * kG2Gray + data_ptr[0] * kR2Gray + kGrayShiftDelta) >> kGrayShift; | |||
| ptr++; | |||
| data_ptr += 4; | |||
| } | |||
| @@ -665,7 +663,7 @@ bool Crop(const LiteMat &src, LiteMat &dst, int x, int y, int w, int h) { | |||
| static bool CheckZero(const std::vector<float> &vs) { | |||
| for (int i = 0; i < vs.size(); i++) { | |||
| if (Equ(vs[i], 0.0f)) { | |||
| if (Equal(vs[i], 0.0f)) { | |||
| return true; | |||
| } | |||
| } | |||
| @@ -804,6 +802,7 @@ static int PadFromPos(int p, int len, PaddBorderType pad_type) { | |||
| if (pad_type == PaddBorderType::PADD_BORDER_REPLICATE) { | |||
| return p < 0 ? 0 : len - 1; | |||
| } else { | |||
| // calculate the position of pixel in reflect mode like edcb|abcdef|edcb | |||
| return p < 0 ? -p : 2 * len - p - 2; | |||
| } | |||
| } | |||
| @@ -1621,7 +1620,7 @@ bool ConvertRgbToGray(const LiteMat &src, LDataType data_type, int w, int h, Lit | |||
| const unsigned char *data_ptr = src; | |||
| for (int y = 0; y < h; y++) { | |||
| for (int x = 0; x < w; x++) { | |||
| *ptr = (data_ptr[2] * B2GRAY + data_ptr[1] * G2GRAY + data_ptr[0] * R2GRAY + GRAYSHIFT_DELTA) >> GRAYSHIFT; | |||
| *ptr = (data_ptr[2] * kB2Gray + data_ptr[1] * kG2Gray + data_ptr[0] * kR2Gray + kGrayShiftDelta) >> kGrayShift; | |||
| ptr++; | |||
| data_ptr += 3; | |||
| } | |||
| @@ -20,31 +20,42 @@ | |||
| #include "lite_cv/lite_mat.h" | |||
| #include "lite_cv/image_process.h" | |||
| #define BITS 5 | |||
| #define BITS1 15 | |||
| #define TAB_SZ (1 << BITS) | |||
| #define TAB_SZ2 (TAB_SZ * TAB_SZ) | |||
| #define FLOATTOSHORT(value) (IntCastShort(round(value))) | |||
| #define REMAP_SCALE (1 << 15) | |||
| #define INTTOUCHAR(v) ((uint8_t)((unsigned)v <= UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0)) | |||
| #define SrcValue(y, x) (reinterpret_cast<double *>(src + y * 3))[x] | |||
| #define DstValue(y, x) (reinterpret_cast<double *>(dst + y * 3))[x] | |||
| constexpr int kBits = 5; | |||
| constexpr int kBits1 = 15; | |||
| constexpr int kTabSz = 1 << kBits; | |||
| constexpr int kTabSz2 = kTabSz * kTabSz; | |||
| constexpr int kRemapScale = 1 << 15; | |||
| namespace mindspore { | |||
| namespace dataset { | |||
| static int16_t BWBlock_i[TAB_SZ2][2][2]; | |||
| static int16_t BWBlock_i[kTabSz2][2][2]; | |||
| static double SrcValue(const double *src, const int &y, const int &x) { return (src + y * 3)[x]; } | |||
| static double &DstValue(double *dst, const int &y, const int &x) { return (dst + y * 3)[x]; } | |||
| static double GetDet3(double *src) { | |||
| double a1 = SrcValue(0, 0) * (SrcValue(1, 1) * SrcValue(2, 2) - SrcValue(1, 2) * SrcValue(2, 1)); | |||
| double a2 = SrcValue(0, 1) * (SrcValue(1, 0) * SrcValue(2, 2) - SrcValue(1, 2) * SrcValue(2, 0)); | |||
| double a3 = SrcValue(0, 2) * (SrcValue(1, 0) * SrcValue(2, 1) - SrcValue(1, 1) * SrcValue(2, 0)); | |||
| double a1 = | |||
| SrcValue(src, 0, 0) * (SrcValue(src, 1, 1) * SrcValue(src, 2, 2) - SrcValue(src, 1, 2) * SrcValue(src, 2, 1)); | |||
| double a2 = | |||
| SrcValue(src, 0, 1) * (SrcValue(src, 1, 0) * SrcValue(src, 2, 2) - SrcValue(src, 1, 2) * SrcValue(src, 2, 0)); | |||
| double a3 = | |||
| SrcValue(src, 0, 2) * (SrcValue(src, 1, 0) * SrcValue(src, 2, 1) - SrcValue(src, 1, 1) * SrcValue(src, 2, 0)); | |||
| return a1 - a2 + a3; | |||
| } | |||
| static int16_t IntCastShort(int value) { | |||
| return (int16_t)((unsigned)(value - SHRT_MIN) <= (unsigned)USHRT_MAX ? value : value > 0 ? SHRT_MAX : SHRT_MIN); | |||
| static uint8_t UIntToUChar(const uint32_t &v) { | |||
| return static_cast<uint8_t>(v <= UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); | |||
| } | |||
| static int16_t IntCastShort(const int &value) { | |||
| return static_cast<int16_t>(static_cast<unsigned>(value - SHRT_MIN) <= static_cast<unsigned>(USHRT_MAX) | |||
| ? value | |||
| : value > 0 ? SHRT_MAX : SHRT_MIN); | |||
| } | |||
| static int16_t FloatToShort(float value) { return IntCastShort(round(value)); } | |||
| static void InitWBlockInter(float *wBlock, int wBlockSz) { | |||
| float scale = 1.f / wBlockSz; | |||
| for (int i = 0; i < wBlockSz; i++, wBlock += 2) { | |||
| @@ -56,27 +67,27 @@ static void InitWBlockInter(float *wBlock, int wBlockSz) { | |||
| static const void *InitWBlock() { | |||
| static bool initWB = false; | |||
| int16_t *iWBlock = 0; | |||
| int16_t *iWBlock = nullptr; | |||
| int ks = 2; | |||
| iWBlock = BWBlock_i[0][0]; | |||
| if (!initWB) { | |||
| float *_wblock = new float[8 * TAB_SZ]; | |||
| float *_wblock = new float[8 * kTabSz]; | |||
| int i, j, h1, h2; | |||
| InitWBlockInter(_wblock, TAB_SZ); | |||
| for (i = 0; i < TAB_SZ; i++) { | |||
| for (j = 0; j < TAB_SZ; j++, iWBlock += ks * ks) { | |||
| InitWBlockInter(_wblock, kTabSz); | |||
| for (i = 0; i < kTabSz; i++) { | |||
| for (j = 0; j < kTabSz; j++, iWBlock += ks * ks) { | |||
| int sum_i = 0; | |||
| for (h1 = 0; h1 < ks; h1++) { | |||
| float vy = _wblock[i * ks + h1]; | |||
| for (h2 = 0; h2 < ks; h2++) { | |||
| float v = vy * _wblock[j * ks + h2]; | |||
| sum_i += iWBlock[h1 * ks + h2] = FLOATTOSHORT(v * REMAP_SCALE); | |||
| sum_i += iWBlock[h1 * ks + h2] = FloatToShort(v * kRemapScale); | |||
| } | |||
| } | |||
| if (sum_i != REMAP_SCALE) { | |||
| int df = sum_i - REMAP_SCALE; | |||
| if (sum_i != kRemapScale) { | |||
| int df = sum_i - kRemapScale; | |||
| int ks2 = 1; | |||
| int tk1 = ks2; | |||
| int tk2 = ks2; | |||
| @@ -99,14 +110,14 @@ static const void *InitWBlock() { | |||
| } | |||
| } | |||
| } | |||
| iWBlock -= TAB_SZ2 * ks * ks; | |||
| iWBlock -= kTabSz2 * ks * ks; | |||
| delete[] _wblock; | |||
| initWB = true; | |||
| } | |||
| return (const void *)iWBlock; | |||
| } | |||
| static uint8_t CastToFixed(int v) { return INTTOUCHAR(((v + (1 << (BITS1 - 1))) >> BITS1)); } | |||
| static uint8_t CastToFixed(int v) { return UIntToUChar(((v + (1 << (kBits1 - 1))) >> kBits1)); } | |||
| static int BorderPolate(int value, int length, PaddBorderType borderType) { | |||
| if ((unsigned)value < (unsigned)length) { | |||
| @@ -345,7 +356,7 @@ static void Remap(const LiteMat &src, LiteMat &dst, LiteMat &map1, const LiteMat | |||
| const uint16_t *sa_ptr = map2.ptr<uint16_t>(y + y1) + x; | |||
| x1 = 0; | |||
| for (; x1 < bwidth; x1++) { | |||
| t_a_ptr[x1] = (uint16_t)(sa_ptr[x1] & (TAB_SZ2 - 1)); | |||
| t_a_ptr[x1] = (uint16_t)(sa_ptr[x1] & (kTabSz2 - 1)); | |||
| } | |||
| } | |||
| RemapBilinear(src, lite_part, xy_ptr, a_ptr, wblock, borderType, borderValue); | |||
| @@ -401,7 +412,7 @@ bool WarpAffineBilinear(const LiteMat &src, LiteMat &dst, const LiteMat &M, int | |||
| const int B_SIZE = 64; | |||
| int16_t WH[B_SIZE * B_SIZE * 2]; | |||
| int16_t A_Ptr[B_SIZE * B_SIZE]; | |||
| int r_delta = SCALE / TAB_SZ / 2; | |||
| int r_delta = SCALE / kTabSz / 2; | |||
| int x, y, x1, y1; | |||
| for (x = 0; x < dst.width_; x++) { | |||
| a[x] = round(IM[0] * x * SCALE); | |||
| @@ -426,11 +437,11 @@ bool WarpAffineBilinear(const LiteMat &src, LiteMat &dst, const LiteMat &M, int | |||
| int16_t *t_a = A_Ptr + y1 * t_bw; | |||
| x1 = 0; | |||
| for (; x1 < t_bw; x1++) { | |||
| int X = (X0 + a[x + x1]) >> (10 - BITS); | |||
| int Y = (Y0 + b[x + x1]) >> (10 - BITS); | |||
| t_xy[x1 * 2] = IntCastShort(X >> BITS); | |||
| t_xy[x1 * 2 + 1] = IntCastShort(Y >> BITS); | |||
| t_a[x1] = (int16_t)((Y & (TAB_SZ - 1)) * TAB_SZ + (X & (TAB_SZ - 1))); | |||
| int X = (X0 + a[x + x1]) >> (10 - kBits); | |||
| int Y = (Y0 + b[x + x1]) >> (10 - kBits); | |||
| t_xy[x1 * 2] = IntCastShort(X >> kBits); | |||
| t_xy[x1 * 2 + 1] = IntCastShort(Y >> kBits); | |||
| t_a[x1] = (int16_t)((Y & (kTabSz - 1)) * kTabSz + (X & (kTabSz - 1))); | |||
| } | |||
| } | |||
| @@ -449,27 +460,27 @@ static void PerspectiveInvert(double *src, double *dst) { | |||
| value = 1. / value; | |||
| double v[9]; | |||
| v[0] = (SrcValue(1, 1) * SrcValue(2, 2) - SrcValue(1, 2) * SrcValue(2, 1)) * value; | |||
| v[1] = (SrcValue(0, 2) * SrcValue(2, 1) - SrcValue(0, 1) * SrcValue(2, 2)) * value; | |||
| v[2] = (SrcValue(0, 1) * SrcValue(1, 2) - SrcValue(0, 2) * SrcValue(1, 1)) * value; | |||
| v[3] = (SrcValue(1, 2) * SrcValue(2, 0) - SrcValue(1, 0) * SrcValue(2, 2)) * value; | |||
| v[4] = (SrcValue(0, 0) * SrcValue(2, 2) - SrcValue(0, 2) * SrcValue(2, 0)) * value; | |||
| v[5] = (SrcValue(0, 2) * SrcValue(1, 0) - SrcValue(0, 0) * SrcValue(1, 2)) * value; | |||
| v[6] = (SrcValue(1, 0) * SrcValue(2, 1) - SrcValue(1, 1) * SrcValue(2, 0)) * value; | |||
| v[7] = (SrcValue(0, 1) * SrcValue(2, 0) - SrcValue(0, 0) * SrcValue(2, 1)) * value; | |||
| v[8] = (SrcValue(0, 0) * SrcValue(1, 1) - SrcValue(0, 1) * SrcValue(1, 0)) * value; | |||
| DstValue(0, 0) = v[0]; | |||
| DstValue(0, 1) = v[1]; | |||
| DstValue(0, 2) = v[2]; | |||
| DstValue(1, 0) = v[3]; | |||
| DstValue(1, 1) = v[4]; | |||
| DstValue(1, 2) = v[5]; | |||
| DstValue(2, 0) = v[6]; | |||
| DstValue(2, 1) = v[7]; | |||
| DstValue(2, 2) = v[8]; | |||
| v[0] = (SrcValue(src, 1, 1) * SrcValue(src, 2, 2) - SrcValue(src, 1, 2) * SrcValue(src, 2, 1)) * value; | |||
| v[1] = (SrcValue(src, 0, 2) * SrcValue(src, 2, 1) - SrcValue(src, 0, 1) * SrcValue(src, 2, 2)) * value; | |||
| v[2] = (SrcValue(src, 0, 1) * SrcValue(src, 1, 2) - SrcValue(src, 0, 2) * SrcValue(src, 1, 1)) * value; | |||
| v[3] = (SrcValue(src, 1, 2) * SrcValue(src, 2, 0) - SrcValue(src, 1, 0) * SrcValue(src, 2, 2)) * value; | |||
| v[4] = (SrcValue(src, 0, 0) * SrcValue(src, 2, 2) - SrcValue(src, 0, 2) * SrcValue(src, 2, 0)) * value; | |||
| v[5] = (SrcValue(src, 0, 2) * SrcValue(src, 1, 0) - SrcValue(src, 0, 0) * SrcValue(src, 1, 2)) * value; | |||
| v[6] = (SrcValue(src, 1, 0) * SrcValue(src, 2, 1) - SrcValue(src, 1, 1) * SrcValue(src, 2, 0)) * value; | |||
| v[7] = (SrcValue(src, 0, 1) * SrcValue(src, 2, 0) - SrcValue(src, 0, 0) * SrcValue(src, 2, 1)) * value; | |||
| v[8] = (SrcValue(src, 0, 0) * SrcValue(src, 1, 1) - SrcValue(src, 0, 1) * SrcValue(src, 1, 0)) * value; | |||
| DstValue(dst, 0, 0) = v[0]; | |||
| DstValue(dst, 0, 1) = v[1]; | |||
| DstValue(dst, 0, 2) = v[2]; | |||
| DstValue(dst, 1, 0) = v[3]; | |||
| DstValue(dst, 1, 1) = v[4]; | |||
| DstValue(dst, 1, 2) = v[5]; | |||
| DstValue(dst, 2, 0) = v[6]; | |||
| DstValue(dst, 2, 1) = v[7]; | |||
| DstValue(dst, 2, 2) = v[8]; | |||
| } | |||
| } | |||
| @@ -532,15 +543,15 @@ bool WarpPerspectiveBilinear(const LiteMat &src, LiteMat &dst, const LiteMat &M, | |||
| int16_t *t_a = TA + y1 * tw; | |||
| for (int x1 = 0; x1 < tw; x1++) { | |||
| double W = WV + IM[6] * x1; | |||
| W = W ? TAB_SZ / W : 0; | |||
| W = W ? kTabSz / W : 0; | |||
| double fX = std::max((double)INT_MIN, std::min((double)INT_MAX, (XV + IM[0] * x1) * W)); // NOLINT | |||
| double fY = std::max((double)INT_MIN, std::min((double)INT_MAX, (YV + IM[3] * x1) * W)); // NOLINT | |||
| int X = round(fX); | |||
| int Y = round(fY); | |||
| xy[x1 * 2] = IntCastShort(X >> BITS); | |||
| xy[x1 * 2 + 1] = IntCastShort(Y >> BITS); | |||
| t_a[x1] = (int16_t)((Y & (TAB_SZ - 1)) * TAB_SZ + (X & (TAB_SZ - 1))); | |||
| xy[x1 * 2] = IntCastShort(X >> kBits); | |||
| xy[x1 * 2 + 1] = IntCastShort(Y >> kBits); | |||
| t_a[x1] = (int16_t)((Y & (kTabSz - 1)) * kTabSz + (X & (kTabSz - 1))); | |||
| } | |||
| } | |||
| LiteMat _matA(tw, th, 1, TA, LDataType::UINT16); | |||
| @@ -22,8 +22,8 @@ import subprocess | |||
| import sys | |||
| import mindspore | |||
| def main(): | |||
| def main(): | |||
| """Entry point for cache service""" | |||
| cache_admin_dir = os.path.join(os.path.dirname(mindspore.__file__), "bin") | |||
| os.chdir(cache_admin_dir) | |||
| @@ -13,8 +13,8 @@ | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| */ | |||
| #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_DATASETOPS_SOURCE_ALBUM_ANDROID_OP_H_ | |||
| #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_DATASETOPS_SOURCE_ALBUM_ANDROID_OP_H_ | |||
| #ifndef MINDSPORE_LITE_MINDDATA_WRAPPER_ALBUM_OP_ANDROID_H_ | |||
| #define MINDSPORE_LITE_MINDDATA_WRAPPER_ALBUM_OP_ANDROID_H_ | |||
| #include <deque> | |||
| #include <memory> | |||
| @@ -190,4 +190,4 @@ class AlbumOp { | |||
| }; | |||
| } // namespace dataset | |||
| } // namespace mindspore | |||
| #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_DATASETOPS_SOURCE_ALBUM_ANDROID_OP_H_ | |||
| #endif // MINDSPORE_LITE_MINDDATA_WRAPPER_ALBUM_OP_ANDROID_H_ | |||