Skip to content

Fix: Poisoned python exception - #2

Merged
aljazkonec1 merged 1 commit into
masterfrom
fix/poisoned_python_exception
Aug 14, 2026
Merged

Fix: Poisoned python exception#2
aljazkonec1 merged 1 commit into
masterfrom
fix/poisoned_python_exception

Conversation

@aljazkonec1

@aljazkonec1 aljazkonec1 commented Aug 14, 2026

Copy link
Copy Markdown

Purpose

With PR #1909 a colorizeDepth frame was added to DepthAI. The function has two overloads:

utility.def( "colorizeDepthFrame", [](const cv::Mat& frame, float minDepth, float maxDepth, int colormap, bool useLog) ...

and

utility.def( "colorizeDepthFrame", [](const ImgFrame& frame, float minDepth, float maxDepth, int colormap, bool useLog) ..

When an ImgFrame object is passed, pybind probes the cv::Mat overload during dispatch. The custom cv::Mat caster tries rejects the object, sets a TypeError before returning false. This PR clears the error before returning false. This allows pybind to probe the next overload and fail in the next overload if that one is not correct.

Example of error:
error

Specification

None / not applicable

Dependencies & Potential Impact

None / not applicable

Deployment Plan

None / not applicable

Testing & Validation

None / not applicable

AI Usage

Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]

Submitted code was reviewed by a human: YES/NO

The author is taking the responsibility for the contribution: YES/NO

@aljazkonec1

Copy link
Copy Markdown
Author

Tested and it works:


(depthai3-12) aljaz@pc:depthai-core $ python examples/python/PointCloud/point_cloud_visualizer.py 
PointCloud Visualizer
=====================
Connecting to device...
Device: OAK4-D-PRO-W  (ID: 733979940)

Waiting for auto-exposure to settle...
Streaming... Press Q in the Open3D window to quit.
^C
Stopping...
Done.
(depthai3-12) aljaz@pc:depthai-core $ python3 -m pip install --extra-index-url https://artifacts.luxonis.com/artifactory/luxonis-python-snapshot-local/ depthai==3.9.0.dev0+5c9ed711a507bcc158cfc731c216d3fcea306792
Looking in indexes: https://pypi.org/simple, https://artifacts.luxonis.com/artifactory/luxonis-python-snapshot-local/
Requirement already satisfied: depthai==3.9.0.dev0+5c9ed711a507bcc158cfc731c216d3fcea306792 in /home/aljaz/miniforge3/envs/depthai3-12/lib/python3.12/site-packages (3.9.0.dev0+5c9ed711a507bcc158cfc731c216d3fcea306792)
Requirement already satisfied: numpy<3.0.0 in /home/aljaz/miniforge3/envs/depthai3-12/lib/python3.12/site-packages (from depthai==3.9.0.dev0+5c9ed711a507bcc158cfc731c216d3fcea306792) (2.5.2)
(failed reverse-i-search)`PYH': export ^CTHONPATH=/home/aljaz/work-luxonis/depthai-core/build/bindings/python
(failed reverse-i-search)`PYHTONPA': export ^CTHONPATH=/home/aljaz/work-luxonis/depthai-core/build/bindings/python
(depthai3-12) aljaz@pc:depthai-core $ unset PYTHONPATH 
(depthai3-12) aljaz@pc:depthai-core $ python examples/python/PointCloud/point_cloud_visualizer.py 
PointCloud Visualizer
=====================
Connecting to device...
Device: OAK4-D-PRO-W  (ID: 733979940)

Waiting for auto-exposure to settle...
Streaming... Press Q in the Open3D window to quit.
TypeError: return value is not a numpy array, neither a scalar

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/aljaz/work-luxonis/depthai-core/examples/python/PointCloud/point_cloud_visualizer.py", line 121, in <module>
    main()
  File "/home/aljaz/work-luxonis/depthai-core/examples/python/PointCloud/point_cloud_visualizer.py", line 103, in main
    cv2.imshow("Depth", dai.utility.colorizeDepthFrame(depthMsg, 300, 12000, cv2.COLORMAP_HOT, useLog=True).getCvFrame())
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: <built-in method colorizeDepthFrame of PyCapsule object at 0x7d75f0923f00> returned a result with an exception set

@aljazkonec1
aljazkonec1 merged commit 7926f9a into master Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants