From 5394ae7d50b018268609b2f4b668e8e1817eba9e Mon Sep 17 00:00:00 2001 From: Daria Doubine Date: Thu, 8 Dec 2022 15:21:07 +0100 Subject: [PATCH 1/2] 1st commit --- aloscene/renderer/renderer.py | 2 ++ aloscene/tensors/spatial_augmented_tensor.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/aloscene/renderer/renderer.py b/aloscene/renderer/renderer.py index 5a577ace..68dd8ea3 100644 --- a/aloscene/renderer/renderer.py +++ b/aloscene/renderer/renderer.py @@ -93,12 +93,14 @@ def render(self, method="matplotlib", location: str = None, figsize=[6.4, 4.8]): if location is not None: plt.figure(figsize=figsize, tight_layout=True) plt.imshow(self.image) + plt.title("Frame" if self.title is None else self.title, self.image[:, :, ::-1]) plt.savefig(location) plt.close() if method == self.MATPLOTLIB: plt.figure(figsize=figsize, tight_layout=True) plt.imshow(self.image) + plt.title("Frame" if self.title is None else self.title, self.image[:, :, ::-1]) plt.show() plt.close() diff --git a/aloscene/tensors/spatial_augmented_tensor.py b/aloscene/tensors/spatial_augmented_tensor.py index e9969c72..1abb05b5 100644 --- a/aloscene/tensors/spatial_augmented_tensor.py +++ b/aloscene/tensors/spatial_augmented_tensor.py @@ -110,7 +110,7 @@ def append_cam_intrinsic(self, cam_intrinsic: CameraIntrinsic): def append_cam_extrinsic(self, cam_extrinsic: CameraExtrinsic): self._append_child("cam_extrinsic", cam_extrinsic) - def get_view(self, views: list = [], exclude=[], size=None, grid_size=None, **kwargs): + def get_view(self, views: list = [], exclude=[], size=None, grid_size=None, title=None, **kwargs): """Render the spatial augmented tensor. Parameters @@ -130,7 +130,7 @@ def get_view(self, views: list = [], exclude=[], size=None, grid_size=None, **kw """ _views = [v for v in views if isinstance(v, View)] if len(_views) > 0: - return View(Renderer.get_grid_view(_views, grid_size=None, cell_grid_size=size, **kwargs)) + return View(Renderer.get_grid_view(_views, grid_size=None, cell_grid_size=size, **kwargs),title=title) # Include type include_type = [ @@ -194,7 +194,7 @@ def __get_view(sa_tensor: SpatialAugmentedTensor, info={}): grid_size = None view = Renderer.get_grid_view(n_views, grid_size=grid_size, cell_grid_size=size, **kwargs) - return View(view) + return View(view, title=title) def relative_to_absolute(self, x, dim, assert_integer=False): dim = dim.lower() From cf1b82e0cda37df3d1b4f77f3878ce47094f71a5 Mon Sep 17 00:00:00 2001 From: Daria Doubine Date: Thu, 12 Jan 2023 16:48:17 +0100 Subject: [PATCH 2/2] calling title only if title is not none ; typing --- aloscene/renderer/renderer.py | 8 ++++---- aloscene/tensors/spatial_augmented_tensor.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aloscene/renderer/renderer.py b/aloscene/renderer/renderer.py index 68dd8ea3..aee4eb9d 100644 --- a/aloscene/renderer/renderer.py +++ b/aloscene/renderer/renderer.py @@ -4,8 +4,6 @@ import matplotlib.pyplot as plt import matplotlib from abc import ABC, abstractmethod -import numpy as np -import cv2 def adapt_text_size_to_frame(size, frame_size): @@ -93,14 +91,16 @@ def render(self, method="matplotlib", location: str = None, figsize=[6.4, 4.8]): if location is not None: plt.figure(figsize=figsize, tight_layout=True) plt.imshow(self.image) - plt.title("Frame" if self.title is None else self.title, self.image[:, :, ::-1]) + if self.title is not None: + plt.title(self.title) plt.savefig(location) plt.close() if method == self.MATPLOTLIB: plt.figure(figsize=figsize, tight_layout=True) plt.imshow(self.image) - plt.title("Frame" if self.title is None else self.title, self.image[:, :, ::-1]) + if self.title is not None: + plt.title(self.title) plt.show() plt.close() diff --git a/aloscene/tensors/spatial_augmented_tensor.py b/aloscene/tensors/spatial_augmented_tensor.py index 1abb05b5..371e6b7a 100644 --- a/aloscene/tensors/spatial_augmented_tensor.py +++ b/aloscene/tensors/spatial_augmented_tensor.py @@ -130,7 +130,7 @@ def get_view(self, views: list = [], exclude=[], size=None, grid_size=None, titl """ _views = [v for v in views if isinstance(v, View)] if len(_views) > 0: - return View(Renderer.get_grid_view(_views, grid_size=None, cell_grid_size=size, **kwargs),title=title) + return View(Renderer.get_grid_view(_views, grid_size=None, cell_grid_size=size, **kwargs), title=title) # Include type include_type = [