# Path: third_party/xiuminglib/xiuminglib/imprt.py
# def preset_import(name, assert_success=False):
#     """A unified importer for both regular and ``google3`` modules, according
#     to specified presets/profiles (e.g., ignoring ``ModuleNotFoundError``).
#     """
#     if name in ('cv2', 'opencv'):
#         try:
#             # BUILD dep:
#             # "//third_party/py/cvx2",
#             from cvx2 import latest as mod
#             # Or
#             # BUILD dep:
#             # "//third_party/OpenCVX:cvx2",
#             # from google3.third_party.OpenCVX import cvx2 as cv2
#         except ModuleNotFoundError:
#             mod = import_module_404ok('cv2')
# 
#     elif name in ('tf', 'tensorflow'):
#         mod = import_module_404ok('tensorflow')
# 
#     elif name == 'gfile':
#         # BUILD deps:
#         # "//pyglib:gfile",
#         # "//file/colossus/cns",
#         mod = import_module_404ok('google3.pyglib.gfile')
# 
#     elif name == 'video_api':
#         # BUILD deps:
#         # "//learning/deepmind/video/python:video_api",
#         mod = import_module_404ok(
#             'google3.learning.deepmind.video.python.video_api')
# 
#     elif name in ('bpy', 'bmesh', 'OpenEXR', 'Imath'):
#         # BUILD deps:
#         # "//third_party/py/Imath",
#         # "//third_party/py/OpenEXR",
#         mod = import_module_404ok(name)
# 
#     elif name in ('Vector', 'Matrix', 'Quaternion'):
#         mod = import_module_404ok('mathutils')
#         mod = _get_module_class(mod, name)
# 
#     elif name == 'BVHTree':
#         mod = import_module_404ok('mathutils.bvhtree')
#         mod = _get_module_class(mod, name)
# 
#     else:
#         raise NotImplementedError(name)
# 
#     if assert_success:
#         assert mod is not None, "Failed in importing '%s'" % name
# 
#     return mod


import numpy as np
from ..imprt import preset_import
            assert h > 3, "Input has height (%d) > width (%d); the height" \
                % (h, w) + err_str
            pts_homo = np.hstack((pts, np.ones((h, 1))))
        elif h < w: # fat
            assert w > 3, "Input has width (%d) > height (%d); the width" \
                % (w, h) + err_str
            pts_homo = np.vstack((pts, np.ones((1, w))))
        else: # square
            raise ValueError(
                "Ambiguous square matrix that I can't guess how to pad")

    else:
        raise ValueError(pts.ndim)

    return pts_homo


def from_homo(pts, axis=None):
    """Converts from homogeneous to non-homogeneous coordinates.

    Args:
        pts (numpy.ndarray or mathutils.Vector): NumPy array of N-D point(s),
            or Blender vector of a single N-D point.
        axis (int, optional): The last slice of which dimension holds the
            :math:`w` values. Optional for 1D inputs.

    Returns:
        numpy.ndarray or mathutils.Vector: Non-homogeneous coordinates of the
        input point(s).
    """

# Path: third_party/xiuminglib/xiuminglib/imprt.py
# def preset_import(name, assert_success=False):
#     """A unified importer for both regular and ``google3`` modules, according
#     to specified presets/profiles (e.g., ignoring ``ModuleNotFoundError``).
#     """
#     if name in ('cv2', 'opencv'):
#         try:
#             # BUILD dep:
#             # "//third_party/py/cvx2",
#             from cvx2 import latest as mod
#             # Or
#             # BUILD dep:
#             # "//third_party/OpenCVX:cvx2",
#             # from google3.third_party.OpenCVX import cvx2 as cv2
#         except ModuleNotFoundError:
#             mod = import_module_404ok('cv2')
# 
#     elif name in ('tf', 'tensorflow'):
#         mod = import_module_404ok('tensorflow')
# 
#     elif name == 'gfile':
#         # BUILD deps:
#         # "//pyglib:gfile",
#         # "//file/colossus/cns",
#         mod = import_module_404ok('google3.pyglib.gfile')
# 
#     elif name == 'video_api':
#         # BUILD deps:
#         # "//learning/deepmind/video/python:video_api",
#         mod = import_module_404ok(
#             'google3.learning.deepmind.video.python.video_api')
# 
#     elif name in ('bpy', 'bmesh', 'OpenEXR', 'Imath'):
#         # BUILD deps:
#         # "//third_party/py/Imath",
#         # "//third_party/py/OpenEXR",
#         mod = import_module_404ok(name)
# 
#     elif name in ('Vector', 'Matrix', 'Quaternion'):
#         mod = import_module_404ok('mathutils')
#         mod = _get_module_class(mod, name)
# 
#     elif name == 'BVHTree':
#         mod = import_module_404ok('mathutils.bvhtree')
#         mod = _get_module_class(mod, name)
# 
#     else:
#         raise NotImplementedError(name)
# 
#     if assert_success:
#         assert mod is not None, "Failed in importing '%s'" % name
# 
#     return mod


# Path: third_party/xiuminglib/xiuminglib/geometry/proj.py
import numpy as np
from ..imprt import preset_import

            assert h > 3, "Input has height (%d) > width (%d); the height" \
                % (h, w) + err_str
            pts_homo = np.hstack((pts, np.ones((h, 1))))
        elif h < w: # fat
            assert w > 3, "Input has width (%d) > height (%d); the width" \
                % (w, h) + err_str
            pts_homo = np.vstack((pts, np.ones((1, w))))
        else: # square
            raise ValueError(
                "Ambiguous square matrix that I can't guess how to pad")

    else:
        raise ValueError(pts.ndim)

    return pts_homo


def from_homo(pts, axis=None):
    """Converts from homogeneous to non-homogeneous coordinates.

    Args:
        pts (numpy.ndarray or mathutils.Vector): NumPy array of N-D point(s),
            or Blender vector of a single N-D point.
        axis (int, optional): The last slice of which dimension holds the
            :math:`w` values. Optional for 1D inputs.

    Returns:
        numpy.ndarray or mathutils.Vector: Non-homogeneous coordinates of the
        input point(s).
    """

    Vector = preset_import('Vector')