This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# カメラ内部パラメータ(内部パラメータ行列) | |
# ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None) | |
# -----reading camera intrinsic matrix | |
cameraMatrix = np.loadtxt("calib/cameraMatrix.csv",delimiter=",") | |
distCoeffs = np.loadtxt("calib/distCoeffs.csv",delimiter=",") | |
# 外部パラメータ行列 | |
# https://gist.github.com/shks/e3cd5fc22ad9f4ddbccd5312a64803c3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
retval, rvec, tvec = aruco.estimatePoseBoard(corners, ids, board, cameraMatrix, distCoeffs, None, None) | |
#rvec, tvec : 3 float vector | |
#ロドリゲス公式で、rvecから回転行列へ変換する | |
Rmatrix, Jacob = cv2.Rodrigues(rvec) | |
# [3 x 4 matrix]で、R|t マトリクスを作成 | |
RTmatrix34_L = np.concatenate([Rmatrix, tvec], axis=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -load camera instrinsic matrix | |
cameraMatrix = np.loadtxt("calib/cameraMatrix.csv",delimiter=",") | |
distCoeffs = np.loadtxt("calib/distCoeffs.csv",delimiter=",") | |
# prepare the 'same' aruco board | |
aruco = cv2.aruco | |
dictionary = aruco.getPredefinedDictionary(aruco.DICT_4X4_50) | |
board = cv2.aruco.GridBoard_create(5, 5, 0.2,0.1,dictionary) | |
# retval = cv.aruco.GridBoard_create( markersX, markersY, markerLength, markerSeparation, dictionary[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cv2 import aruco | |
import cv2 | |
aruco_dict = aruco.Dictionary_get(aruco.DICT_6X6_250) | |
board = aruco.CharucoBoard_create(28, 16, 200, 140, aruco_dict) | |
imboard = board.draw((1920,1080)) | |
cv2.imwrite('CharucoBoard.png', imboard) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
arr = op('td_top').numpyArray('delayed=True') | |
gray = arr[:, :, 0] | |
gray = gray * 255.0 | |
gray = gray.astype(np.uint8) | |
#flip | |
gray = cv2.flip(gray, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
_list = glob.glob("*.mov", recursive=True) | |
for fname in _list: | |
sampleName = os.path.basename(fname).split('.', 1)[0] | |
print(sampleName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)") |
NewerOlder