LeapImage
code_loader.contract.visualizer_classes.LeapImage
import numpy.typing as npt
from code_loader.contract.enums import LeapDataType
@dataclass
class LeapImage:
data: npt.NDArray[np.float32]
type: LeapDataType = LeapDataType.Image
Examples
Basic Usage
from code_loader.contract.visualizer_classes import LeapImage
import cv2
...
def bgr2rgb_visualizer(data: np.ndarray) -> LeapImage:
im_rgb = cv2.cvtColor(data, cv2.COLOR_BGR2RGB)
return LeapImage(im_rgb)
leap_binder.set_visualizer(
name='bgr2rgb',
function=bgr2rgb_visualizer,
visualizer_type=LeapImage.type
)
Resize Image and Heat-map
import numpy as np
from code_loader.contract.visualizer_classes import LeapImage
from code_loader import le
def resized_image_visualizer(data: npt.NDArray[np.float32]) -> LeapImage:
return LeapImage(np.resize(data, (256, 512, 3)))
def resized_image_visualizer_heatmap(original_size_heatmap: npt.NDArray[np.float32]):
return np.resize(original_size_heatmap, (256, 512))
leap_binder.set_visualizer(
function=resized_image_visualizer,
name='resized_image_visualizer',
visualizer_type=LeapImage.type,
heatmap_visualizer=resized_image_visualizer_heatmap
)
Last updated