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:
- Some python binding. Issue may be here
|
static Net readNetFromDarknet(std::istream &cfgFile, std::istream &darknetModel) |
|
DarknetImporter(std::istream &cfgStream, std::istream &darknetModelStream) |
|
void ReadNetParamsFromCfgStreamOrDie(std::istream &ifile, darknet::NetParameter *net) |
- Wherever
CV_Error lives
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
System information (version)
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:
opencv/modules/dnn/src/darknet/darknet_importer.cpp
Line 184 in b866d0d
opencv/modules/dnn/src/darknet/darknet_importer.cpp
Line 70 in b866d0d
opencv/modules/dnn/src/darknet/darknet_io.cpp
Line 1001 in b866d0d
CV_ErrorlivesSteps to reproduce
git clone https://github.com/pjreddie/darknet.gitpip install opencv-python-headlessorpip install opencv-pythonShould result in:
Issue submission checklist
answers.opencv.org, Stack Overflow, etc and have not found solution