Unable to read model file in structurededgedetection
I've created the EdgeBoxes.cpp Example DLL for LabVIEW using OpenCV. I'm trying to open the model file in the DLL but all I get is an assertion fail. I also created VI's for morphology, Corner detection, hough transformation but never got any error messages like that.
I tried:
Every path combination using Forward slashes or back slashes. Putting every file into the same Folder(also in C:). (LabVIEW VI, DLL, ModelFile) To open it in LabVIEW first with "Open/Create/Replace.vi" To open the extracted model.yml file instead of model.yml.gz That's the point where I'm clueless:
string filename = "C:/model.yml.gz"
Ptr<StructuredEdgeDetection> pDollar; = createStructuredEdgeDetection(filename);
Error Message I'm receiving:
Error -1002 occurred at OpenCV(4.0.1-dev) C:\OpenCV\opencv_contrib-master\modules\ximgproc\src\structured_edge_detection.cpp:432: error: (-215:Assertion failed) modelFile.isOpened() in function 'cv::ximgproc::StructuredEdgeDetectionImpl::StructuredEdgeDetectionImpl'
I tried to read the file with ifstream and it seems like I can acess the file without any Problems (Code below). So the reason why it won't work seems to be in context with OpenCV?
std::ifstream is(filename, std::ifstream::binary);
is.seekg(0, is.end);
int length = is.tellg();
is.seekg(0, is.beg);
char * buffer = new char[length];
is.read(buffer, length);
is.close();
delete[] buffer; // buffer contains the entire file
Now I tried to open the file like OpenCV does after calling:
createStructuredEdgeDetection(filename); After that OpenCV tries to open the file with: See Row 431 https://github.com/opencv/opencv_cont...
cv::FileStorage modelFile(filename, FileStorage::READ)
Why does it work with
ifstream::binary
Do I have to recompile the "structured_edge_detection.cpp or cv::Filestorage with cmake?
Thanks for looking into this with me.
string filename = "C:\model.yml.gz"
-- in the end, it's a sillly path problem ? you either have to use/
or\\
(-215:Assertion failed) modelFile.isOpened()
-- believe it. it means what it says. there was nothing to open.As I said I tried every path combination / or \ it didn‘t work. And still I don‘t get it why the path above works with ifstream :: binary option.
however, it's wrong in your question, so how would we know better ?
but the ' binary' hint is somewhat interesting !