HumanSignal / HumanSignal/label-studio
RotatedRectangle bounding box rectangle is not pure rectangle in annotation
- Dominant language
- TypeScript
- Stars
- 28.3k
- Forks
- 3.7k
- Avg merge
- 14h
- Merged PRs (30d)
- 15
Description
**Is your feature request related to a problem? Please describe.**
I have creatd some label using bounding box for my image segmentation project. As my object always have four edges. I wanted to see create segmentation mask from it, which also have four edges(sometimes it is rectangle, sometimes square). But exporting annotation the bounding box seems not fully rectangle.
I have used following code from the annotation to see the bounding box
x = (sn_output['value']['x']) * sn_output['original_width'] / 100
y = (sn_output['value']['y']) * sn_output['original_height'] / 100
w = sn_output['value']['width'] * sn_output['original_width'] / 100
r = sn_output['value']['rotation'] / (180) * math.pi
first_point = np.array([x,y])
second_point = np.array([first_point[0] + math.cos(r+0/2*math.pi) * w, first_point[1] + math.sin(r+0/2*math.pi) * w])
third_point = np.array([second_point[0] + math.cos(r+1/2*math.pi) * h, second_point[1] + math.sin(r+1/2*math.pi) * h])
fourth_point = np.array([third_point[0] + math.cos(r+2/2*math.pi) * w, third_point[1] + math.sin(r+2/2*math.pi) * w])
box3 = np.array([first_point, second_point, third_point, fourth_point], dtype=int)
new_img = img.copy()
cv2.drawContours(new_img, [box3], 0,(255),1)
fig, ax= plt.subplots(figsize=(5, 5))
ax.imshow(new_img[570:640,530:700])
where sn_output =query_data[0]['annotations'][0]['result']
I wanted to create segmenttion mask from but the if the square is not straight, how could the segmentation mask will be square. My question is how to get perfect square from it.
One thing I have tried is
new_img = img.copy()
cv2.drawContours(new_img, [box3], 0,(255),-1, lineType=cv2.LINE_AA)
fig, ax= plt.subplots(figsize=(5, 5))
ax.imshow(new_img[570:640,530:700])
Then the lines are straight, but then it is not a binary mask . I am not sure whether it is a bug, or I am making some type of mistake.
Expected behaviour for me will be when I create a rotated rectangle, Then I should get also pure rotated rectangle, not the broken line like this. It would be highly appreciated, if you could show me whether I am making some types of mistake

Contributor guide
Assessment
This issue has not been assessed yet.