Comments (3)
I think the issue might be at rotate_bbox_helper and I fixed it with two changes
angle_rad = -math.radians(degrees)
rotation_matrix = [
round(math.cos(angle_rad), 15),
round(math.sin(angle_rad), 15),
0.0,
round(math.sin(angle_rad), 15),
round(-math.cos(angle_rad), 15),
0.0,
]
rotation_matrix[2], rotation_matrix[5] = transform(
-rotation_center[0], -rotation_center[1], rotation_matrix
)
rotation_matrix[2] += rotation_center[0]
rotation_matrix[5] += rotation_center[1]
# Get rotated image dimensions
src_img_corners = [(0, 0), (src_w, 0), (src_w, src_h), (0, src_h)]
(
rotated_img_min_x,
rotated_img_min_y,
rotated_img_max_x,
rotated_img_max_y,
) = get_enclosing_bbox(src_img_corners, rotation_matrix)
rotated_img_w = rotated_img_max_x - rotated_img_min_x
rotated_img_h = rotated_img_max_y - rotated_img_min_y
Potential solution:
1. rotation matrix initialization:
angle_rad = math.radians(degrees)
rotation_matrix = [
round(math.cos(angle_rad), 15),
round(math.sin(angle_rad), 15),
0.0,
round(-math.sin(angle_rad), 15),
round(math.cos(angle_rad), 15),
0.0,
]
2. coordinate translation: update the transform matrix after the calculation of rotated image corners.
src_img_corners = [(0, 0), (src_w, 0), (src_w, src_h), (0, src_h)]
(
rotated_img_min_x,
rotated_img_min_y,
rotated_img_max_x,
rotated_img_max_y,
) = get_enclosing_bbox(src_img_corners, rotation_matrix)
rotation_matrix[2] += rotated_img_max_x
rotation_matrix[5] += rotated_img_max_y
from augly.
One more fixing:
3. the cropping operation: add the translation operation to the cropped-img rotate_bbox_helper
cropped_w, cropped_h = imutils.rotated_rect_with_max_area(src_w, src_h, degrees)
cropped_img_left, cropped_img_upper, cropped_img_right, cropped_img_lower = (
(rotated_img_w - cropped_w) // 2 + rotated_img_min_x + rotated_img_max_x,
(rotated_img_h - cropped_h) // 2 + rotated_img_min_y + rotated_img_max_y,
(rotated_img_w + cropped_w) // 2 + rotated_img_min_x + rotated_img_max_x,
(rotated_img_h + cropped_h) // 2 + rotated_img_min_y + rotated_img_max_y,
)
from augly.
Test case after fixing : [aligned rotating bbox]
from augly.
Related Issues (20)
- Augly should use system-installed fonts instead of bundled ones HOT 1
- Move test data out of `augly` dir HOT 2
- boost fb HOT 1
- ReplaceSimilarChars text augmenter removes separators and replaces them with one blank space
- one HOT 1
- Support For Keypoints?
- IMPORTANT: AugLy v1.0.0 release
- Path is invalid
- mosaic
- Issue about not specifying the path to the ffmpeg package
- Missing comparison in paper
- Fixed : SimulateTypo type error
- Paraphrasing using AugLy
- Shape issue in `reverb`
- Error Videogear error HOT 2
- AssertionError: Output path invalid: HOT 1
- failed to find libmagic on M1 Mac
- ModuleNotFoundError
- HelpοΌI will not enhance the corresponding json file of the image HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from augly.