Skip to content

Instantly share code, notes, and snippets.

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

Takuma Maruyama mattak

👨‍💻
working
View GitHub Profile
@mattak
mattak / mq-adb-pull-h264-rm-latest
Created February 10, 2026 03:24
Pull latest video screencapture on MetaQuest, convert the file to h264 compression, remove original video on device.
#!/bin/bash
set -eu
# --- Configuration ---
REMOTE_DIR="/sdcard/Oculus/VideoShots"
LOCAL_TMP_DIR="/tmp"
CONVERT_QUALITY=32
# Scale long side to 1920px while maintaining aspect ratio
SCALE_FILTER="scale='if(gt(iw,ih),1920,-2)':'if(gt(ih,iw),1920,-2)'"
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