【发布时间】:2019-12-06 03:09:55
【问题描述】:
我想将一个文件与 Cloudinary 路径中的完整照片路径进行比较,但我不知道如何做。有人可以帮我吗?
这是我用于本地路径的代码
import cv2
import os
import cloudinary
directory = './images'
upload = cv2.imread("images/img1.jpg")
for entry in os.listdir(directory):
if entry.lower().endswith( ('.jpg', '.jpeg', '.png', '.gif') ):
fullname = os.path.join(directory, entry)
print('fullname:', fullname)
duplicate = cv2.imread(fullname)
if upload.shape == duplicate.shape:
print("The images have same size and channels")
#difference = cv2.subtract(upload, duplicate)
#b, g, r = cv2.split(difference)
#if cv2.countNonZero(b) == 0 and cv2.countNonZero(g) == 0 and cv2.countNonZero(r) == 0:
if (upload == duplicate).all():
print("images are the same")
else:
print("images are different")
【问题讨论】:
-
在这种情况下,您必须从 http 链接读取图像。
import urllib.request as req url = 'your-url-to-image-file' req.urlretrieve(url, "filename.jpg") img = cv2.imread('filename.jpg') -
这是否也适用于一个 Cloudinary 存储中的多个文件?
-
循环遍历cloudinary storage中文件夹中的所有文件。
-
我该怎么做?
-
你的意思是 res.cloudinairy.com/cloudname/ ?
标签: python opencv cloudinary