added sift to logger output
This commit is contained in:
parent
156e4a9961
commit
6582fa01d6
20
src/helpers/sift.py
Normal file
20
src/helpers/sift.py
Normal 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)
|
11
src/suite.py
11
src/suite.py
@ -17,6 +17,7 @@ import matplotlib.pyplot as plt
|
|||||||
from helpers.statistics import imgStats
|
from helpers.statistics import imgStats
|
||||||
from helpers.logger import CVSuiteLogger, C_DBUG
|
from helpers.logger import CVSuiteLogger, C_DBUG
|
||||||
from helpers.canvas import CVSuiteCanvas
|
from helpers.canvas import CVSuiteCanvas
|
||||||
|
from helpers.sift import getSiftData
|
||||||
|
|
||||||
## UI config load
|
## UI config load
|
||||||
PROJECT_PATH = pathlib.Path(__file__).parent
|
PROJECT_PATH = pathlib.Path(__file__).parent
|
||||||
@ -395,6 +396,16 @@ class CVSuite:
|
|||||||
if not part_update:
|
if not part_update:
|
||||||
self.drawCannyHM(img, 1, 1)
|
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
|
# Write results to CSV file
|
||||||
if not part_update:
|
if not part_update:
|
||||||
self.log.update()
|
self.log.update()
|
||||||
|
Loading…
Reference in New Issue
Block a user