Closed xychen9459 closed 6 years ago
Hi, @MhLiao . I have something unclear about the procedure of cropping an rotated rectangular bounding box.
In line 262 of bbox_util.cpp, the new width and centre coordinates are calculated:
// calculate the new width float half_width = width / 2.; float len_rhalf = ray_length_in_bbox(cx, cy, theta); float len_lhalf = ray_length_in_bbox(cx, cy, M_PI + theta); float clipped_width = std::min(half_width, len_rhalf) + std::min(half_width, len_lhalf); // move center point float clipped_cx, clipped_cy; if (clipped_width < width - eps) { float move_rhalf = (len_rhalf < half_width) ? (len_rhalf - half_width) / 2. : zero; float move_lhalf = (len_lhalf < half_width) ? (half_width - len_lhalf) / 2. : zero; float move_len = move_rhalf + move_lhalf; clipped_cx = cx + std::cos(theta) move_len; clipped_cy = cy + std::sin(theta) move_len; } else { clipped_cx = cx; clipped_cy = cy; }
I can't get the idea of the implementation, especially the calculation of len_rhalf and len_lhalf. Could you explain the detail of implementation?
Thx.
Hi, @MhLiao . I have something unclear about the procedure of cropping an rotated rectangular bounding box.
In line 262 of bbox_util.cpp, the new width and centre coordinates are calculated:
// calculate the new width float half_width = width / 2.; float len_rhalf = ray_length_in_bbox(cx, cy, theta); float len_lhalf = ray_length_in_bbox(cx, cy, M_PI + theta); float clipped_width = std::min(half_width, len_rhalf) + std::min(half_width, len_lhalf); // move center point float clipped_cx, clipped_cy; if (clipped_width < width - eps) { float move_rhalf = (len_rhalf < half_width) ? (len_rhalf - half_width) / 2. : zero; float move_lhalf = (len_lhalf < half_width) ? (half_width - len_lhalf) / 2. : zero; float move_len = move_rhalf + move_lhalf; clipped_cx = cx + std::cos(theta) move_len; clipped_cy = cy + std::sin(theta) move_len; } else { clipped_cx = cx; clipped_cy = cy; }
I can't get the idea of the implementation, especially the calculation of len_rhalf and len_lhalf. Could you explain the detail of implementation?
Thx.