-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
cPython Binding Not Setting Error in cv2.dnn.readNetFromDarknet #18835
Copy link
Copy link
Closed
Milestone
Description
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) opencv/modules/dnn/src/darknet/darknet_io.cpp
Line 1001 in b866d0d
void ReadNetParamsFromCfgStreamOrDie(std::istream &ifile, darknet::NetParameter *net) - Wherever
CV_Errorlives
Steps to reproduce
- Git clone darknet to a directory via
git clone https://github.com/pjreddie/darknet.git - Download YOLO weights from 'https://pjreddie.com/media/files/yolov3.weights'
- Run:
pip install opencv-python-headlessorpip install opencv-python
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
Reactions are currently unavailable