code: def parse_colmap_output(
      cameras_path: str,
      images_path: str,
      device: Device,
      dtype: torch.dtype,
  ) -> Tuple[List[str], PinholeCamera]:
      r"""Parses colmap output to create an PinholeCamera for aligned scene cameras.
  
      Args:
          cameras_path: Path to camera.txt Colmap file with camera intrinsics: str
          images_path: Path to images.txt Colmap file with camera extrinsics for each image: str
          device: device for created camera object: Union[str, torch.device]
  
      Returns:
          image names: List[str]
          scene camera object: PinholeCamera
      """
  
      # Parse camera intrinsics
      with open(cameras_path) as f:
          lines = f.readlines()
  
      class CameraParams:
          def __init__(self, line: str) -> None:
              split_line = line.split(" ")
              model = split_line[1]
              if model == "SIMPLE_PINHOLE":
                  self._width = int(split_line[2])
                  self._height = int(split_line[3])
                  self._fx = float(split_line[4])
                  self._fy = self._fx
                  self._cx = int(split_line[5])
                  self._cy = int(split_line[6])
              elif model == "PINHOLE":
                  self._width = int(split_line[2])
                  self._height = int(split_line[3])
                  self._fx = float(split_line[4])
                  self._fy = float(split_line[5])
                  self._cx = int(split_line[6])
                  self._cy = int(split_line[7])
  
      cameras_params: List[CameraParams] = []
      for line in lines:
          if line.startswith("#"):
              continue
          camera_params = CameraParams(line)
          cameras_params.append(camera_params)
  
      # Parse camera quaternions and translation vectors
      with open(images_path) as f:
          lines = f.readlines()
      intrinsics: List[Tensor] = []
      extrinsics: List[Tensor] = []
      heights: List[int] = []
      widths: List[int] = []
      img_names: List[str] = []
      for line in lines:
          if line.startswith("#"):
              continue
  
          # Read line with camera quaternion
          line = line.strip()
          if line.endswith(("jpg", "png")):
              split_line = line.split(" ")
              qw = float(split_line[1])
              qx = float(split_line[2])
              qy = float(split_line[3])
              qz = float(split_line[4])
              tx = float(split_line[5])
              ty = float(split_line[6])
              tz = float(split_line[7])
              camera_ind = int(split_line[8]) - 1
              img_name = split_line[9]
              img_names.append(img_name)
  
              # Intrinsic
              camera_params = cameras_params[camera_ind]
              intrinsic = torch.eye(4, device=device, dtype=dtype)
              intrinsic[0, 0] = camera_params._fx
              intrinsic[1, 1] = camera_params._fy
              intrinsic[0, 2] = camera_params._cx
              intrinsic[1, 2] = camera_params._cy
              intrinsics.append(intrinsic)
  
              heights.append(camera_params._height)
              widths.append(camera_params._width)
  
              # Extrinsic
              q = torch.tensor([qw, qx, qy, qz], device=device)
              R = quaternion_to_rotation_matrix(q)
              t = torch.tensor([tx, ty, tz], device=device)
              extrinsic = torch.eye(4, device=device, dtype=dtype)
              extrinsic[:3, :3] = R
              extrinsic[:3, 3] = t
              extrinsics.append(extrinsic)
  
      cameras = PinholeCamera(
          torch.stack(intrinsics),
          torch.stack(extrinsics),
          torch.tensor(heights, device=device),
          torch.tensor(widths, device=device),
      )
      return img_names, cameras
  
file_path: kornia/kornia/nerf/camera_utils.py
imports: import math
  from typing import List, Tuple, Union
  import torch
  from kornia.core import Device, Tensor, cos, sin, stack
  from kornia.geometry.camera import PinholeCamera
  from kornia.geometry.conversions import quaternion_to_rotation_matrix
label_desc: Use image node_id 1 for calling a global function with example usage: parse_colmap_output(cameras_path, images_path, device, dtype) and returns: img_names,  cameras