Open h-cha opened 1 year ago
import numpy as np
print("flip coordinates ...")
c2w = [
[0.9977, -0.0647, -0.02016, -0.10793465059103907],
[-0.00198, -0.32523, 0.94563, 3.7799645259408403],
[0.06774, 0.94342, 0.32461, 1.299197965401564],
[0.0, 0.0, 0.0, 1.0]
]
c2w = np.array(c2w) # リストをNumPy配列に変換
c2w[0:3, 2] *= -1
print(c2w)
print("a")
c2w[0:3, 1] *= -1
print(c2w)
print("a")
c2w = c2w[[1, 0, 2, 3], :]
print(c2w)
print("a")
c2w[2, :] *= -1
print(c2w)
print("a")
出力結果
flip coordinates ...
[[ 9.97700000e-01 -6.47000000e-02 2.01600000e-02 -1.07934651e-01]
[-1.98000000e-03 -3.25230000e-01 -9.45630000e-01 3.77996453e+00]
[ 6.77400000e-02 9.43420000e-01 -3.24610000e-01 1.29919797e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00]]
a
[[ 9.97700000e-01 6.47000000e-02 2.01600000e-02 -1.07934651e-01]
[-1.98000000e-03 3.25230000e-01 -9.45630000e-01 3.77996453e+00]
[ 6.77400000e-02 -9.43420000e-01 -3.24610000e-01 1.29919797e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00]]
a
[[-1.98000000e-03 3.25230000e-01 -9.45630000e-01 3.77996453e+00]
[ 9.97700000e-01 6.47000000e-02 2.01600000e-02 -1.07934651e-01]
[ 6.77400000e-02 -9.43420000e-01 -3.24610000e-01 1.29919797e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00]]
a
[[-1.98000000e-03 3.25230000e-01 -9.45630000e-01 3.77996453e+00]
[ 9.97700000e-01 6.47000000e-02 2.01600000e-02 -1.07934651e-01]
[-6.77400000e-02 9.43420000e-01 3.24610000e-01 -1.29919797e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00]]
a
flip_mat = np.array([
[1, 0, 0, 0],
[0, -1, 0, 0],
[0, 0, -1, 0],
[0, 0, 0, 1]
])
c2w = [
[0.9977, -0.0647, -0.02016, -0.10793465059103907],
[-0.00198, -0.32523, 0.94563, 3.7799645259408403],
[0.06774, 0.94342, 0.32461, 1.299197965401564],
[0.0, 0.0, 0.0, 1.0]
]
print(np.matmul(c2w, flip_mat)) # flip cameras (it just works)
出力結果
[[ 9.97700000e-01 6.47000000e-02 2.01600000e-02 -1.07934651e-01]
[-1.98000000e-03 3.25230000e-01 -9.45630000e-01 3.77996453e+00]
[ 6.77400000e-02 -9.43420000e-01 -3.24610000e-01 1.29919797e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00]]
unity_generate_transform_mat2_rotate90_flip_yz.py
flip_mat = np.array([
[1, 0, 0, 0],
[0, -1, 0, 0],
[0, 0, -1, 0],
[0, 0, 0, 1]
])