Yolov5: Output bounding box coordinates

Created on 30 Oct 2020  路  4Comments  路  Source: ultralytics/yolov5

鉂擰uestion

I'd like to output the coordinates of a detection in the format of the original image to be used to draw bounding boxes at a later stage.

Additional context

Currently it looks like data saved in output txt file is class, centroids, w, h but not as it relates to original image, instead it is in a normalized format, how to revert to original?
thanks

Stale question

Most helpful comment

From detect example script, this is the code your looking for.

You end up with upper left corner (x,y) lower right corner (x,y) in im0 coordinate space

det[:, :4] = scale_coords(img.shape[2:], det[:, :4], im0.shape).round()
for *xyxy, conf, cls in reversed(det):
c1, c2 = (int(xyxy[0]), int(xyxy[1])), (int(xyxy[2]), int(xyxy[3]))

All 4 comments

Hello @jayabrams, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook Open In Colab, Docker Image, and Google Cloud Quickstart Guide for example environments.

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom model or data training question, please note Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

  • Cloud-based AI systems operating on hundreds of HD video streams in realtime.
  • Edge AI integrated into custom iOS and Android apps for realtime 30 FPS video inference.
  • Custom data training, hyperparameter evolution, and model exportation to any destination.

For more information please visit https://www.ultralytics.com.

From detect example script, this is the code your looking for.

You end up with upper left corner (x,y) lower right corner (x,y) in im0 coordinate space

det[:, :4] = scale_coords(img.shape[2:], det[:, :4], im0.shape).round()
for *xyxy, conf, cls in reversed(det):
c1, c2 = (int(xyxy[0]), int(xyxy[1])), (int(xyxy[2]), int(xyxy[3]))

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xinxin342 picture xinxin342  路  3Comments

jaqub-manuel picture jaqub-manuel  路  4Comments

dereyly picture dereyly  路  4Comments

abhiksark picture abhiksark  路  3Comments

Alex-afka picture Alex-afka  路  3Comments