基于Yolov7的路面病害检测代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 line
960B

  1. class BoundingBox:
  2. def __init__(self, classID, confidence, x1, x2, y1, y2, image_width, image_height):
  3. self.classID = classID
  4. self.confidence = confidence
  5. self.x1 = x1
  6. self.x2 = x2
  7. self.y1 = y1
  8. self.y2 = y2
  9. self.u1 = x1 / image_width
  10. self.u2 = x2 / image_width
  11. self.v1 = y1 / image_height
  12. self.v2 = y2 / image_height
  13. def box(self):
  14. return (self.x1, self.y1, self.x2, self.y2)
  15. def width(self):
  16. return self.x2 - self.x1
  17. def height(self):
  18. return self.y2 - self.y1
  19. def center_absolute(self):
  20. return (0.5 * (self.x1 + self.x2), 0.5 * (self.y1 + self.y2))
  21. def center_normalized(self):
  22. return (0.5 * (self.u1 + self.u2), 0.5 * (self.v1 + self.v2))
  23. def size_absolute(self):
  24. return (self.x2 - self.x1, self.y2 - self.y1)
  25. def size_normalized(self):
  26. return (self.u2 - self.u1, self.v2 - self.v1)