Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using two dnn network causes crash

Hi I wanna to using two yolo network in my program (a yolo3-tiny and a yolov3-spp), but when I call net.forward function for the second network, I'm got following exception :

terminate called after throwing an instance of 'cv::Exception'
what():  OpenCV(4.0.0-pre) /home/pouya/Develop/opecv4/opencv/modules/dnn/src/dnn.cpp:1149: error: (-204:Requested object was not found) Layer with requested id=-1 not found in function 'getLayerData'

and when I comment one of the networks, it runs without any problem. Is there any solution for this problem?

Using two dnn network causes crash

Hi I wanna to using two yolo network in my program (a (an yolo3-tiny and a an yolov3-spp), but when I call net.forward function for the second network, I'm got following exception :

terminate called after throwing an instance of 'cv::Exception'
what():  OpenCV(4.0.0-pre) /home/pouya/Develop/opecv4/opencv/modules/dnn/src/dnn.cpp:1149: error: (-204:Requested object was not found) Layer with requested id=-1 not found in function 'getLayerData'

and when I comment one of the networks, it runs without any problem. Is there any solution for this problem? problem?

Using two dnn network causes crash

Hi I wanna to using two yolo network in my program (an yolo3-tiny and an yolov3-spp), but when I call net.forward function for the second network, I'm got following exception :

terminate called after throwing an instance of 'cv::Exception'
what():  OpenCV(4.0.0-pre) /home/pouya/Develop/opecv4/opencv/modules/dnn/src/dnn.cpp:1149: error: (-204:Requested object was not found) Layer with requested id=-1 not found in function 'getLayerData'

and when I comment one of the networks, it runs without any problem. Is there any solution for this problem?

Using two dnn network causes crash

Hi I wanna to using two yolo network in my program (an yolo3-tiny and an yolov3-spp), but when I call net.forward function for the second network, I'm got following exception :

terminate called after throwing an instance of 'cv::Exception'
what():  OpenCV(4.0.0-pre) /home/pouya/Develop/opecv4/opencv/modules/dnn/src/dnn.cpp:1149: error: (-204:Requested object was not found) Layer with requested id=-1 not found in function 'getLayerData'

and when I comment one of the networks, it runs without any problem. Is there any solution for this problem?

Using two dnn network networks causes crash

Hi I wanna to using two yolo network networks in my program (an yolo3-tiny and an yolov3-spp), but when I call net.forward function for the second network, I'm got following exception :

terminate called after throwing an instance of 'cv::Exception'
what():  OpenCV(4.0.0-pre) /home/pouya/Develop/opecv4/opencv/modules/dnn/src/dnn.cpp:1149: error: (-204:Requested object was not found) Layer with requested id=-1 not found in function 'getLayerData'

and when I comment one of the networks, it runs without any problem. Is there any solution for this problem?

Using two dnn networks causes crash

Hi I wanna to using two yolo networks in my program (an yolo3-tiny and an yolov3-spp), but when I call net.forward function for the second network, I'm got following exception :

terminate called after throwing an instance of 'cv::Exception'
what():  OpenCV(4.0.0-pre) /home/pouya/Develop/opecv4/opencv/modules/dnn/src/dnn.cpp:1149: error: (-204:Requested object was not found) Layer with requested id=-1 not found in function 'getLayerData'

there is my code :

bool Detector::postprocesstiny(const std::vector<cv::Mat>& outs)
{

    for (size_t i = 0; i < outs.size(); ++i)
    {
        float* data = (float*)outs[i].data;
        for (int j = 0; j < outs[i].rows; ++j, data += outs[i].cols)
        {
            cv::Mat scores = outs[i].row(j).colRange(5, outs[i].cols);
            cv::Point classIdPoint;
            double confidence;
            minMaxLoc(scores, 0, &confidence, 0, &classIdPoint);

            if (classIdPoint.x==2 && confidence > 0.5)
                return true ;
        }

    }
    return false ;

}


std::vector<cv::String> Detector::getOutputsNames(const cv::dnn::Net& net)
{
    static std::vector<cv::String> names;
    if (names.empty())
    {
        std::vector<int> outLayers = net.getUnconnectedOutLayers();
        std::vector<cv::String> layersNames = net.getLayerNames();
        names.resize(outLayers.size());
        for (size_t i = 0; i < outLayers.size(); ++i)
            names[i] = layersNames[outLayers[i] - 1];
    }
    return names;
}


bool Detector::isThereAnyCar(cv::Mat image) {

cv::Mat inputBlob = cv::dnn::blobFromImage(image, 1 / 255.F , cv::Size(416, 416), cv::Scalar(), true, false); 
net_tiny.setInput(inputBlob);                 
std::vector<cv::Mat> outs;

net_tiny.forward(outs, getOutputsNames(net_tiny));  
return postprocesstiny(outs);

}

cv::dnn::Net net = cv::dnn::readNetFromDarknet(modelConfiguration, modelBinary);
cv::dnn::Net net_tiny = cv::dnn::readNetFromDarknet(modelConfigurationTiny, modelBinaryTiny);
cv::Mat frame;
cv::VideoCapture cap(source);
cap >> frame;
if (isThereAnyCar(frame)) {
        cv::Mat inputBlob = cv::dnn::blobFromImage(frame, 1 / 255.F , cv::Size(416, 416), cv::Scalar(), true, false); 
        net.setInput(inputBlob);                   
        std::vector<cv::Mat> outs;

        std::vector<DetectionResult> detection_results;
        net.forward(outs, getOutputsNames(net));  //This line causes error 

}

and when I comment one of the networks, it runs without any problem. Is there any solution for this problem?