Parcourir la source

began local feature approach

Felix Kleinsteuber il y a 3 ans
Parent
commit
d0c133cc7e

BIN
Cache_NoBackup/approach3_cluster10.npy


Fichier diff supprimé car celui-ci est trop grand
+ 2 - 2
approach1b_histograms.ipynb


Fichier diff supprimé car celui-ci est trop grand
+ 3 - 3
approach2_background_estimation.ipynb


Fichier diff supprimé car celui-ci est trop grand
+ 55 - 0
approach3_local_features.ipynb


+ 30 - 0
py/Session.py

@@ -1,6 +1,7 @@
 from datetime import datetime, timedelta
 import pickle
 import random
+import cv2 as cv
 import subprocess
 from warnings import warn
 import os
@@ -225,6 +226,15 @@ class Session:
         for file, date in self.motion_dates.items():
             yield MotionImage(self, file, date)
 
+    def generate_lapse_images(self):
+        """Yields all lapse images in this session.
+
+        Yields:
+            LapseImage: A LapseImage
+        """
+        for file, date in self.lapse_dates.items():
+            yield LapseImage(self, file, date)
+
     
     def get_closest_lapse_images(self, motion_file: str):
         """Returns the lapse images taken closest before and after this image, respectively.
@@ -296,6 +306,26 @@ class SessionImage:
         if scale is not None and scale < 1:
             img = transform.rescale(img, scale, multichannel=not gray)
         return img
+    
+    def read_opencv(self, truncate_y = (40, 40), scale=1, gray=True):
+        full_path = self.get_full_path()
+        img = cv.imread(full_path)
+        # grayscale
+        if gray:
+            img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
+        # truncate
+        if truncate_y is not None:
+            if truncate_y[0] > 0 and truncate_y[1] > 0:
+                img = img[truncate_y[0]:(-truncate_y[1])]
+            elif truncate_y[0] > 0:
+                img = img[truncate_y[0]:]
+            elif truncate_y[1] > 0:
+                img = img[:(-truncate_y[1])]
+        # scale
+        if scale is not None and scale < 1:
+            img = cv.resize(img, None, fx=scale, fy=scale, interpolation=cv.INTER_LINEAR)
+        return img
+        
 
     def is_daytime(self):
         return 6 <= self.date.hour <= 18

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff