Skip to content

Instantly share code, notes, and snippets.

View ionymikler's full-sized avatar

Jonathan (iony) Mikler ionymikler

View GitHub Profile
@ionymikler
ionymikler / dictionary_print.py
Last active November 22, 2024 16:34
better (recursive) dictionary print
def print_dict(dictionary, ident='', braces=1):
""" Recursively prints nested dictionaries."""
cached_dicts = []
for key, value in dictionary.items():
if isinstance(value, dict):
cached_dicts.append((key, value))
else:
print(f'{ident}{key} = {value}')
for key, value in cached_dicts:
@ionymikler
ionymikler / bbox_3d_utils.py
Created April 28, 2024 15:47
generation of a 3D bounding box from shape, position and orientation + function to plot it. Though for torch tensors to maintain operations in variables.
import matplotlib.pyplot as plt
import numpy as np
import torch
def generate_corners3d(whl:torch.Tensor, ry:torch.Tensor=[0], pos:torch.Tensor=[0,0], depth:torch.Tensor=[0]) -> torch.Tensor:
"""
https://github.com/ZrrSkywalker/MonoDETR/blob/main/lib/datasets/kitti/kitti_utils.py
Generates a representation of 3D bounding box(es) as 8 corners in camera coordinates.