diff --git a/src/helpers/sift.py b/src/helpers/sift.py new file mode 100644 index 0000000..d210f8f --- /dev/null +++ b/src/helpers/sift.py @@ -0,0 +1,20 @@ +import numpy as np +import cv2 + +def getSiftData(img): + sift = cv2.SIFT.create(enable_precise_upscale = True) + kp = sift.detect(img, None) + + magnitudes = [keypoint.size for keypoint in kp] + tot_mag = np.sum(magnitudes) + max_mag = np.amax(magnitudes) + avg_mag = np.sum(magnitudes)/len(kp) #TODO: Uhm, why not np.mean?? + std_mag = np.std(magnitudes) + counts = len(kp) + + responses = [keypoint.response for keypoint in kp] + tot_rep = np.sum(responses) + avg_rep = np.mean(responses) + + return (tot_mag, max_mag, avg_mag, std_mag, counts, + tot_rep, avg_rep) \ No newline at end of file diff --git a/src/suite.py b/src/suite.py index 2e14d35..6ae9492 100644 --- a/src/suite.py +++ b/src/suite.py @@ -17,6 +17,7 @@ import matplotlib.pyplot as plt from helpers.statistics import imgStats from helpers.logger import CVSuiteLogger, C_DBUG from helpers.canvas import CVSuiteCanvas +from helpers.sift import getSiftData ## UI config load PROJECT_PATH = pathlib.Path(__file__).parent @@ -395,6 +396,16 @@ class CVSuite: if not part_update: self.drawCannyHM(img, 1, 1) + # SIFT + siftData = getSiftData(img) + self.log.add("SIFT total magnitude", siftData[0]) + self.log.add("SIFT maximum magnitude", siftData[1]) + self.log.add("SIFT average magnitude", siftData[2]) + self.log.add("SIFT std magnitude", siftData[3]) + self.log.add("SIFT counts", siftData[4]) + self.log.add("SIFT total response", siftData[5]) + self.log.add("SIFT average response", siftData[6]) + # Write results to CSV file if not part_update: self.log.update()