浏览代码

began local feature approach

Felix Kleinsteuber 3 年之前
父节点
当前提交
d0c133cc7e
共有 5 个文件被更改,包括 90 次插入5 次删除
  1. 二进制
      Cache_NoBackup/approach3_cluster10.npy
  2. 2 2
      approach1b_histograms.ipynb
  3. 3 3
      approach2_background_estimation.ipynb
  4. 55 0
      approach3_local_features.ipynb
  5. 30 0
      py/Session.py

二进制
Cache_NoBackup/approach3_cluster10.npy


文件差异内容过多而无法显示
+ 2 - 2
approach1b_histograms.ipynb


文件差异内容过多而无法显示
+ 3 - 3
approach2_background_estimation.ipynb


文件差异内容过多而无法显示
+ 55 - 0
approach3_local_features.ipynb


+ 30 - 0
py/Session.py

@@ -1,6 +1,7 @@
 from datetime import datetime, timedelta
 from datetime import datetime, timedelta
 import pickle
 import pickle
 import random
 import random
+import cv2 as cv
 import subprocess
 import subprocess
 from warnings import warn
 from warnings import warn
 import os
 import os
@@ -225,6 +226,15 @@ class Session:
         for file, date in self.motion_dates.items():
         for file, date in self.motion_dates.items():
             yield MotionImage(self, file, date)
             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):
     def get_closest_lapse_images(self, motion_file: str):
         """Returns the lapse images taken closest before and after this image, respectively.
         """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:
         if scale is not None and scale < 1:
             img = transform.rescale(img, scale, multichannel=not gray)
             img = transform.rescale(img, scale, multichannel=not gray)
         return img
         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):
     def is_daytime(self):
         return 6 <= self.date.hour <= 18
         return 6 <= self.date.hour <= 18

部分文件因为文件数量过多而无法显示