def create_camera_matrix(): """ All parameters are taken from https://github.com/guiggh/hand_pose_action """ # camera parameter for image sensor # Image center u0 = 935.732544 v0 = 540.681030 # Focal Length fx = 1395.749023 fy = 1395.749268 rgb_camera_intr = camera.CameraIntr(**{ "u0": u0, "v0": v0, "fx": fx, "fy": fy }) # camera parameter for depth sensor # Image center: depth_u0 = 315.944855 depth_v0 = 245.287079 # Focal Length: depth_fx = 475.065948 depth_fy = 475.065857 depth_camera_intr = camera.CameraIntr(**{ "u0": depth_u0, "v0": depth_v0, "fx": depth_fx, "fy": depth_fy }) # Extrinsic parameters # Rotations R = np.array([ [0.999988496304, -0.00468848412856, 0.000982563360594], [0.00469115935266, 0.999985218048, -0.00273845880292], [-0.000969709653873, 0.00274303671904, 0.99999576807], ]) # Translate t = np.array([25.7, 1.22, 3.902]) camera_extr = camera.CameraExtr(R, t) cameras = {} cameras["rgb_camera_intr"] = rgb_camera_intr cameras["depth_camera_intr"] = depth_camera_intr cameras["camera_extr"] = camera_extr return cameras
def create_camera_mat(): """ The camera intrinsic parameters are: principle point = image center(160, 120), focal length = 241.42. """ fx = fy = 241.42 u0, v0 = 160, 120 depth_camera_intr = camera.CameraIntr(**{"u0": u0, "v0": v0, "fx": fx, "fy": fy}) cameras = {} cameras["depth_camera_intr"] = depth_camera_intr return cameras
def create_camera_mat(): # These values are Taken from anno_all["K"] fx = fy = 283.1 u0 = v0 = 160. rgb_camera_intr = camera.CameraIntr(**{ "u0": u0, "v0": v0, "fx": fx, "fy": fy }) depth_camera_intr = camera.CameraIntr(**{ "u0": u0, "v0": v0, "fx": fx, "fy": fy }) cameras = {} # Both, rgb and depth, have same camera parameter cameras["rgb_camera_intr"] = rgb_camera_intr cameras["depth_camera_intr"] = depth_camera_intr return cameras
def create_camera_mat(): fx = 614.878 fy = 615.479 u0 = 313.219 v0 = 231.288 rgb_camera_intr = camera.CameraIntr(**{ "u0": u0, "v0": v0, "fx": fx, "fy": fy }) cameras = {"rgb_camera_intr": rgb_camera_intr} return cameras
def create_camera_mat(): # These parameters are taken from convert_xyz_to_uvd.m provided by NYU dataset. u0 = 640 / 2 v0 = 480 / 2 fx = 588.036865 fy = 587.075073 rgb_camera_intr = camera.CameraIntr(**{ "u0": u0, "v0": v0, "fx": fx, "fy": fy }) depth_camera_intr = camera.CameraIntr(**{ "u0": u0, "v0": v0, "fx": fx, "fy": fy }) cameras = {} cameras["rgb_camera_intr"] = rgb_camera_intr cameras["depth_camera_intr"] = depth_camera_intr return cameras
def create_camera_mat(): fx = fy = 617.173 u0 = 315.453 v0 = 242.259 rgb_camera_intr = camera.CameraIntr(**{ "u0": u0, "v0": v0, "fx": fx, "fy": fy }) fx = fy = 475.62 u0 = 311.125 v0 = 245.965 depth_camera_intr = camera.CameraIntr(**{ "u0": u0, "v0": v0, "fx": fx, "fy": fy }) cameras = {} cameras["rgb_camera_intr"] = rgb_camera_intr cameras["depth_camera_intr"] = depth_camera_intr return cameras
def create_camera_mat(): # See README.txt camera_intr = np.array([ [617.173, 0, 315.453], [0, 617.173, 242.259], [0, 0, 1], ]) fx = fy = 617.173 u0 = 315.453 v0 = 242.259 rgb_camera_intr = camera.CameraIntr(**{"u0": u0, "v0": v0, "fx": fx, "fy": fy}) cameras = {} cameras["rgb_camera_intr"] = rgb_camera_intr return cameras
def load_annotations(self, dataset_dir, debug=False): logger.info("load annotations mode = {}".format(self.mode)) logger.info("dataset_dir = {}".format(dataset_dir)) annotations = [] with open(os.path.join(dataset_dir, "training_xyz.json"), 'r') as f: joint_annotations = json.load(f) with open(os.path.join(dataset_dir, "training_K.json"), 'r') as f: camera_annotations = json.load(f) global VAL_LIST VAL_LIST = np.random.choice(len(joint_annotations), int(0.1 * len(joint_annotations))) for idx in range(len(joint_annotations)): if self.mode == "train" and idx in VAL_LIST: continue if self.mode != "train" and idx not in VAL_LIST: continue rgb_path = os.path.join(dataset_dir, "training", "rgb", "{:08d}.jpg".format(idx)) if not os.path.exists(rgb_path): continue rgb_joint = np.array(joint_annotations[idx]) [[fx, _, u0], [_, fy, v0], [_, _, _]] = camera_annotations[idx] rgb_camera = camera.CameraIntr(u0=u0, v0=v0, fx=fx, fy=fy) if DATA_CONVENTION == "ZYX": rgb_joint = rgb_joint[:, ::-1] rgb_joint = rgb_joint[INDEX_CONVERTER] rgb_joint = rgb_joint[INDEX_CONVERTER] rgb_joint = wrist2palm(rgb_joint) example = {} example["hand_side"] = "right" example["rgb_path"] = rgb_path example["rgb_joint"] = 1000 * rgb_joint example["rgb_camera"] = rgb_camera annotations.append(example) if debug and len(annotations) > 10: break return annotations
def create_camera_mat(): """ Camera parameter of Intel Real Sense F200 active depth camera. These parameters are taken from readme.txt of STB dataset. 1. Camera parameters (1) Point Grey Bumblebee2 stereo camera: base line = 120.054 fx = 822.79041 fy = 822.79041 tx = 318.47345 ty = 250.31296 (2) Intel Real Sense F200 active depth camera: fx color = 607.92271 fy color = 607.88192 tx color = 314.78337 ty color = 236.42484 fx depth = 475.62768 fy depth = 474.77709 tx depth = 336.41179 ty depth = 238.77962 rotation vector = [0.00531 -0.01196 0.00301] (use Rodrigues' rotation formula to transform it into rotation matrix) translation vector = [-24.0381 -0.4563 -1.2326] (rotation and translation vector can transform the coordinates relative to color camera to those relative to depth camera) """ fx_color = 607.92271 fy_color = 607.88192 tx_color = 314.78337 ty_color = 236.42484 rgb_camera_intr = camera.CameraIntr(**{ "u0": tx_color, "v0": ty_color, "fx": fx_color, "fy": fy_color }) fx_depth = 475.62768 fy_depth = 474.77709 tx_depth = 336.41179 ty_depth = 238.77962 depth_camera_intr = camera.CameraIntr(**{ "u0": tx_depth, "v0": ty_depth, "fx": fx_depth, "fy": fy_depth }) def Rodrigues(rotation_vector): theta = np.linalg.norm(rotation_vector) rv = rotation_vector / theta rr = np.array([[rv[i] * rv[j] for j in range(3)] for i in range(3)]) R = np.cos(theta) * np.eye(3) R += (1 - np.cos(theta)) * rr R += np.sin(theta) * np.array([ [0, -rv[2], rv[1]], [rv[2], 0, -rv[0]], [-rv[1], rv[0], 0], ]) return R rotation_vector = np.array([0.00531, -0.01196, 0.00301]) R = Rodrigues(rotation_vector) # transpose to fit our camera class interface R = R.transpose() # apply minus to fit our camera class interface translation_vector = -np.array([-24.0381, -0.4563, -1.2326]) rgb_camera_extr = camera.CameraExtr(R, translation_vector) depth_camera_extr = camera.CameraExtr(R, np.zeros(3)) cameras = {} cameras["rgb_camera_intr"] = rgb_camera_intr cameras["depth_camera_intr"] = depth_camera_intr cameras["rgb_camera_extr"] = rgb_camera_extr cameras["depth_camera_extr"] = depth_camera_extr return cameras