【问题标题】:Get transformation from small bounding box to larger bounding box获得从小边界框到大边界框的转换
【发布时间】:2020-05-27 15:58:01
【问题描述】:

我有图像中一个大边界框的四个角的坐标,我还有一个较大边界框内的较小边界框的坐标。 python代码中是否有任何方法可以获取从小框坐标到大框坐标的转换信息,以便我可以将此转换应用于任何框坐标并接收其相应的较大框坐标?也许使用 openCV?

【问题讨论】:

    标签: python opencv transform coordinate-transformation


    【解决方案1】:

    您可以只使用简单的比率,
    如果你用左下角和右上角坐标定义你的盒子。

    smallBox = ((x0, y0), (x1, y1))
    bigBox = ((x2, y2), (x3, y3))
    width = lambda box: box[1][0] - box[0][0]
    length = lambda box: box[1][1] - box[0][1]
    ratio = (width(bigBox)/width(smallBox), length(bigBox)/length(smallBox))
    transform_axis = lambda axis, units: bigBox[0][axis]+(units - smallBox[0][axis])*ratio[axis]
    transform = lambda x, y: (transform_axis(0, x), transform_axis(1, y))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-13
      • 2021-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-03
      • 2011-03-21
      相关资源
      最近更新 更多