Skip to content

Commit

Permalink
update changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu Sun committed Aug 22, 2022
1 parent ff5ea02 commit b108da9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 193 deletions.
6 changes: 2 additions & 4 deletions romp/lib/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def calc_obb(ptSets):
#__________________transform tools_______________________


def transform_rot_representation(rot, input_type='mat',out_type='vec'):
def transform_rot_representation(rot, input_type='mat',out_type='quat',input_is_degrees=True):
'''
make transformation between different representation of 3D rotation
input_type / out_type (np.array):
Expand All @@ -418,9 +418,7 @@ def transform_rot_representation(rot, input_type='mat',out_type='vec'):
elif input_type =='vec':
r = R.from_rotvec(rot)
elif input_type =='euler':
if rot.max()<4:
rot = rot*180/np.pi
r = R.from_euler('xyz',rot, degrees=True)
r = R.from_euler('xyz',rot, degrees=input_is_degrees)

if out_type=='mat':
out = r.as_matrix()
Expand Down
3 changes: 2 additions & 1 deletion simple_romp/bev/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def bev_settings(input_args=sys.argv[1:]):
# not support temporal processing now
parser.add_argument('-t', '--temporal_optimize', action='store_true', help = 'Whether to use OneEuro filter to smooth the results')
parser.add_argument('-sc','--smooth_coeff', type=float, default=3., help = 'The smoothness coeff of OneEuro filter, the smaller, the smoother.')
parser.add_argument('--webcam_id',type=int, default=0, help = 'The Webcam ID.')
args = parser.parse_args(input_args)

if args.model_id != 2:
Expand Down Expand Up @@ -304,7 +305,7 @@ def main():
saver.save_video(video_save_path, frame_rate=args.frame_rate)

if args.mode == 'webcam':
cap = WebcamVideoStream(0)
cap = WebcamVideoStream(args.webcam_id)
cap.start()
while True:
frame = cap.read()
Expand Down
3 changes: 2 additions & 1 deletion simple_romp/romp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def romp_settings(input_args=sys.argv[1:]):
parser.add_argument('--model_path', type=str, default=osp.join(osp.expanduser("~"),'.romp','ROMP.pkl'), help = 'The path of ROMP checkpoint')
parser.add_argument('--model_onnx_path', type=str, default=osp.join(osp.expanduser("~"),'.romp','ROMP.onnx'), help = 'The path of ROMP onnx checkpoint')
parser.add_argument('--root_align',type=bool, default=False, help = 'Please set this config as True to use the ROMP checkpoints trained by yourself.')
parser.add_argument('--webcam_id',type=int, default=0, help = 'The Webcam ID.')
args = parser.parse_args(input_args)

if not torch.cuda.is_available():
Expand Down Expand Up @@ -194,7 +195,7 @@ def main():
saver.save_video(video_save_path, frame_rate=args.frame_rate)

if args.mode == 'webcam':
cap = WebcamVideoStream(0)
cap = WebcamVideoStream(args.webcam_id)
cap.start()
while True:
frame = cap.read()
Expand Down
7 changes: 2 additions & 5 deletions simple_romp/romp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def rotation_matrix_to_quaternion(rotation_matrix, eps=1e-6):



def transform_rot_representation(rot, input_type='mat',out_type='vec'):
def transform_rot_representation(rot, input_type='mat',out_type='quat',input_is_degrees=True):
'''
make transformation between different representation of 3D rotation
input_type / out_type (np.array):
Expand All @@ -692,17 +692,14 @@ def transform_rot_representation(rot, input_type='mat',out_type='vec'):
'vec': rotation vector (3)
'euler': Euler degrees in x,y,z (3)
'''
from scipy.spatial.transform import Rotation as R
if input_type=='mat':
r = R.from_matrix(rot)
elif input_type=='quat':
r = R.from_quat(rot)
elif input_type =='vec':
r = R.from_rotvec(rot)
elif input_type =='euler':
if rot.max()<4:
rot = rot*180/np.pi
r = R.from_euler('xyz',rot, degrees=True)
r = R.from_euler('xyz',rot, degrees=input_is_degrees)

if out_type=='mat':
out = r.as_matrix()
Expand Down
Loading

0 comments on commit b108da9

Please sign in to comment.