Beispiel #1
0
	def find_chessboard_boundary_for_depth_image(self):
		boundary = {}

		for (serial, frameset) in self.frames.items():

			depth_frame = post_process_depth_frame(frameset[rs.stream.depth])
			infrared_frame = frameset[(rs.stream.infrared, 1)]
			found_corners, points2D = cv_find_chessboard(depth_frame, infrared_frame, self.chessboard_params)
			boundary[serial] = [np.floor(np.amin(points2D[0,:])).astype(int), np.floor(np.amax(points2D[0,:])).astype(int), np.floor(np.amin(points2D[1,:])).astype(int), np.floor(np.amax(points2D[1,:])).astype(int)]

		return boundary
Beispiel #2
0
    def get_chessboard_corners_in3d(self):
        """
		Searches the chessboard corners in the infrared images of 
		every connected device and uses the information in the 
		corresponding depth image to calculate the 3d 
		coordinates of the chessboard corners in the coordinate system of 
		the camera

		Returns:
		-----------
		corners3D : dict
			keys: str
				Serial number of the device
			values: [success, points3D, validDepths] 
				success: bool
					Indicates wether the operation was successfull
				points3d: array
					(3,N) matrix with the coordinates of the chessboard corners
					in the coordinate system of the camera. N is the number of corners
					in the chessboard. May contain points with invalid depth values
				validDephts: [bool]*
					Sequence with length N indicating which point in points3D has a valid depth value
		"""
        corners3D = {}
        for (info, frameset) in self.frames.items():
            serial = info[0]
            product_line = info[1]
            depth_frame = post_process_depth_frame(frameset[rs.stream.depth])
            if product_line == "L500":
                infrared_frame = frameset[(rs.stream.infrared, 0)]
            else:
                infrared_frame = frameset[(rs.stream.infrared, 1)]
            depth_intrinsics = self.intrinsic[serial][rs.stream.depth]
            found_corners, points2D = cv_find_chessboard(
                depth_frame, infrared_frame, self.chessboard_params)
            corners3D[serial] = [found_corners, None, None, None]
            if found_corners:
                points3D = np.zeros((3, len(points2D[0])))
                validPoints = [False] * len(points2D[0])
                for index in range(len(points2D[0])):
                    corner = points2D[:, index].flatten()
                    depth = get_depth_at_pixel(depth_frame, corner[0],
                                               corner[1])
                    if depth != 0 and depth is not None:
                        validPoints[index] = True
                        [X, Y, Z] = convert_depth_pixel_to_metric_coordinate(
                            depth, corner[0], corner[1], depth_intrinsics)
                        points3D[0, index] = X
                        points3D[1, index] = Y
                        points3D[2, index] = Z
                corners3D[
                    serial] = found_corners, points2D, points3D, validPoints
        return corners3D
	def get_chessboard_corners_in3d(self):
		"""
		Searches the chessboard corners in the infrared images of 
		every connected device and uses the information in the 
		corresponding depth image to calculate the 3d 
		coordinates of the chessboard corners in the coordinate system of 
		the camera

		Returns:
		-----------
		corners3D : dict
			keys: str
				Serial number of the device
			values: [success, points3D, validDepths] 
				success: bool
					Indicates wether the operation was successfull
				points3d: array
					(3,N) matrix with the coordinates of the chessboard corners
					in the coordinate system of the camera. N is the number of corners
					in the chessboard. May contain points with invalid depth values
				validDephts: [bool]*
					Sequence with length N indicating which point in points3D has a valid depth value
		"""
		corners3D = {}
		for (serial, frameset) in self.frames.items():
			depth_frame = post_process_depth_frame(frameset[rs.stream.depth])
			infrared_frame = frameset[(rs.stream.infrared, 1)]
			depth_intrinsics = self.intrinsic[serial][rs.stream.depth]	
			found_corners, points2D = cv_find_chessboard(depth_frame, infrared_frame, self.chessboard_params)
			corners3D[serial] = [found_corners, None, None, None]
			if found_corners:
				points3D = np.zeros((3, len(points2D[0])))
				validPoints = [False] * len(points2D[0])
				for index in range(len(points2D[0])):
					corner = points2D[:,index].flatten()
					depth = get_depth_at_pixel(depth_frame, corner[0], corner[1])
					if depth != 0 and depth is not None:
						validPoints[index] = True
						[X,Y,Z] = convert_depth_pixel_to_metric_coordinate(depth, corner[0], corner[1], depth_intrinsics)
						points3D[0, index] = X
						points3D[1, index] = Y
						points3D[2, index] = Z
				corners3D[serial] = found_corners, points2D, points3D, validPoints
		return corners3D