added sift to logger output

This commit is contained in:
Tom Selier 2023-10-21 09:42:55 +02:00
parent 156e4a9961
commit 6582fa01d6
2 changed files with 31 additions and 0 deletions

20
src/helpers/sift.py Normal file
View File

@ -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)

View File

@ -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()