Skip to content

Instantly share code, notes, and snippets.

View saccadic's full-sized avatar
🌎
Maybe on Earth. Maybe in the future.

Katsuyoshi Hotta saccadic

🌎
Maybe on Earth. Maybe in the future.
  • Osaka
  • 15:49 (UTC +09:00)
View GitHub Profile
#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
}
//https://www.shadertoy.com/view/4ssXRX
const int NUM_BUCKETS = 32;
const int ITER_PER_BUCKET = 1024;
const float HIST_SCALE = 8.0;
const float NUM_BUCKETS_F = float(NUM_BUCKETS);
const float ITER_PER_BUCKET_F = float(ITER_PER_BUCKET);
@saccadic
saccadic / udev-get-camera-list.c
Last active February 25, 2020 04:53
LinuxでカメラのIDと名前を取得するコード
// Author : Katsuyoshi Hotta
// sudo apt-get install libudev
// udevadm info --query=all --name=/dev/video0
#include <stdio.h>
#include <unistd.h>
#include <libudev.h>
int main()
{
@saccadic
saccadic / filesearch.py
Created June 17, 2020 00:58
特定のフォルダ以下に含まれる特定のファイルを検索してファイルごとに何かの処理を行う
from tqdm import tqdm
import pandas as pd
import pathlib
targetDirectry = "./test"
requestFile = "**/**/**/*.bmp"
file = pathlib.Path(targetDirectry)
pathList = list(file.glob(requestFile))
for i in (range(len(pathList))):
@saccadic
saccadic / ErrorEllipse.py
Created June 17, 2020 08:14
2次元の座標群に対する確率楕円を計算
#https://github.com/joferkington/oost_paper_code/blob/master/error_ellipse.py
def confidence_ellipse(x, y, n_std=3.0):
def eigsorted(cov):
vals, vecs = np.linalg.eigh(cov)
order = vals.argsort()[::-1]
return vals[order], vecs[:,order]
xy = (np.mean(x), np.mean(y))
cov = np.cov(x, y)
vals, vecs = eigsorted(cov)
@saccadic
saccadic / CheckInsideEllipse.py
Last active July 13, 2020 05:27
楕円の内外判定
# https://www.tutorialspoint.com/check-if-a-point-is-inside-outside-or-on-the-ellipse-in-cplusplus
def isInsideEllipse(ellipse,point):
(x0, y0), bb, aa, phi_b_deg = ellipse
(x1, y1) = point
angle = np.radians(phi_b_deg)
if aa > bb:
a = aa/2
b = bb/2
@saccadic
saccadic / QuaternionFilter.h
Created July 6, 2020 05:00
IMUから取得されるセンサー値から姿勢を推定する
#pragma once
#ifndef QUATERNIONFILTER_H
#define QUATERNIONFILTER_H
class QuaternionFilter
{
float GyroMeasError = PI * (40.0f / 180.0f); // gyroscope measurement error in rads/s (start at 40 deg/s)
float GyroMeasDrift = PI * (0.0f / 180.0f); // gyroscope measurement drift in rad/s/s (start at 0.0 deg/s/s)
float beta = sqrt(3.0f / 4.0f) * GyroMeasError; // compute beta
@saccadic
saccadic / imageFiles2PDF.py
Last active November 4, 2020 00:50
複数の画像をPDFに統合するスクリプト
import os
import pathlib
from tqdm import tqdm
from PIL import Image
import img2pdf
# !pip install pathlib tqdm Pillow img2pdf
def ConvertImage2Pdf(pdfFileName,imageDirPath,ext="png"):
file = pathlib.Path(imageDirPath)
@saccadic
saccadic / nnabla_dl.bat
Created November 2, 2020 00:49
nnablaのダウンロードツール
SET nnabla_version=1.12.0
powershell wget https://github.com/sony/nnabla/archive/v%nnabla_version%.zip -o nnable.zip
powershell wget https://github.com/sony/nnabla-ext-cuda/archive/v%nnabla_version%.zip -o nnable-ext-cuda.zip
powershell Expand-Archive -Path nnable.zip -Force -DestinationPath ./nnable
powershell Move-Item ./nnable/nnabla-%nnabla_version%/* ./nnable/
powershell Remove-Item -Path ./nnable/nnabla-%nnabla_version%
@saccadic
saccadic / nnable_build.bat
Created November 2, 2020 00:50
nnableのリリースとデバック両方をビルド
SET nnabla_build_folder_name=build
SET nnabla_root=./nnable
SET build_type=Release
call .\nnable\build-tools\msvc\build_cpplib.bat
call .\nnable-ext-cuda\build-tools\msvc\build_cpplib.bat
cd .\nnable
ren build build_Release
cd ..\
cd .\nnable-ext-cuda