fix typo and minor formatting issues

PiperOrigin-RevId: 491453662
This commit is contained in:
MediaPipe Team 2022-11-28 15:02:55 -08:00 committed by Copybara-Service
parent b65c40b302
commit 26a7ca5c64

View File

@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
"""MediaPipe solution drawing utils.""" """MediaPipe solution drawing utils."""
import math import math
@ -135,15 +134,14 @@ def draw_landmarks(
the image. the image.
connections: A list of landmark index tuples that specifies how landmarks to connections: A list of landmark index tuples that specifies how landmarks to
be connected in the drawing. be connected in the drawing.
landmark_drawing_spec: Either a DrawingSpec object or a mapping from landmark_drawing_spec: Either a DrawingSpec object or a mapping from hand
hand landmarks to the DrawingSpecs that specifies the landmarks' drawing landmarks to the DrawingSpecs that specifies the landmarks' drawing
settings such as color, line thickness, and circle radius. settings such as color, line thickness, and circle radius. If this
If this argument is explicitly set to None, no landmarks will be drawn. argument is explicitly set to None, no landmarks will be drawn.
connection_drawing_spec: Either a DrawingSpec object or a mapping from connection_drawing_spec: Either a DrawingSpec object or a mapping from hand
hand connections to the DrawingSpecs that specifies the connections to the DrawingSpecs that specifies the connections' drawing
connections' drawing settings such as color and line thickness. settings such as color and line thickness. If this argument is explicitly
If this argument is explicitly set to None, no landmark connections will set to None, no landmark connections will be drawn.
be drawn.
Raises: Raises:
ValueError: If one of the followings: ValueError: If one of the followings:
@ -197,8 +195,7 @@ def draw_landmarks(
drawing_spec.color, drawing_spec.thickness) drawing_spec.color, drawing_spec.thickness)
def draw_axis( def draw_axis(image: np.ndarray,
image: np.ndarray,
rotation: np.ndarray, rotation: np.ndarray,
translation: np.ndarray, translation: np.ndarray,
focal_length: Tuple[float, float] = (1.0, 1.0), focal_length: Tuple[float, float] = (1.0, 1.0),
@ -214,8 +211,8 @@ def draw_axis(
focal_length: camera focal length along x and y directions. focal_length: camera focal length along x and y directions.
principal_point: camera principal point in x and y. principal_point: camera principal point in x and y.
axis_length: length of the axis in the drawing. axis_length: length of the axis in the drawing.
axis_drawing_spec: A DrawingSpec object that specifies the xyz axis axis_drawing_spec: A DrawingSpec object that specifies the xyz axis drawing
drawing settings such as line thickness. settings such as line thickness.
Raises: Raises:
ValueError: If one of the followings: ValueError: If one of the followings:
@ -226,7 +223,7 @@ def draw_axis(
image_rows, image_cols, _ = image.shape image_rows, image_cols, _ = image.shape
# Create axis points in camera coordinate frame. # Create axis points in camera coordinate frame.
axis_world = np.float32([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]]) axis_world = np.float32([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]])
axis_cam = np.matmul(rotation, axis_length*axis_world.T).T + translation axis_cam = np.matmul(rotation, axis_length * axis_world.T).T + translation
x = axis_cam[..., 0] x = axis_cam[..., 0]
y = axis_cam[..., 1] y = axis_cam[..., 1]
z = axis_cam[..., 2] z = axis_cam[..., 2]
@ -274,8 +271,9 @@ def plot_landmarks(landmark_list: landmark_pb2.NormalizedLandmarkList,
connections' drawing settings such as color and line thickness. connections' drawing settings such as color and line thickness.
elevation: The elevation from which to view the plot. elevation: The elevation from which to view the plot.
azimuth: the azimuth angle to rotate the plot. azimuth: the azimuth angle to rotate the plot.
Raises: Raises:
ValueError: If any connetions contain invalid landmark index. ValueError: If any connection contains an invalid landmark index.
""" """
if not landmark_list: if not landmark_list:
return return