Skip to content

Instantly share code, notes, and snippets.

@shks
shks / jpegs_into_mov.py
Created Jan 18, 2021
merge jpegs into mov
View jpegs_into_mov.py
import sys
import cv2
import glob
_list = glob.glob("./some/*", recursive=True)
_list.sort()
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
video = cv2.VideoWriter('./some/video.mp4',fourcc, 60.0, (1024, 1024))
@shks
shks / get_file_list.py
Created Jan 18, 2021
特定ファイルリストを取得
View get_file_list.py
import glob
_list = glob.glob("*.mov", recursive=True)
for fname in _list:
sampleName = os.path.basename(fname).split('.', 1)[0]
print(sampleName)
@shks
shks / video_into_jpegs.py
Created Jan 18, 2021
split video into jpegs. ビデオをフレーム画像に分割する
View video_into_jpegs.py
import cv2
import os
def save_all_frames(video_path, dir_path, basename, ext='jpg'):
cap = cv2.VideoCapture(video_path)
if not cap.isOpened():
return
os.makedirs(dir_path, exist_ok=True)
@shks
shks / ScriptTOP_matplotlib.py
Last active Jan 5, 2021
rendering matplotlib in ScriptTOP TouchDesigner
View ScriptTOP_matplotlib.py
# me - this DAT
# scriptOp - the OP which is cooking
import numpy as np
import cv2
import io
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('Agg')
@shks
shks / doShapirotest.py
Last active Jan 2, 2021
doShapirotest in python
View doShapirotest.py
from scipy.stats import shapiro
#https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.shapiro.html
def doShapirotest(data):
stat, p = shapiro(data)
print("Shapirotest Wstat , p-value", stat, p)
if(p < 0.05):
print("USE NON-PARAMETRIC TEST :(p < 0.05)")
else:
print("USE PARAMETRIC TEST : (p > 0.05)")
@shks
shks / read_tsv_csv.py
Last active Jan 2, 2021
read_tsv_csv.py
View read_tsv_csv.py
#tsv, csvファイルからデータの読み込み
def readFile(filePath):
#TSVの場合#delimiter="\t"
#CSVの場合","
_d= "\t"#","
#skiprows=1 : 最初の行を無視する
_data = np.loadtxt(filePath,delimiter = _d,skiprows=1)
@shks
shks / OSC-Python.py
Created Jun 19, 2020
Touchdesigner - python communication via OSC
View OSC-Python.py
#python
'''
setup instruction
for Install pythonosc
pip install python-osc
'''
from pythonosc import dispatcher