Skip to content

cPython Binding Not Setting Error in cv2.dnn.readNetFromDarknet #18835

@EmperorArthur

Description

@EmperorArthur
System information (version)
  • OpenCV => opencv-python-headless 4.4.0.46
  • Operating System / Platform => Ubuntu Linux, x64
Detailed description

Different from #18821 in cause, though the result is the same. In this case, the error I am causing is because the Python binding can not handle pathlib paths.

The real problem is that the C++ binding to Python does not properly set the error when "CV_Error" is caught.

I suspect the call stack looks like:

Steps to reproduce
import cv2
from pathlib import Path
darknet_path = Path('<path to darknet src>')
yolo_cfg_path = darknet_path.joinpath('cfg/yolov3.cfg')
yolo_weights_path = Path('<path to downloaded weights>')
net = cv2.dnn.readNetFromDarknet(yolo_cfg_path, yolo_weights_path)

Should result in:

Traceback (most recent call last):
File "", line 1, in
SystemError: returned NULL without setting an error

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    answers.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions