【发布时间】:2019-03-28 08:10:43
【问题描述】:
我在一个文件夹中有多个图像,我想对其进行处理并向它们应用一些 opencv 函数。
我正在尝试查找文件夹中存在的每个图像的轮廓。
我可以一次处理一个。
单张图片代码
img = cv2.imread('abc.jpg')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
_, thresh = cv2.threshold(gray,85,155,cv2.THRESH_BINARY_INV)
thresh = cv2.GaussianBlur(thresh,(11,11),0)
_, contours, _ = cv2.findContours(thresh, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
final = cv2.drawContours(img,contours, -1, (0,255,0), 3)
cv2.imshow('Output', final)
cv2.waitKey(0)
cv2.destroyAllWindows()
我想要的是对文件夹中存在的多个图像应用这些操作。
【问题讨论】:
-
使用 for 循环。例如
os.listdir。
标签: python opencv image-processing computer-vision