[英]How to find a file/ data from a given data set in python- opencv image processing project?
我在一個圖像處理項目中有一個圖像數據集。 我想輸入圖像並瀏覽數據集以識別給定圖像。 我應該使用哪種模塊/庫/方法(例如:ML)在python-opencv代碼中標識圖像?
要查找完全相同的圖像 ,您不需要任何類型的ML。 該圖像只是一個像素數組,因此您可以檢查輸入圖像的數組是否等於數據集中的圖像。
import glob
import cv2
import numpy as np
# Read in source image (the one you want to match to others in the dataset)
source = cv2.imread('test.jpg')
# Make a list of all the images in the dataset (I assume they are images in a directory)
filelist = glob.glob(r'C:\Users\...\Images\*.JPG')
# Loop through the images, read them in and check if an image is equal to your source
for file in filelist:
img = cv2.imread(file)
if np.array_equal(source, img):
print("%s is the same image as source" %(file))
break
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.