c# - Convert OpenImage Coordinates to DarkNet format
问题描述
How can i Converting Screen space Coordinates to DarkNet Yolo format?
Image Dimensions:
width: 1024
height: 768
Box Dimensions:
x: 51.84
y: 175.359741
width: 988.16
height: 639.999756
Normalization i understand with the division of point to image, as x = x/width but to convert the x,y,width,height coordination to darknet format.
if anyone can point me in a c# direction
btw what is the darknet format called?, since the original is screen-space. that would make googling a lot easier.
解决方案
这可能会有所帮助。YOLO 格式为:
<object-class> <x_center> <y_center> <width> <height>
其中所有<x_center> , <y_center> , <width> , <height>
都是相对于图像宽度和高度的浮点值,它可以等于从 0.0 到 1.0。
- 宽度 = 对象宽度 / 图像宽度
- 高度 = 物体高度 / 图像高度
- x_center 和 y_center 是每个对象的中心坐标
例如,要计算中心:
- x_center = (x_min + (x_max - x_min)/2) / image_width
- y_center = (y_min + (y_max - y_min)/2) / image_width
在您的示例中:
width = 988.16 / 1024
height = 639.999756 / 768
x_center = (51.84 + 988.16) / (2 * 1024)
y_center = (175.359741 + 639.999756) / (2 * 768)
我不确定你的文本文件是什么样子的。如果您可以发布一个文本文件示例以供阅读和转换,这将有所帮助。我也不知道暗网格式叫什么。
推荐阅读
- google-apps-script - 如果两个对应的单元格匹配,则删除行
- json - 如何将一些 json 文件解析为列表
- php - 使用 PHP 连接到 MySQL 的问题
- javascript - 为什么我的javascript类实例中的方法看不到属性
- python - sqlite3.OperationalError) Heroku 上没有这样的表
- android - 此处 zoomTo 忽略 ViewRect X 和 Y 位置
- c# - PDFsharp 无法从 Crystal Reports CR23 编码的文档中读取文本
- java - 如何使用 do-while 循环程序修复这个随机数猜谜游戏?
- c++ - Arcball 相机:如何获得正确、方向和向上
- thymeleaf - 将列表绑定到单个输入字段 - spring boot thymeleaf