将边界框区域保存为图像在自定义文件夹中。

huangapple go评论40阅读模式
英文:

Saving bounding box region as an image in a custom folder

问题

我有一个在交通标志牌上进行训练的自定义训练过的yolov5模型。每当它识别到交通标志时,它会在交通标志牌周围绘制一个边界框。我希望将该边界框保存为一个图像在一个自定义文件夹中。

我需要在yolo v5的任何文件中进行更改吗?

英文:

I have a custom trained yolov5 model trained on traffic sign boards. It draws a bounding box around the traffic sign board whenever it recognizes a traffic sign. I want that bounding box to be saved as an image in a custom folder.

Do I have to make changes in any file of yolo v5.

答案1

得分: 1

# 你可能会在文件中找到一行代码,看起来类似于这样:

cv2.rectangle(image, (x, y), (x+w, y+h), (255, 255, 255), 3)

在这种情况下'image' 表示保存图像的变量名称使用这行代码将应用边界框

要将结果图像保存到文件中您可以使用 'imwrite' 方法

cv2.imwrite('folder/filename.bmp', image)

其中 'image' 是存储图像的变量在您的情况下可能有不同的名称 - 检查上面带有 "rectangle" 方法的那一行)。此外请在引号中指定文件夹和文件名在保存时无需在之前创建文件夹
英文:

You will probably have a line in the file that looks more or less like this:

cv2.rectangle(image, (x, y), (x+w, y+h), (255, 255, 255), 3)

In this case, 'image' means the name of the variable that holds your image. With this line of code, the bounding box is applied.

To save the resulting image to a file, you can use the imwrite method:

cv2.imwrite('folder/filename.bmp', image)

where 'image' is the variable storing the image (in your case it may be named different - check the line above with "rectangle" method). Also, please specify the folder and file name in quotes. The folder does not need to be created by you before the moment of saving.

huangapple
  • 本文由 发表于 2023年7月24日 18:20:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76753515.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定