Skip to content

Commit 2aef5ad

Browse files
authored
Merge pull request #310 from Visual-Behavior/adding_title_to_view
Added title to get_view()
2 parents 8cc2758 + cf1b82e commit 2aef5ad

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

aloscene/renderer/renderer.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import matplotlib.pyplot as plt
55
import matplotlib
66
from abc import ABC, abstractmethod
7-
import numpy as np
8-
import cv2
97

108

119
def adapt_text_size_to_frame(size, frame_size):
@@ -93,12 +91,16 @@ def render(self, method="matplotlib", location: str = None, figsize=[6.4, 4.8]):
9391
if location is not None:
9492
plt.figure(figsize=figsize, tight_layout=True)
9593
plt.imshow(self.image)
94+
if self.title is not None:
95+
plt.title(self.title)
9696
plt.savefig(location)
9797
plt.close()
9898

9999
if method == self.MATPLOTLIB:
100100
plt.figure(figsize=figsize, tight_layout=True)
101101
plt.imshow(self.image)
102+
if self.title is not None:
103+
plt.title(self.title)
102104
plt.show()
103105
plt.close()
104106

aloscene/tensors/spatial_augmented_tensor.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def append_cam_intrinsic(self, cam_intrinsic: CameraIntrinsic):
110110
def append_cam_extrinsic(self, cam_extrinsic: CameraExtrinsic):
111111
self._append_child("cam_extrinsic", cam_extrinsic)
112112

113-
def get_view(self, views: list = [], exclude=[], size=None, grid_size=None, **kwargs):
113+
def get_view(self, views: list = [], exclude=[], size=None, grid_size=None, title=None, **kwargs):
114114
"""Render the spatial augmented tensor.
115115
116116
Parameters
@@ -130,7 +130,7 @@ def get_view(self, views: list = [], exclude=[], size=None, grid_size=None, **kw
130130
"""
131131
_views = [v for v in views if isinstance(v, View)]
132132
if len(_views) > 0:
133-
return View(Renderer.get_grid_view(_views, grid_size=None, cell_grid_size=size, **kwargs))
133+
return View(Renderer.get_grid_view(_views, grid_size=None, cell_grid_size=size, **kwargs), title=title)
134134

135135
# Include type
136136
include_type = [
@@ -194,7 +194,7 @@ def __get_view(sa_tensor: SpatialAugmentedTensor, info={}):
194194
grid_size = None
195195

196196
view = Renderer.get_grid_view(n_views, grid_size=grid_size, cell_grid_size=size, **kwargs)
197-
return View(view)
197+
return View(view, title=title)
198198

199199
def relative_to_absolute(self, x, dim, assert_integer=False):
200200
dim = dim.lower()

0 commit comments

Comments
 (0)