Skip to content

Instantly share code, notes, and snippets.

View HViktorTsoi's full-sized avatar

KINO HViktorTsoi

  • CUHK
  • Hong Kong
View GitHub Profile
@HViktorTsoi
HViktorTsoi / numpy_2_pointcloud2.py
Created June 19, 2021 05:33
Convert numpy array to PointCloud2 msg
import numpy as np
import ros_numpy
from sensor_msgs.msg import PointCloud2
"""
pc: 2d numpy array of shape (N, 4)
"""
pc_array = np.zeros(len(pc), dtype=[
@HViktorTsoi
HViktorTsoi / geometry_transform.py
Created June 18, 2021 14:10
Geometry Transform
def transform_pointcloud(T_X_2_pc, pc):
"""
transform pointcloud to frame X with transformation T_X_2_pc
:param T_x_2_pc: a transform matrix of shape(4, 4)
:param pc: a 2d array of shape (N, D) (the first 3 dim of D is x, y, z; the rest dim can be any extra data)
:return: a 2d array of shape (N, D)
"""
pc[:, :3] = np.matmul(
T_X_2_pc,
np.column_stack([pc[:, :3], np.ones(len(pc)).reshape(-1, 1)]).T
@HViktorTsoi
HViktorTsoi / umeyama.py
Created May 14, 2021 18:18
Python implementation of umeyama algorithm.
import numpy as np
def umeyama(X, Y):
# From https://gist.github.com/CarloNicolini/7118015
# and https://github.com/ethz-asl/maplab/blob/master/test/end-to-end-common/python/end_to_end_common/umeyama.py
assert X.shape[0] == 3
assert Y.shape[0] == 3
assert X.shape[1] > 0
assert Y.shape[1] > 0
@HViktorTsoi
HViktorTsoi / save_pcd_odom.py
Last active April 29, 2021 17:56 — forked from hyxhope/save_pcd_odom.py
save_pcd_odom.py
# !/usr/bin/env python3
# coding=utf-8
from __future__ import print_function, division, absolute_import
import rospy
from sensor_msgs.msg import PointCloud2
from nav_msgs.msg import Odometry
import cv2
from cv_bridge import CvBridge, CvBridgeError
@HViktorTsoi
HViktorTsoi / KITTI_to_COCO.py
Last active February 15, 2025 15:12
KITTI object, tracking, segmentation to COCO format.
import functools
import json
import os
import random
import shutil
from collections import defaultdict
import matplotlib.pyplot as plt
import pycocotools
from pycocotools import mask
@HViktorTsoi
HViktorTsoi / groundtruth_mapping.py
Last active September 9, 2022 03:11
Use the groundtruth of KITTI odometry dataset for mapping.
import array
import cv2
import numpy as np
import numpy.linalg as LA
import open3d as o3d
import matplotlib.pyplot as plt
def load_calib(calib_file_path):
"""
@HViktorTsoi
HViktorTsoi / GAN-evaluation.md
Last active June 25, 2024 13:37
GAN生成图像评价标准(Updating)

GAN生成图像质量评价标准

1. Inception Score

将生成图像送进inception, 得到1x1000的预测向量;

1. 如果生成的样本比较真实,那么Inception应该给出某个比较明确的类别, 向量中某个值比较高, 因此预测向量的信息熵越低越好;

2. 如果生成的样本多样性好,那么对于产生的一批样本,其对应的这批类别标签的分布应该比较均匀(各个类别都生成了一些), 因此类别标签的信息熵越高越好;
@HViktorTsoi
HViktorTsoi / ShadowHighlightCorrection.py
Last active November 17, 2025 13:47
Image shadow and highlight correction/adujstment with opencv.
import numpy as np
import cv2
def correction(
img,
shadow_amount_percent, shadow_tone_percent, shadow_radius,
highlight_amount_percent, highlight_tone_percent, highlight_radius,
color_percent
):
"""
@HViktorTsoi
HViktorTsoi / CMakeLists.txt
Created November 25, 2020 08:50
Get all variables in CMakeLists.txt
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
@HViktorTsoi
HViktorTsoi / install_pcl.md
Last active January 26, 2021 12:30
Installation guide for PCL