OpenCV with Kit 105 custom app

I have a custom extension and app using OpenCV that was working earlier but it is erroring with Kit 105.
I am getting an error while building custom app using Kit 105 (based on Developing on Nvidia Omniverse - How to Build an App — kit-project-template 105.0 documentation). I get the following error:

2024-04-18 16:39:30 [3,891ms] [Error] [omni.ext.impl.custom_importer] Failed to import python module 3des.videofeed.project. Error: DLL load failed while importing cv2: The specified module could not be found… Traceback:
Traceback (most recent call last):
File “d:\nvidia/omniverse/extensions/kit-project-template/kit/kernel/py\omni\ext_impl\custom_importer.py”, line 76, in import_module
return importlib.import_module(name)
File "d:\nvidia\omniverse\extensions\kit-project-template\kit\python\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1050, in _gcd_import
File “”, line 1027, in _find_and_load
File “”, line 1006, in find_and_load_unlocked
File “”, line 688, in load_unlocked
File “”, line 883, in exec_module
File “”, line 241, in call_with_frames_removed
File “d:/nvidia/omniverse/extensions/kit-project-template/source/extensions/3des.videofeed.project/3des/videofeed/project/init.py”, line 1, in
from .extension import *
File “d:/nvidia/omniverse/extensions/kit-project-template/source/extensions/3des.videofeed.project/3des/videofeed/project/extension.py”, line 11, in
import cv2
File "D:\NVidia\ov\data\Kit\my_name.my_app\1.0\pip3-envs\default\cv2_init
.py", line 181, in
bootstrap()
File "D:\NVidia\ov\data\Kit\my_name.my_app\1.0\pip3-envs\default\cv2_init
.py", line 153, in bootstrap
native_module = importlib.import_module(“cv2”)
File "d:\nvidia\omniverse\extensions\kit-project-template\kit\python\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing cv2: The specified module could not be found.

2024-04-18 16:39:30 [3,893ms] [Error] [carb.scripting-python.plugin] Exception: Extension python module: ‘3des.videofeed.project’ in ‘d:\nvidia\omniverse\extensions\kit-project-template\source\extensions\3des.videofeed.project’ failed to load.

At:
d:\nvidia/omniverse/extensions/kit-project-template/kit/kernel/py\omni\ext_impl_internal.py(213): startup
d:\nvidia/omniverse/extensions/kit-project-template/kit/kernel/py\omni\ext_impl_internal.py(328): startup_extension
PythonExtension.cpp::startup()(2):

2024-04-18 16:39:30 [3,894ms] [Error] [omni.ext.plugin] [ext: 3des.videofeed.project-1.0.0] Failed to startup python extension.

Here is the initialization of my extension:
from pathlib import Path
import carb
import numpy as np
import omni.ext
import omni.kit.app
import omni.ui as ui
import omni.kit.pipapi
omni.kit.pipapi.install(“opencv-python”)
import cv2

The error is occuring only with the latest Kit 105 custom extension/app. It works fine with USD composer 2023.2.5 when enabled as an extension.

Resolved it by using the solution from jshrake as follows:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.