add util & example
This commit is contained in:
+15
-17
@@ -10,7 +10,6 @@ from enum import Enum, auto
|
||||
from typing import Optional, Tuple, Union, Any
|
||||
from .getDensity import getFilteredDensity
|
||||
from . import configs
|
||||
from .util import draw_arrows, draw_magnitude_map, draw_fps
|
||||
|
||||
class Sensor:
|
||||
"""
|
||||
@@ -56,7 +55,7 @@ class Sensor:
|
||||
self.hhd = None
|
||||
|
||||
# Setup video capture
|
||||
self.__open_video_source()
|
||||
self.__open_video_source(override, box)
|
||||
|
||||
# Logging state
|
||||
self.last_log_time = time.time()
|
||||
@@ -80,7 +79,7 @@ class Sensor:
|
||||
FSHEARY = auto()
|
||||
DEPTH = auto()
|
||||
|
||||
def __open_video_source(self):
|
||||
def __open_video_source(self, override, box):
|
||||
|
||||
# Setup video capture
|
||||
self.cap = cv2.VideoCapture(self.vid_src)
|
||||
@@ -101,12 +100,19 @@ class Sensor:
|
||||
else:
|
||||
raise Exception("Failed to open video source.")
|
||||
|
||||
# Initialize stitching calibration
|
||||
self.__find_stitch_boxes(frame, show=False)
|
||||
self.__get_tiles(frame)
|
||||
self.stitch_cal()
|
||||
if self.verbose:
|
||||
print("Sensor initialized and calibrated.")
|
||||
if override:
|
||||
if box is not None:
|
||||
|
||||
self.isstitch = False
|
||||
self.__stitcher.isstitch = False
|
||||
self.__stitcher.boxes = box
|
||||
else:
|
||||
print("Override is True but no box provided.")
|
||||
else:
|
||||
# Initialize and calibrate
|
||||
self.__find_stitch_boxes(frame, show=False)
|
||||
self.__get_tiles(frame)
|
||||
self.stitch_cal()
|
||||
|
||||
def get_config(self):
|
||||
"""
|
||||
@@ -349,11 +355,3 @@ class Sensor:
|
||||
# print("Image stitched with shape:", img_stitched_height.shape)
|
||||
return img_stitched_height
|
||||
|
||||
# def draw_arrows(self, optical_flow, fps=True, threshold=5, grid_spacing=40, arrow_scale=1.0):
|
||||
# return draw_arrows(self.img, optical_flow, fps, threshold, grid_spacing, arrow_scale)
|
||||
|
||||
# def draw_magnitude_map(self, flow_field, threshold=3.0, colormap=cv2.COLORMAP_JET):
|
||||
# return draw_magnitude_map(self.img, flow_field, threshold, colormap)
|
||||
|
||||
# def draw_fps(self, fps):
|
||||
# return draw_fps(self.img, fps)
|
||||
|
||||
Reference in New Issue
Block a user