Exemple #1
0
import matplotlib.pyplot as plt
from datetime import datetime as d

# initialize the image descriptor
cd = ColorDescriptor()

# load the query image
query = cv2.imread('queries/3_301.jpg')

# Set the timer
now = d.now()
current = now.strftime("%H:%M:%S")
print(current)

# describe LBP features and perform the search
lbp_features = cd.calculate_lbp(query)
lbp_searcher = Searcher("lbp_value.csv")
lbp_results = lbp_searcher.search(lbp_features)
print(lbp_results)

# Set the timer
now = d.now()
current = now.strftime("%H:%M:%S")
print(current)

# Plot result images from LBP

filenames = []
for (score, resultID) in lbp_results:
    filenames.append("Corel/" + resultID)
print(filenames)
dir_images = 'Corel'

imgs = os.listdir(dir_images)

# Set the timer
now = d.now()
current = now.strftime("%H:%M:%S")
print(current)

# Store imageID and LBP features

output = open("lbp_value.csv", "w")
for imgnm in imgs:
	img_rgb = plt.imread(os.path.join(dir_images,imgnm))
	imageID = imgnm
	features = cd.calculate_lbp(img_rgb)
    
	# write the features to file
	features = [str(f) for f in features]
	output.write("%s,%s\n" % (imageID, ",".join(features)))

output.close()

# Set the timer
now = d.now()
current = now.strftime("%H:%M:%S")
print(current)

# Store imageID and BEM features
i = 0
output = open("bem_value.csv", "w")