Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import taichi as ti
from skimage.io import imread, imsave
ti.init(arch=ti.cuda)
@ti.kernel
def normals_from_depth_kernel(f: ti.f32, cx: ti.f32, cy: ti.f32, window_size: ti.u16, max_rel_depth_diff: ti.f32):
height, width = ti_depth.shape()
@valgur
valgur / torch_add_hash.sh
Created May 23, 2020 16:45
Add a checksum string to a state file name for Torch Hub
#!/bin/bash
mv "$1" "${1%.*}"-$(sha256sum "$1" | cut -c1-8).pt
@valgur
valgur / elb_grids.py
Last active March 16, 2021 14:21
Estonian Land Board map sheet (grid) index formulas / Maa-ameti kaardilehtede järjekorranumbrite teisendusvalemid
# x - easting, y - northing
def grid20k(x, y):
x = int(x) // 1000 - 200
y = int(y) // 1000 - 5900
idx = (y // 100) * 1000 + (y // 10 % 10) * 10
idx += (x // 100) * 100 + (x // 10 % 10)
return idx
def grid10k(x, y):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@valgur
valgur / velodyne_decoder vs VeloView ground truth.ipynb
Last active January 12, 2023 09:45
velodyne_decoder v3.0.0 validation against VeloView test datasets
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@valgur
valgur / baseline velodyne_decoder vs VeloView.ipynb
Created January 9, 2023 14:33
velodyne_decoder v2.3.0 validation against VeloView test datasets
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import av
# packets = [H.264 packets as byte arrays]
codec = av.CodecContext.create('h264', 'r')
for packet in packets:
for avpacket in codec.parse(packet):
frames = codec.decode(avpacket)
print(frames)
# Or, can also simply do
@valgur
valgur / hdl64e_s3_calib_data.m
Last active May 4, 2023 15:24
Appendix D: MATLAB Sample Code, from "63‐HDL64ES3 REV K", Velodyne 2013
% Matlab sample code to read calibration data from sensor output.
fileFilter = '*.pcap';
[File_name, Directory] = uigetfile(fileFilter, 'Open a .pcap file');
Filename = [Directory File_name];
fid = fopen(Filename);
ttc = fread(fid, 40);
ttc = fread(fid, 42);
ttc = fread(fid, inf, '1206*uint8=>uint8', 58);
fclose(fid);
# Defines the following helper functions:
# - print_target_properties()
# - print_vars()
# - get_all_targets()
# Adapted from https://stackoverflow.com/a/68881024/2997179
# Print all properties of CMake target.
function(print_target_properties target)
if(NOT TARGET ${target})
@valgur
valgur / init_cc_package.sh
Last active May 9, 2023 19:53
Create a recipe skeleton for a new conan-center-index package.
#!/bin/bash
set -eu -o pipefail
name=$1
version=$2
template=${3:-"cmake_package"}
echo Copying sources...
root=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
pkg_dir=$root/recipes/$name