Closed marinafridman closed 1 year ago
Hi! @marinafridman
You must multiply normalized postion and the shape of image before converting int.
It's a python example.
import cv2
import numpy as np
img = cv2.imread("img.jpg")
img_h, img_w = img.shape[:2]
labels = np.loadtxt("label.txt")
for label in labels:
class_idx, cx, cy, w, h = label
cx *= img_w
cy *= img_h
w *= img_w
h *= img_h
cx = int(cx)
cy = int(cy)
w = int(w)
h = int(h)
# do your process
Perfect, thank you so much @developer0hye !
Hi!
First off many thanks for the amazing tool. Very handy and simple to use.
I feel a bit stupid, but I'm not sure how to convert the decimal coordinates produced by the program into pixel coordinates.
All of the coordinate values in my label .txt files are decimals between 0 and 1, as shown below.
I saw in issue #40 that that user tried to convert the decimals with an
int()
call... however for me this converts all values to 0.What am I missing here?
Thanks in advance!