Compare commits

..

No commits in common. "a8c7581fac292592cdd73b589e13275f6425222a" and "5aba28b120bd6f3e3457ee407c2473ec3daefcee" have entirely different histories.

2 changed files with 7 additions and 41 deletions

View File

@ -3,19 +3,15 @@ import cv2
import os import os
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
DATASET_PATH = "C:\\Users\\tomse\\Downloads\\Dataset\\" DATASET_PATH = "C:\\Users\\tomse\\Documents\\Dataset\\"
DATASET_FOLDERS_LEN = len(os.listdir(DATASET_PATH)) DATASET_FOLDERS_LEN = len(os.listdir(DATASET_PATH))
EARLY_BREAK = 0 EARLY_BREAK = 3
SCALE = 1
# Plataan, Berk, Accasia
sift = cv2.SIFT.create(enable_precise_upscale=True) sift = cv2.SIFT.create(enable_precise_upscale=True)
## Create 2D lists ## ## Create 2D lists ##
max_magnitudes = [[] for x in range(DATASET_FOLDERS_LEN)] max_magnitudes = [[] for x in range(DATASET_FOLDERS_LEN)]
avg_magnitudes = [[] for x in range(DATASET_FOLDERS_LEN)] avg_magnitudes = [[] for x in range(DATASET_FOLDERS_LEN)]
tot_magnitudes = [[] for x in range(DATASET_FOLDERS_LEN)]
counts = [[] for x in range(DATASET_FOLDERS_LEN)] counts = [[] for x in range(DATASET_FOLDERS_LEN)]
## Create other variables ## ## Create other variables ##
@ -23,9 +19,6 @@ labels = ['' for x in range(DATASET_FOLDERS_LEN)]
i = 0 i = 0
for folder in os.listdir(DATASET_PATH): for folder in os.listdir(DATASET_PATH):
if not folder.endswith("_out"):
continue
if EARLY_BREAK: if EARLY_BREAK:
print("Step %d/%d processing %s:"%(i+1, EARLY_BREAK, folder)) print("Step %d/%d processing %s:"%(i+1, EARLY_BREAK, folder))
else: else:
@ -35,28 +28,19 @@ for folder in os.listdir(DATASET_PATH):
## Load an image ## ## Load an image ##
path = DATASET_PATH + folder + "\\" + file path = DATASET_PATH + folder + "\\" + file
full_image = cv2.imread(path, 0) full_image = cv2.imread(path, 0)
image = cv2.resize(full_image, (0, 0), fx=SCALE, fy=SCALE) image = cv2.resize(full_image, (0, 0), fx=0.25, fy=0.25)
## Detect keypoints ## ## Detect keypoints ##
kp = sift.detect(image, None) kp = sift.detect(image, None)
image = cv2.drawKeypoints(
image,
kp,
image,
flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
## Average and Max size ## ## Average and Max size ##
magnitudes = [keypoint.size for keypoint in kp] magnitudes = [keypoint.size for keypoint in kp]
tot_magnitudes[i].append(np.sum(magnitudes))
max_magnitudes[i].append(np.amax(magnitudes)) max_magnitudes[i].append(np.amax(magnitudes))
avg_magnitudes[i].append(np.sum(magnitudes)/len(kp)) avg_magnitudes[i].append(np.sum(magnitudes)/len(kp))
## Number of keypoints ## ## Number of keypoints ##
counts[i].append(len(kp)) counts[i].append(len(kp))
# cv2.imshow("Opencv tech", image)
# cv2.waitKey(0)
## Store labels ## ## Store labels ##
labels[i] = folder labels[i] = folder
@ -70,21 +54,8 @@ print("Done!")
## Plots ## ## Plots ##
fig, ax = plt.subplots() fig, ax = plt.subplots()
# for i in range(DATASET_FOLDERS_LEN): for i in range(DATASET_FOLDERS_LEN):
# ax.scatter(tot_magnitudes[i], max_magnitudes[i],label=labels[i], alpha=0.7) ax.scatter(avg_magnitudes[i], max_magnitudes[i],label=labels[i], alpha=0.7)
# ax.scatter(avg_magnitudes[0], max_magnitudes[0], label=labels[0], alpha=0.7)
# ax.scatter(avg_magnitudes[7], max_magnitudes[7], label=labels[7], alpha=0.7)
# ax.set_xlabel("Gemiddelde magnitude")
# ax.set_ylabel("Maximale magnitude")
# ax.legend()
# ax.grid(True)
# plt.show()
ax.scatter(tot_magnitudes[2], max_magnitudes[2], label='Berk', alpha=0.7)
ax.scatter(tot_magnitudes[3], max_magnitudes[3], label='Els', alpha=0.7)
ax.scatter(tot_magnitudes[7], max_magnitudes[7], label='Plataan', alpha=0.7)
ax.set_xlabel("Total magnitude")
ax.set_ylabel("Maximal magnitude")
ax.legend() ax.legend()
ax.grid(True) ax.grid(True)
plt.show() plt.show()

View File

@ -110,8 +110,6 @@ for folder in os.listdir(input_directory):
if VERBOSE: if VERBOSE:
print("Created folder: " + out_folder) print("Created folder: " + out_folder)
os.mkdir(out_folder) os.mkdir(out_folder)
else:
continue
for file in os.listdir(os.path.join(input_directory, folder)): for file in os.listdir(os.path.join(input_directory, folder)):
## Laad plaatjes in kleur ## ## Laad plaatjes in kleur ##
@ -141,9 +139,6 @@ for folder in os.listdir(input_directory):
corners, corners,
ids) ids)
if VERBOSE:
print("IDs detected:\n", ids)
if ids is None: if ids is None:
print("Skipping: ", filename) print("Skipping: ", filename)
print("=============================================") print("=============================================")