关于图像中使用Python/openCV中的多个ROI

发布于 2025-01-26 15:23:57 字数 448 浏览 2 评论 0原文

当您在图像中选择多个ROI时,如何同时在该图像中同时显示它们,然后选择一个一个选择一个?如何在选择ROI的同一实例中取消选择该图像中的某些ROI? 我在下面写的一些代码。请修改并添加要求。

如果可能的话,还请帮助更改图像本身中所选ROI的宽度和高度。

path=r'D:\abc.jpg'
img_raw = cv2.imread(path)
ROIs = cv2.selectROIs("Select Rois",img_raw,0,0)
print(ROIs)
for roi in ROIs:
    x1=roi[0]
    y1=roi[1]
    x2=roi[2]
    y2=roi[3]
    img_crop=img_raw[y1:y1+y2,x1:x1+x2]
    cv2.imshow(img_crop)
cv2.waitKey(0)
cv2.destroyAllWindows()

When you select multiple ROIs in an image, how to display them all simultaneously in that image white selecting one by one? How to deselect some selected ROIs in that image at the same instance of selecting ROIs?
some of the code I have written below. Please modify and add the requirements.

If possible, please also help in changing the width and height of the selected ROI in the images itself.

path=r'D:\abc.jpg'
img_raw = cv2.imread(path)
ROIs = cv2.selectROIs("Select Rois",img_raw,0,0)
print(ROIs)
for roi in ROIs:
    x1=roi[0]
    y1=roi[1]
    x2=roi[2]
    y2=roi[3]
    img_crop=img_raw[y1:y1+y2,x1:x1+x2]
    cv2.imshow(img_crop)
cv2.waitKey(0)
cv2.destroyAllWindows()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文