Permalink
Please sign in to comment.
Showing
with
134,206 additions
and 0 deletions.
- +2 −0 EyeTab_Python/anatomical_constants.py
- +79 −0 EyeTab_Python/calibrate_camera.py
- +15,452 −0 EyeTab_Python/cascades/haarcascade_eye.xml
- +26,161 −0 EyeTab_Python/cascades/haarcascade_frontalface_alt.xml
- +10,930 −0 EyeTab_Python/cascades/haarcascade_mcs_eyepair_big.xml
- +12,586 −0 EyeTab_Python/cascades/haarcascade_mcs_eyepair_small.xml
- +23,791 −0 EyeTab_Python/cascades/haarcascade_mcs_lefteye.xml
- +42,252 −0 EyeTab_Python/cascades/haarcascade_mcs_righteye.xml
- +126 −0 EyeTab_Python/conic_section.py
- +56 −0 EyeTab_Python/device_constants.py
- +168 −0 EyeTab_Python/draw_utils.py
- +69 −0 EyeTab_Python/eye_center_locator_combined.py
- +118 −0 EyeTab_Python/eye_center_locator_gradients.py
- +149 −0 EyeTab_Python/eye_center_locator_isophote.py
- +228 −0 EyeTab_Python/eye_extractor.py
- BIN EyeTab_Python/eye_images/abi1_l.png
- BIN EyeTab_Python/eye_images/abi1_r.png
- BIN EyeTab_Python/eye_images/abi2_l.png
- BIN EyeTab_Python/eye_images/abi2_r.png
- BIN EyeTab_Python/eye_images/andreas1_l.png
- BIN EyeTab_Python/eye_images/andreas1_r.png
- BIN EyeTab_Python/eye_images/andreas2_l.png
- BIN EyeTab_Python/eye_images/andreas2_r.png
- BIN EyeTab_Python/eye_images/andreas3_l.png
- BIN EyeTab_Python/eye_images/andreas3_r.png
- BIN EyeTab_Python/eye_images/andreas4_l.png
- BIN EyeTab_Python/eye_images/andreas4_r.png
- BIN EyeTab_Python/eye_images/andreas5_l.png
- BIN EyeTab_Python/eye_images/andreas5_r.png
- BIN EyeTab_Python/eye_images/andreas6_l.png
- BIN EyeTab_Python/eye_images/andreas6_r.png
- BIN EyeTab_Python/eye_images/david1_l.png
- BIN EyeTab_Python/eye_images/david1_r.png
- BIN EyeTab_Python/eye_images/erroll10_l.png
- BIN EyeTab_Python/eye_images/erroll10_r.png
- BIN EyeTab_Python/eye_images/erroll1_l.png
- BIN EyeTab_Python/eye_images/erroll1_r.png
- BIN EyeTab_Python/eye_images/erroll2_l.png
- BIN EyeTab_Python/eye_images/erroll2_r.png
- BIN EyeTab_Python/eye_images/erroll3_l.png
- BIN EyeTab_Python/eye_images/erroll3_r.png
- BIN EyeTab_Python/eye_images/erroll4_l.png
- BIN EyeTab_Python/eye_images/erroll4_r.png
- BIN EyeTab_Python/eye_images/erroll5_l.png
- BIN EyeTab_Python/eye_images/erroll5_r.png
- BIN EyeTab_Python/eye_images/erroll6_l.png
- BIN EyeTab_Python/eye_images/erroll6_r.png
- BIN EyeTab_Python/eye_images/erroll7_l.png
- BIN EyeTab_Python/eye_images/erroll7_r.png
- BIN EyeTab_Python/eye_images/erroll8_l.png
- BIN EyeTab_Python/eye_images/erroll8_r.png
- BIN EyeTab_Python/eye_images/erroll9_l.png
- BIN EyeTab_Python/eye_images/erroll9_r.png
- BIN EyeTab_Python/eye_images/george1_l.png
- BIN EyeTab_Python/eye_images/george1_r.png
- BIN EyeTab_Python/eye_images/hyesoon1_l.png
- BIN EyeTab_Python/eye_images/hyesoon1_r.png
- BIN EyeTab_Python/eye_images/hyesoon2_l.png
- BIN EyeTab_Python/eye_images/hyesoon2_r.png
- BIN EyeTab_Python/eye_images/james1_l.png
- BIN EyeTab_Python/eye_images/james1_r.png
- BIN EyeTab_Python/eye_images/james2_l.png
- BIN EyeTab_Python/eye_images/james2_r.png
- BIN EyeTab_Python/eye_images/mahdi1_l.png
- BIN EyeTab_Python/eye_images/mahdi1_r.png
- BIN EyeTab_Python/eye_images/mahdi2_l.png
- BIN EyeTab_Python/eye_images/mahdi2_r.png
- BIN EyeTab_Python/eye_images/osman1_l.png
- BIN EyeTab_Python/eye_images/osman1_r.png
- BIN EyeTab_Python/eye_images/osman2_l.png
- BIN EyeTab_Python/eye_images/osman2_r.png
- BIN EyeTab_Python/eye_images/phil1_l.png
- BIN EyeTab_Python/eye_images/phil1_r.png
- BIN EyeTab_Python/eye_images/phil2_l.png
- BIN EyeTab_Python/eye_images/phil2_r.png
- BIN EyeTab_Python/eye_images/phil3_l.png
- BIN EyeTab_Python/eye_images/phil3_r.png
- BIN EyeTab_Python/eye_images/phil4_l.png
- BIN EyeTab_Python/eye_images/phil4_r.png
- +259 −0 EyeTab_Python/eyelid_locator.py
- +101 −0 EyeTab_Python/find_limbus_points.py
- +63 −0 EyeTab_Python/fit_ellipse_numpy.py
- +157 −0 EyeTab_Python/gaze_geometry.py
- +62 −0 EyeTab_Python/gaze_smoothing.py
- +193 −0 EyeTab_Python/gaze_system.py
- +163 −0 EyeTab_Python/image_utils.py
- +50 −0 EyeTab_Python/limbus_outlier_removal.py
- +101 −0 EyeTab_Python/linpolar_transform.py
- +103 −0 EyeTab_Python/main.py
- +59 −0 EyeTab_Python/pre_processing.py
- +207 −0 EyeTab_Python/ransac_ellipse.py
- +116 −0 EyeTab_Python/ransac_eyelids.py
- +96 −0 EyeTab_Python/ray_casting.py
- +34 −0 EyeTab_Python/time_profiler.py
- +275 −0 EyeTab_Python/visualize_in_3d.py
| @@ -0,0 +1,2 @@ | |||
| +limbus_r_mm = 6 | |||
| +eye_r_mm = 11 | |||
| @@ -0,0 +1,79 @@ | |||
| +import cv2, numpy as np, os | |||
| + | |||
| +board_w, board_h = 6, 9 | |||
| +board_size = (board_w, board_h) | |||
| + | |||
| +img_w, img_h = 720, 1280 | |||
| +img_size = (img_w, img_h) | |||
| +square_mm = 21 | |||
| + | |||
| +def get_obect_img_pts(board_img, debug=False): | |||
| + | |||
| + board_img_grey = cv2.cvtColor(board_img, cv2.COLOR_BGR2GRAY) | |||
| + | |||
| + # Find chessboard corners | |||
| + found, corners = cv2.findChessboardCorners( | |||
| + image=board_img_grey, | |||
| + patternSize=board_size, | |||
| + flags=cv2.CALIB_CB_ADAPTIVE_THRESH | cv2.CALIB_CB_FILTER_QUADS | cv2.CALIB_CB_FAST_CHECK) | |||
| + | |||
| + # Refine corner locations | |||
| + cv2.cornerSubPix( | |||
| + image=board_img_grey, | |||
| + corners=corners, | |||
| + winSize=(11, 11), | |||
| + zeroZone=(-1, -1), | |||
| + criteria=(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 30, 0.1)) | |||
| + | |||
| + if debug: | |||
| + chessboard_debug_img = np.copy(board_img) | |||
| + chessboard_debug_img = cv2.cvtColor(chessboard_debug_img,cv2.COLOR_BGR2GRAY) | |||
| + chessboard_debug_img = cv2.cvtColor(chessboard_debug_img,cv2.COLOR_GRAY2BGR) | |||
| + cv2.drawChessboardCorners(chessboard_debug_img, board_size, corners, found) | |||
| + cv2.imshow("board", chessboard_debug_img) | |||
| + cv2.waitKey() | |||
| + | |||
| + # Correctly arrange arrays of corresponding points | |||
| + object_pts = np.zeros((np.prod(board_size), 3), np.float32) | |||
| + object_pts[:, :2] = np.indices(board_size).T.reshape(-1, 2) * square_mm | |||
| + image_pts = corners.reshape(-1, 2) | |||
| + | |||
| + return object_pts, image_pts | |||
| + | |||
| + | |||
| +def get_intrinsic_camera_params(object_pts, image_pts, debug=False): | |||
| + | |||
| + _, cam_mat, dist_coefs, _, _ = cv2.calibrateCamera( | |||
| + objectPoints=object_pts, | |||
| + imagePoints=image_pts, | |||
| + imageSize=img_size) | |||
| + | |||
| + if debug: | |||
| + print dist_coefs | |||
| + print cam_mat | |||
| + print 'fx = {}, fy = {}'.format(cam_mat[0][0], cam_mat[1][1]) | |||
| + print 'cx = {}, cy = {}'.format(cam_mat[0][2], cam_mat[1][2]) | |||
| + | |||
| + return cam_mat, dist_coefs | |||
| + | |||
| + | |||
| +#---------------------------------------- | |||
| +# FIND INTRINSIC CAMERA PARAMETERS | |||
| +#---------------------------------------- | |||
| +if __name__ == '__main__': | |||
| + | |||
| + calibration_imgs_path = 'camera_calibration' | |||
| + calibration_imgs = map(lambda x: cv2.imread(os.path.join(calibration_imgs_path, x)), | |||
| + os.listdir(calibration_imgs_path)) | |||
| + | |||
| + all_object_pts, all_img_pts = [], [] | |||
| + for img in calibration_imgs: | |||
| + object_pts, image_pts = get_obect_img_pts(img, debug=True) | |||
| + all_object_pts.append(object_pts) | |||
| + all_img_pts.append(image_pts) | |||
| + | |||
| + cam_mat, dist_coefs = get_intrinsic_camera_params(all_object_pts, all_img_pts, True) | |||
| + | |||
| + params_file = open('camera_matrix_N7.txt', 'w') | |||
| + params_file.write('fx = {}\nfy = {}\ncx = {}\ncy = {}'.format(cam_mat[0][0], cam_mat[1][1], cam_mat[0][2], cam_mat[1][2])) | |||
| + params_file.close() | |||
Oops, something went wrong.
0 comments on commit
7d163e2