HumanSignal / HumanSignal/label-studio

Export Data: Option-> JSON-Min; Rotated bonding boxes has rotation problem

Open
#9,547 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
28.3k
Forks
3.7k
Avg merge
14h
Merged PRs (30d)
15

Description

**Describe the bug**
Actually I selected the template OCR and used rotated bonding boxes while annotations now which I export it through the JSON_MIN export it giving me four values (x1, y1, w, h, rotation) but which I try to draw It considering the code of opencv and it gives me it wrong drawn annotation.

**Code**
'''
image_name = json['ocr']
bboxes = json['bbox'] # list (x, y, width, height, rotation)
transcription = json['transcription'] # list()

image_path = os.path.join(IMAGES_PATH, image_name.split("/")[-1])
image = cv2.imread(image_path)
image = cv2.resize(image, (678, 340))
o_h, o_w, _ = image.shape

for Idx, (box, text) in enumerate(zip(bboxes, transcription)):

img_width, img_height = int(box['original_width']), int(box['original_height'])
w, h = box['width'], box['height']
x, y = box['x'], box['y']
rot = box['rotation']

x, y = x / 100 * img_width, y / 100 * img_height
w, h = w / 100 * img_width, h / 100 * img_height

xc, yc = x + w/2, y + h/2
rect_rotated = cv2.boxPoints(((xc, yc), (w, h), rot)).astype(int)
cv2.polylines(image, [rect_rotated], True, (0, 255, 0), 2)
'''

**Screenshots**
screenshot is attached.
![Image](https://github.com/user-attachments/assets/c4fdd367-ae3c-457f-8e63-3ac69d38c819)

**Environment (please complete the following information):**
- OS: [e.g. iOS]
- Label Studio Version 1.22.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.