Example #1
0
def frameCentroidsToDets(frame, mats=None):
    '''Extract the centroids for given cameras and undistorts them. Returns a list of x2ds and splits per camera.'''
    detRawData, splits = SolveIK.list_of_lists_to_splits(frame,
                                                         dtype=np.float32)
    detRawData = (detRawData - np.float32([256, 256])) / np.float32(
        [256, -256])
    if mats is None: return detRawData[:, :2].copy(), splits
    return Calibrate.undistort_dets(detRawData, splits, mats)
Example #2
0
def get_labels(frames, x3ds_seq, detections_seq, mats, x2d_threshold=0.01):
    '''Project all the 3d points in all the views and label the detections.'''
    num_cameras = len(mats)
    ret = {}
    Ps = np.array([m[2] / (m[0][0, 0]) for m in mats], dtype=np.float32)
    for fi in frames:
        print fi, '\r',
        x3ds, x3ds_labels = x3ds_seq[fi]
        x2ds_raw_data, splits = detections_seq[fi][0]
        assert (num_cameras + 1 == len(splits))
        x2ds_labels = -np.ones(len(x2ds_raw_data), dtype=np.int32)
        x2ds_data, _ = Calibrate.undistort_dets(x2ds_raw_data, splits, mats)
        if len(x2ds_data):
            clouds = ISCV.HashCloud2DList(x2ds_data, splits, x2d_threshold)
            sc, x2ds_labels, x2ds_vels = Label.project_assign(
                clouds, x3ds, x3ds_labels, Ps, x2d_threshold)
            zeros = np.where(x2ds_labels == -1)[0]
            # these lines remove all the data for the unlabelled points
            x2ds_data[zeros] = -1
            x2ds_raw_data[zeros] = -1
        ret[fi] = x2ds_raw_data, splits, x2ds_labels
    return ret
Example #3
0
def frameCentroidsToDets(frame, mats=None):
	'''Extract the centroids for given cameras and undistorts them. Returns a list of x2ds and splits per camera.'''
	x2ds_raw_data, x2ds_splits = frame[0],frame[1]
	if mats is None: return x2ds_raw_data[:,:2].copy(), x2ds_splits
	return Calibrate.undistort_dets(x2ds_raw_data, x2ds_splits, mats)
Example #4
0
                    dx, dy = 10, 10
                    img[int(r.sy - dy):int(r.sy + dy),
                        int(r.sx - dx):int(r.sx + dx), 0] = 128
    else:
        pts0 = pts1 = []
    return (pts0, pts1)


def tighten_calibration(
    (x3s, x3s_labels), (x2s, x2s_splits, x2s_labels), mats):
    x3s_original = x3s.copy()
    x2s_labels_original = x2s_labels.copy()
    for it in range(10):
        x2d_threshold = 0.08  # - it * 0.04/50.
        Ps = np.array([m[2] / (m[0][0, 0]) for m in mats], dtype=np.float32)
        u2s, _ = Calibrate.undistort_dets(x2s, x2s_splits, mats)
        x3s, x3s_labels, E, x2d_labels = Recon.solve_x3ds(
            u2s, x2s_splits, x2s_labels_original, Ps, True)
        clouds = ISCV.HashCloud2DList(u2s, x2s_splits, x2d_threshold)
        sc, x2s_labels, _ = Label.project_assign(clouds, x3s, x3s_labels, Ps,
                                                 x2d_threshold)
        print 'it', it, sc
        tiara_xis = np.where(x3s_labels < len(VICON_tiara_x3ds))[0]
        tiara_lis = x3s_labels[tiara_xis]
        tiara_true = VICON_tiara_x3ds[tiara_lis] + [0, 1000, 0]
        tiara_xs = x3s[tiara_xis]
        # now solve the tiara into place by finding a rigid transform
        RT, inliers = Calibrate.rigid_align_points_inliers(tiara_xs,
                                                           tiara_true,
                                                           scale=True)
        x3s = np.dot(x3s, RT[:3, :3].T) + RT[:, 3]