提交 6d72a86b 编写于 作者: L LielinJiang 提交者: whs

fix_roi_transform_bug (#19785)

上级 3fd3b663
...@@ -128,11 +128,11 @@ void get_transform_matrix(const int transformed_width, ...@@ -128,11 +128,11 @@ void get_transform_matrix(const int transformed_width,
T estimated_width = (len1 + len3) / 2.0; T estimated_width = (len1 + len3) / 2.0;
// Get the normalized height and normalized width // Get the normalized height and normalized width
int normalized_height = transformed_height; int normalized_height = std::max(2, transformed_height);
int normalized_width = int normalized_width =
std::round(estimated_width * (normalized_height - 1) / estimated_height) + std::round(estimated_width * (normalized_height - 1) / estimated_height) +
1; 1;
normalized_width = std::min(normalized_width, transformed_width); normalized_width = std::max(2, std::min(normalized_width, transformed_width));
T dx1 = x1 - x2; T dx1 = x1 - x2;
T dx2 = x3 - x2; T dx2 = x3 - x2;
...@@ -141,9 +141,9 @@ void get_transform_matrix(const int transformed_width, ...@@ -141,9 +141,9 @@ void get_transform_matrix(const int transformed_width,
T dy2 = y3 - y2; T dy2 = y3 - y2;
T dy3 = y0 - y1 + y2 - y3; T dy3 = y0 - y1 + y2 - y3;
matrix[6] = (dx3 * dy2 - dx2 * dy3) / (dx1 * dy2 - dx2 * dy1) / matrix[6] = (dx3 * dy2 - dx2 * dy3) / (dx1 * dy2 - dx2 * dy1 + 1e-5) /
(normalized_width - 1); (normalized_width - 1);
matrix[7] = (dx1 * dy3 - dx3 * dy1) / (dx1 * dy2 - dx2 * dy1) / matrix[7] = (dx1 * dy3 - dx3 * dy1) / (dx1 * dy2 - dx2 * dy1 + 1e-5) /
(normalized_height - 1); (normalized_height - 1);
matrix[8] = 1; matrix[8] = 1;
......
...@@ -242,10 +242,10 @@ __device__ void get_transform_matrix(const int transformed_width, ...@@ -242,10 +242,10 @@ __device__ void get_transform_matrix(const int transformed_width,
T estimated_width = (len1 + len3) / 2.0; T estimated_width = (len1 + len3) / 2.0;
// Get the normalized height and normalized width // Get the normalized height and normalized width
int normalized_height = transformed_height; int normalized_height = max(2, transformed_height);
int normalized_width = int normalized_width =
round(estimated_width * (normalized_height - 1) / estimated_height) + 1; round(estimated_width * (normalized_height - 1) / estimated_height) + 1;
normalized_width = min(normalized_width, transformed_width); normalized_width = max(2, min(normalized_width, transformed_width));
T dx1 = x1 - x2; T dx1 = x1 - x2;
T dx2 = x3 - x2; T dx2 = x3 - x2;
...@@ -254,9 +254,9 @@ __device__ void get_transform_matrix(const int transformed_width, ...@@ -254,9 +254,9 @@ __device__ void get_transform_matrix(const int transformed_width,
T dy2 = y3 - y2; T dy2 = y3 - y2;
T dy3 = y0 - y1 + y2 - y3; T dy3 = y0 - y1 + y2 - y3;
matrix[6] = (dx3 * dy2 - dx2 * dy3) / (dx1 * dy2 - dx2 * dy1) / matrix[6] = (dx3 * dy2 - dx2 * dy3) / (dx1 * dy2 - dx2 * dy1 + 1e-5) /
(normalized_width - 1); (normalized_width - 1);
matrix[7] = (dx1 * dy3 - dx3 * dy1) / (dx1 * dy2 - dx2 * dy1) / matrix[7] = (dx1 * dy3 - dx3 * dy1) / (dx1 * dy2 - dx2 * dy1 + 1e-5) /
(normalized_height - 1); (normalized_height - 1);
matrix[8] = 1; matrix[8] = 1;
......
...@@ -87,10 +87,10 @@ def get_transform_matrix(transformed_width, transformed_height, roi_x, roi_y): ...@@ -87,10 +87,10 @@ def get_transform_matrix(transformed_width, transformed_height, roi_x, roi_y):
estimated_height = (len2 + len4) / 2.0 estimated_height = (len2 + len4) / 2.0
estimated_width = (len1 + len3) / 2.0 estimated_width = (len1 + len3) / 2.0
normalized_height = transformed_height normalized_height = max(2, transformed_height)
normalized_width = round(estimated_width * normalized_width = round(estimated_width *
(normalized_height - 1) / estimated_height) + 1 (normalized_height - 1) / estimated_height) + 1
normalized_width = min(normalized_width, transformed_width) normalized_width = max(2, min(normalized_width, transformed_width))
dx1 = x1 - x2 dx1 = x1 - x2
dx2 = x3 - x2 dx2 = x3 - x2
...@@ -99,9 +99,9 @@ def get_transform_matrix(transformed_width, transformed_height, roi_x, roi_y): ...@@ -99,9 +99,9 @@ def get_transform_matrix(transformed_width, transformed_height, roi_x, roi_y):
dy2 = y3 - y2 dy2 = y3 - y2
dy3 = y0 - y1 + y2 - y3 dy3 = y0 - y1 + y2 - y3
matrix = np.zeros([9]) matrix = np.zeros([9])
matrix[6] = (dx3 * dy2 - dx2 * dy3) / (dx1 * dy2 - dx2 * dy1) / ( matrix[6] = (dx3 * dy2 - dx2 * dy3) / (dx1 * dy2 - dx2 * dy1 + 1e-5) / (
normalized_width - 1) normalized_width - 1)
matrix[7] = (dx1 * dy3 - dx3 * dy1) / (dx1 * dy2 - dx2 * dy1) / ( matrix[7] = (dx1 * dy3 - dx3 * dy1) / (dx1 * dy2 - dx2 * dy1 + 1e-5) / (
normalized_height - 1) normalized_height - 1)
matrix[8] = 1 matrix[8] = 1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册