Skip to content

Commit

Permalink
Merge pull request #310 from Visual-Behavior/adding_title_to_view
Browse files Browse the repository at this point in the history
Added title to get_view()
  • Loading branch information
Data-Iab authored Jan 12, 2023
2 parents 8cc2758 + cf1b82e commit 2aef5ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions aloscene/renderer/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -93,12 +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)
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)
if self.title is not None:
plt.title(self.title)
plt.show()
plt.close()

Expand Down
6 changes: 3 additions & 3 deletions aloscene/tensors/spatial_augmented_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = [
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 2aef5ad

Please sign in to comment.