-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
41 lines (33 loc) · 1.36 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"Utils functions, mainly from anipose."
from aniposelib.boards import Checkerboard, CharucoBoard
import cv2
def get_calibration_board(config):
calib = config['calibration']
board_size = calib['board_size']
board_type = calib['board_type'].lower()
if board_type == 'aruco':
raise NotImplementedError(
"aruco board is not implemented with the current pipeline")
elif board_type == 'charuco':
board = CharucoBoard(
board_size[0], board_size[1],
calib['board_square_side_length'],
calib['board_marker_length'],
calib['board_marker_bits'],
calib['board_marker_dict_number'],
manually_verify=False)
elif board_type == 'checkerboard':
board = Checkerboard(board_size[0], board_size[1],
calib['board_square_side_length'],
manually_verify=False)
else:
raise ValueError("board_type should be one of "
"'aruco', 'charuco', or 'checkerboard' not '{}'".format(
board_type))
return board
def get_size(path_in):
"Return the width and height of a video, in pixels."
cap = cv2.VideoCapture(str(path_in))
width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
return int(width), int(height)