英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论