You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had an issue reading the JSON file. I think it isn't a good idea to use lists to read each lines in this case.
Therefore I changed the code and I suggest you to prefer dictionary research to retrieve the points (also it is less expensive because it is not necessary to read the picture).
In my case, I use rectangle bounding boxes and just one detection class :
with open(txt_path) as json_file:
data = json.load(json_file)
w = data["imageWidth"]
h = data["imageHeight"]
for idx, shapes in enumerate(data["shapes"]):
x1 = shapes["points"][0][0]
y1 = shapes["points"][0][1]
x2 = shapes["points"][1][0]
y2 = shapes["points"][1][1]
cls = str(0) # just one class in my object detection project
xmin = min(x1, x2)
xmax = max(x1, x2)
ymin = min(y1, y2)
ymax = max(y1, y2)
b = (xmin, xmax, ymin, ymax)
bb = convert((w, h), b)
txt_outfile.write(cls + " " + " ".join([str(a) for a in bb]) + '\n')
The text was updated successfully, but these errors were encountered:
I had an issue reading the JSON file. I think it isn't a good idea to use lists to read each lines in this case.
Therefore I changed the code and I suggest you to prefer dictionary research to retrieve the points (also it is less expensive because it is not necessary to read the picture).
In my case, I use rectangle bounding boxes and just one detection class :
The text was updated successfully, but these errors were encountered: