Created
July 8, 2019 09:30
-
-
Save mpkuse/a92a06230150b67d57d372e7b520acda to your computer and use it in GitHub Desktop.
OpenCV YAML
This file contains hidden or 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 | |
def convert_3x3_1x1__to__4x4(fname, outfname, outvarname ): | |
## READ YAML OPENCV | |
print( 'fname: ', fname ) | |
fs = cv2.FileStorage(fname, cv2.FILE_STORAGE_READ) | |
R = fs.getNode("extrinsicRotation").mat() | |
t = fs.getNode("extrinsicTranslation").mat() | |
print(R ) | |
print(t ) | |
T = np.eye( 4, 4 ) | |
T[0:3,0:3] = R | |
T[0:3,3:4] = t | |
## WRITE YAML OPENCV | |
print('Write file: ', outfname, '\t outvarname=',outvarname ) | |
cv_file = cv2.FileStorage(outfname, cv2.FILE_STORAGE_WRITE) | |
cv_file.write(outvarname, T) | |
cv_file.release() | |
return R, t | |
#fname ="./output/1_ext.csv" | |
convert_3x3_1x1__to__4x4( "./output/1_ext.csv", "./output/1_ext.csv.yaml", 'body_T_cam0' ) | |
convert_3x3_1x1__to__4x4( "./output/2_ext.csv", "./output/2_ext.csv.yaml", 'body_T_cam1' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment