关于图像中使用Python/openCV中的多个ROI
当您在图像中选择多个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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论