Skip to content

Instantly share code, notes, and snippets.

View mattak's full-sized avatar
👨‍💻
working

Takuma Maruyama mattak

👨‍💻
working
View GitHub Profile
import numpy as np
import pandas as pd
import argparse
def load_points_from_tsv(path: str) -> tuple[np.ndarray, np.ndarray]:
df = pd.read_csv(path, sep='\t')
if not all(col in df.columns for col in ['ID', 'position.x', 'position.y', 'position.z']):
raise ValueError("必要な列 'ID', 'position.x', 'position.y', 'position.z' が見つかりません")
ids = df['ID'].values
@mattak
mattak / calibrate_fisheye.py
Created July 15, 2025 11:00
calibrate_fisheye.py
import cv2
import numpy as np
import glob
import os
import argparse
def calibrate_fisheye(folder_path, pattern_size=(9, 6), square_size=1.0, save_path='fisheye_camera_params.npz'):
# 3D座標の準備(Z=0平面)
objp = np.zeros((1, pattern_size[0] * pattern_size[1], 3), np.float32)
objp[0, :, :2] = np.mgrid[0:pattern_size[0], 0:pattern_size[1]].T.reshape(-1, 2)
@mattak
mattak / calibrate_default.py
Created July 15, 2025 10:59
calibrate_default.py
import cv2
import numpy as np
import glob
import os
import argparse
def calibrate_from_folder(folder_path, pattern_size=(9, 6), square_size=1.0, save_path='camera_params.npz'):
# 実世界のチェスボード上の交点の3D座標(Z=0の平面上)
objp = np.zeros((pattern_size[0] * pattern_size[1], 3), np.float32)
objp[:, :2] = np.mgrid[0:pattern_size[0], 0:pattern_size[1]].T.reshape(-1, 2)
@mattak
mattak / gemma3cmd
Last active March 20, 2025 02:41
Shell command generator by gemma3
#!/bin/bash
set -eu
if [ $# -lt 1 ]; then
cat << __USAGE__
Usage:
$0 <instruction>
Example:
@mattak
mattak / import-env
Last active July 20, 2023 23:25
import-env
#!/bin/bash
for kv in $(< $1)
do
if [[ "$kv" = ^\s*$ ]] || [[ "$kv" =~ ^# ]]; then
continue
fi
export $kv
done
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mattak
mattak / git-prc
Created October 27, 2022 08:29
github pull request creation script
#!/bin/bash
set -e
# optparse
if [ $# -ge 1 ]; then
SOURCE_BRANCH=$1
else
echo "ERROR: source branch not specified"
exit 1
@mattak
mattak / mp4small
Created August 2, 2022 08:27
create small size mp4
#!/bin/sh
set -xe
if [ $# -eq 0 ]; then
echo "usage: <input_mp4>"
exit 1
fi
f1=$1
@mattak
mattak / antlr4
Last active June 21, 2022 13:34
Simple script for using antlr4
#!/bin/sh
set -eu
VERSION="4.10.1"
JAR_DIR="/tmp/antlr4"
if [ ! -d "$JAR_DIR" ]; then
mkdir -p "$JAR_DIR"