Compare commits
No commits in common. "a8c7581fac292592cdd73b589e13275f6425222a" and "5aba28b120bd6f3e3457ee407c2473ec3daefcee" have entirely different histories.
a8c7581fac
...
5aba28b120
@ -3,19 +3,15 @@ import cv2
|
||||
import os
|
||||
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))
|
||||
EARLY_BREAK = 0
|
||||
SCALE = 1
|
||||
|
||||
# Plataan, Berk, Accasia
|
||||
EARLY_BREAK = 3
|
||||
|
||||
sift = cv2.SIFT.create(enable_precise_upscale=True)
|
||||
|
||||
## Create 2D lists ##
|
||||
max_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)]
|
||||
|
||||
## Create other variables ##
|
||||
@ -23,9 +19,6 @@ labels = ['' for x in range(DATASET_FOLDERS_LEN)]
|
||||
i = 0
|
||||
|
||||
for folder in os.listdir(DATASET_PATH):
|
||||
if not folder.endswith("_out"):
|
||||
continue
|
||||
|
||||
if EARLY_BREAK:
|
||||
print("Step %d/%d processing %s:"%(i+1, EARLY_BREAK, folder))
|
||||
else:
|
||||
@ -35,27 +28,18 @@ for folder in os.listdir(DATASET_PATH):
|
||||
## Load an image ##
|
||||
path = DATASET_PATH + folder + "\\" + file
|
||||
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 ##
|
||||
kp = sift.detect(image, None)
|
||||
image = cv2.drawKeypoints(
|
||||
image,
|
||||
kp,
|
||||
image,
|
||||
flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
|
||||
|
||||
## Average and Max size ##
|
||||
magnitudes = [keypoint.size for keypoint in kp]
|
||||
tot_magnitudes[i].append(np.sum(magnitudes))
|
||||
max_magnitudes[i].append(np.amax(magnitudes))
|
||||
avg_magnitudes[i].append(np.sum(magnitudes)/len(kp))
|
||||
|
||||
## Number of keypoints ##
|
||||
counts[i].append(len(kp))
|
||||
|
||||
# cv2.imshow("Opencv tech", image)
|
||||
# cv2.waitKey(0)
|
||||
|
||||
## Store labels ##
|
||||
labels[i] = folder
|
||||
@ -70,21 +54,8 @@ print("Done!")
|
||||
|
||||
## Plots ##
|
||||
fig, ax = plt.subplots()
|
||||
# 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[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()
|
||||
for i in range(DATASET_FOLDERS_LEN):
|
||||
ax.scatter(avg_magnitudes[i], max_magnitudes[i],label=labels[i], alpha=0.7)
|
||||
ax.legend()
|
||||
ax.grid(True)
|
||||
plt.show()
|
||||
plt.show()
|
||||
|
@ -110,8 +110,6 @@ for folder in os.listdir(input_directory):
|
||||
if VERBOSE:
|
||||
print("Created folder: " + out_folder)
|
||||
os.mkdir(out_folder)
|
||||
else:
|
||||
continue
|
||||
|
||||
for file in os.listdir(os.path.join(input_directory, folder)):
|
||||
## Laad plaatjes in kleur ##
|
||||
@ -141,9 +139,6 @@ for folder in os.listdir(input_directory):
|
||||
corners,
|
||||
ids)
|
||||
|
||||
if VERBOSE:
|
||||
print("IDs detected:\n", ids)
|
||||
|
||||
if ids is None:
|
||||
print("Skipping: ", filename)
|
||||
print("=============================================")
|
||||
|
Loading…
Reference in New Issue
Block a user