Hello
Question : OpenCV DNN module, cv::dnn::Net::forward causes error and that Net::forward() is in a DLL that i made before. Since it came from DLL, debug messages are not displayed on Console window.
Is there any way to display debug messages came from DLL that contains OpenCV?
Is there a Special way to run cv::dnn::Net::forward() from DLL?
Situation : I have made .weight file and .cfg file through Yolov3 of Darknet to run it in OpenCV dnn module.
Language is C++.
Here is my code:
//Initialize Net, darkConfig = yolov3-tiny-obj.cfg darkModel = ...
Net net = readNetFromDarknet(darkConfig, darkModel);
net.setPreferableBackend(DNN_BACKEND_OPENCV);
net.setPreferableTarget(DNN_TARGET_CPU);
//Get Classes Names, ex Bird, Dog...
string classesFile = "obj.names";
ifstream ifs(classesFile.c_str());
string line;
while (getline(ifs, line))
{
classes.push_back(line);
cout << line << endl;
}
VideoCapture cap(0);
if (cap.isOpened() == false)
{
cerr << "No cam" << endl;
return -1;
}
Mat frame;
while (true)
{
cap >> frame;
if (frame.empty()) break;
Mat blob;
// Create a 4D blob from a frame.
blobFromImage(frame, blob, 1 / 255.0, Size(288, 288), Scalar(0, 0, 0), true, false);
//Sets the input to the network
net.setInput(blob);
// Runs the forward pass to get output of the output layers
vector<Mat> outs;
//BUT THIS LINE ALWAYS CAUSES ERROR
net.forward(outs, getOutputsNames(net));
// Remove the bounding boxes with low confidence
postprocess(frame, outs);
cv::imshow("Frame", frame);
if (cv::waitKey(1) == 27)
break;
}
return 0;
This Code works well when it is built by Visual Studio C++.
But When it is built as DLL and linked to another, the cv::dnn::Net::forward() causes error.
Other Net class' methods works well like Net::setInput() etc.
Even this error cannot be debugged like so :
Conclusion:
cv::dnn::Net::forward() works well in general C++ project.
When that project is built as DLL and linked to another C++project, the only Net::forward() causes error.
How to solve this problem?
Thank you.