Another cv::net.forward() problem

asked 2018-05-11 11:14:26 -0600

Banquin gravatar image

Hi everyone, I am trying to implement a object detector in ROS via OpenCV, However, in the step of forward(), I get always a mistake. The important parts of my code are:

cv::dnn::Net net;
    std::string path= ros::package::getPath("opencv_versuch_ros_tool");
    std::string path1=path+"/src/feed_network/opt_graph.pb";
    std::string path2=path+"/src/feed_network/graph.pbtxt";
    std::string pathImage=path+"/src/feed_network/audi.jpeg";
net=cv::dnn::readNetFromTensorflow(path1,path2);
    //ROS_INFO("%s\n",path1.data());
    cv::Mat image=cv::imread(pathImage);
    cv::Mat blob;
    blob=cv::dnn::blobFromImage(image,1.0/127.5,cvSize(300,300),127.5f,false);
    net.setInput(blob);
    cv::Mat outs=net.forward();

And when I execute it, I got:

OpenCV Error: Bad argument (PriorBox layer parameter does not contain min_size parameter.) in getParameter, file /builds/mrt-gbp/opencv/opencv/modules/dnn/src/layers/prior_box_layer.cpp, line 87
terminate called after throwing an instance of 'cv::Exception'
  what():  /builds/mrt-gbp/opencv/opencv/modules/dnn/src/layers/prior_box_layer.cpp:87: error: (-5) PriorBox layer parameter does not contain min_size parameter. in function getParameter

Aborted

I dont know if its a ROS problem, or from the network. However, I already used this network in a Python OpenCV program, and it worked, so I wouldnt say that's the problem.

I also already ran the optimize_for_inference.py like:

python optimize_for_inference.py --input frozen_inference_graph.pb --output
 opt_graph.pb --input_names image_tensor --output_names "num_detections,detection_scores,detection_boxes,detection_classes" --placeholder_type_enum 4 --frozen_graph

If someone know what is the problem, would be great, thanks!

edit retag flag offensive close merge delete