首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >yolo包装箱

yolo包装箱
EN

Stack Overflow用户
提问于 2018-03-06 02:07:39
回答 3查看 7.6K关注 0票数 4

我正在使用YOLO做一个机器学习项目。我正在创建自己的数据集,遵循“找到这里”指南(在部分,如何训练(以检测自定义对象))。对于包围框,我需要知道我想在给定的图片中训练YOLO的每个对象的x宽度。到目前为止,我已经找到了手工,但它正在变得非常耗时。我希望能得到一些帮助,写一个脚本,可以为我计算这个。我知道opencv有一些很好的图像处理工具,但不知道从哪里开始寻找对象坐标。

EN

回答 3

Stack Overflow用户

发布于 2018-03-06 05:02:36

在您提到的页面中,有一个部分包含指向执行这些框的工具的链接:

如何标记对象的有界框并创建注释文件: 在这里,您可以找到用于标记有界对象框和为Yolo v2:标记生成注释文件的GUI软件存储库。

票数 1
EN

Stack Overflow用户

发布于 2019-01-11 11:46:13

我也面临着同样的问题,但在我的例子中,数据是视频的,背景是一样的,所以我做了背景减法,你可以通过调整一些阈值来尝试这个代码,也许你可以得到你想要的。

代码语言:javascript
复制
import cv2
import numpy as np 

# read and scale down image
# wget https://bigsnarf.files.wordpress.com/2017/05/hammer.png
img = cv2.pyrDown(cv2.imread('hammer.png', cv2.IMREAD_UNCHANGED))

# threshold image
ret, threshed_img = cv2.threshold(cv2.cvtColor(img, cv2.COLOR_BGR2GRAY),
                127, 255, cv2.THRESH_BINARY)
# find contours and get the external one
image, contours, hier = cv2.findContours(threshed_img, cv2.RETR_TREE,
                cv2.CHAIN_APPROX_SIMPLE)

# with each contour, draw boundingRect in green
# a minAreaRect in red and
# a minEnclosingCircle in blue
for c in contours:
    # get the bounding rect
    x, y, w, h = cv2.boundingRect(c)
    # draw a green rectangle to visualize the bounding rect
    cv2.rectangle(img, (x, y), (x+w, y+h), (0, 255, 0), 2)

    # get the min area rect
    rect = cv2.minAreaRect(c)
    box = cv2.boxPoints(rect)
    # convert all coordinates floating point values to int
    box = np.int0(box)
    # draw a red 'nghien' rectangle
    cv2.drawContours(img, [box], 0, (0, 0, 255))

    # finally, get the min enclosing circle
    (x, y), radius = cv2.minEnclosingCircle(c)
    # convert all values to int
    center = (int(x), int(y))
    radius = int(radius)
    # and draw the circle in blue
    img = cv2.circle(img, center, radius, (255, 0, 0), 2)

print(len(contours))
cv2.drawContours(img, contours, -1, (255, 255, 0), 1)

cv2.imshow("contours", img)

ESC = 27
while True:
    keycode = cv2.waitKey()
    if keycode != -1:
        keycode &= 0xFF
        if keycode == ESC:
            break
cv2.destroyAllWindows()
票数 0
EN

Stack Overflow用户

发布于 2020-06-14 22:32:05

这里有一些来自尤洛-马克-普瓦源代码的部分,如您所见,它比原始的Yolo_mark (在右角单击github图标,在检查src/utils/createExportCord.tssrc/utils/readExportCord.ts之后)可读性强得多。naturalWidthnaturalWidth是图像大小,heightwidth是蓝色矩形大小。

代码语言:javascript
复制
namespace mark {

  export namespace utils {

    export const createExportCord = ({
      name, height, width, top, left, naturalHeight, naturalWidth
    }) => {
      console.log({name, height, width, top, left, naturalHeight, naturalWidth});

      const x = (left + (width/2)) / naturalWidth;
      const y = (top + (height/2)) / naturalHeight;
      const w = width / naturalWidth;
      const h = height / naturalHeight;

      return [name, x, y, w, h].join(' ');
    }

  } // namespace utils

} // namespace mark

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49122356

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档