omni.kit.test_helpers_gfx

Testing system helpers for graphics.

Module that provides helpers that simplify writing tests, e.g. capture and compare screenshots, create windows, etc.

exception omni.kit.test_helpers_gfx.CompareError

Bases: Exception

omni.kit.test_helpers_gfx.capture(image_name: str, output_img_dir: str, app_window: Optional[omni.appwindow._appwindow.IAppWindow] = None)

Captures frame.

Parameters
  • image_name – the image name of the image and golden image.

  • output_img_dir – the directory path that the capture will be saved to.

  • golden_img_dir – the directory path that stores the golden image. Leave it to None to use default dir.

async omni.kit.test_helpers_gfx.capture_and_compare(image_name: str, threshold, output_img_dir: str, golden_img_dir: str, app_window: Optional[omni.appwindow._appwindow.IAppWindow] = None)

Captures frame and compares it with the golden image.

Parameters
  • image_name – the image name of the image and golden image.

  • threshold – the max threshold to collect TC artifacts.

  • golden_img_dir – the directory path that stores the golden image. Leave it to None to use default dir.

Returns

A value that indicates the maximum difference between pixels. 0 is no difference in the range [0-255].

omni.kit.test_helpers_gfx.compare(image1: pathlib.Path, image2: pathlib.Path, image_diffmap: pathlib.Path)

Compares two images and return a value that indicates the maximum differrence between pixels. 0 is no difference in the range [0-255].

It uses Pillow for image read.

Parameters
  • image1 – images to compare

  • image2 – images to compare

  • image_diffmap – the difference map image will be saved if there is any difference between given images

omni.kit.test_helpers_gfx.finalize_capture_and_compare(image_name: str, threshold, output_img_dir: str, golden_img_dir: str, app_window: Optional[omni.appwindow._appwindow.IAppWindow] = None)

Finalizes capture and compares it with the golden image.

Parameters
  • image_name – the image name of the image and golden image.

  • threshold – the max threshold to collect TC artifacts.

  • output_img_dir – the directory path that the capture will be saved to.

  • golden_img_dir – the directory path that stores the golden image. Leave it to None to use default dir.

  • app_window – IAppWindow instance for which the capture will happen, use None to capture default app window.

Returns

A value that indicates the maximum difference between pixels. 0 is no difference in the range [0-255].