计算FirebaseVisionText.Element之间的距离

时间:2019-05-20 21:38:36

标签: android firebase firebase-mlkit

我正在使用FirebaseVisionText从图片中读取数据。识别出的所有单词都存储在FirebaseVisionText.Element中。它具有相同的方法,例如:

  • getBoundingBox():返回检测到的文本的与轴对齐的边界矩形。
  • getCornerPoints():从左上角开始沿顺时针方向获取四个角点。

我想计算每个识别的元素之间的距离。换句话说,每个元素框的第一个角之间的距离。

例如:

elementOne.getBoundingBox() -> Rect(1297, 2190 - 1608, 2282)
elementTwo.getBoundingBox() -> Rect(1378, 1772 - 1639, 1860)

distance = sqrt((1297-1378)^2 + (2190-1772)^2) = 425

0 个答案:

没有答案