Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV 3.4.1 error readNetFromTensorflow Can't open .pb in cv::dnn::ReadProtoFromBinaryFile

I have a problem with opening protobuf file using opencv C++. I use this code:

cv::String weights = "frozen_inference_graph_face.pb";
cv::String pbtxt = "prototxt.pbtxt";
auto graph = cv::dnn::readNetFromTensorflow(weights, pbtxt);

I have this error:

OpenCV(3.4.1) Error: Unspecified error (FAILED: fs.is_open(). Can't open "frozen_inference_graph_face.pb") in cv::dnn::ReadProtoFromBinaryFile, file C:.hunter_Base\acbf4b9\93b3222\8eb84a0\Build\OpenCV\Source\modules\dnn\src\caffe\caffe_io.cpp, line 1126

It works well when I open it with Python code like this and detect image correctly:

cvNet = 

I have trained ssd_mobilenet_v1_pets. Cannot understand why I cannot open it with my C++ code and the error is refers to cafe, when I use tensorflow. Maybe the configuration of builded OpenCV is wrong? I set WITH_PROTOBUF=ON and BUILD_opencv_dnn=ON.