Build error with Opencv with Inference Engine backend on raspberry

asked 2019-04-08 02:56:01 -0500

potoo gravatar image

updated 2019-04-08 03:03:18 -0500

berak gravatar image

I install OpenCV 4.0.1 followed Raspbian Stretch: Install OpenCV 3 + Python on your Raspberry Pi , successfully compiled and installed on my raspberry. But when I want compiled Opencv with Inference Engine backend, got some error.

my env:

- Raspberry 3b+
- OS: Raspbian 9.8
- Python: 3.5.3
- GCC: 6.3.0
- Make: 4.1
- Cmake: 3.7.2

Here is my code:

install dependencies(python’s dep already done):


sudo apt-get install \  
    cmake pkg-config \  
    libjpeg-dev libtiff5-dev libjasper-dev \  
    libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \  
    libxvidcore-dev libx264-dev \  
    libgtk2.0-dev libgtk-3-dev \  
    libatlas-base-dev gfortran \  
    build-essential \  
    xz-utils \  
    libgtk2.0-dev:armhf \  
    libgstreamer1.0-dev:armhf \  

cmake param:


cmake -DCMAKE_BUILD_TYPE=Release \  
      -DCMAKE_INSTALL_PREFIX="../opencv_install" \  
      -DWITH_IPP=OFF \  
      -DPYTHON3_EXECUTABLE=/usr/bin/python3.5 \  
      -DPYTHON3_LIBRARY=/usr/lib/arm-linux-gnueabihf/ \  
      -DPYTHON3_INCLUDE_DIR=/usr/include/python3.5m \  
      -DPYTHON3_INCLUDE_DIR2=/usr/include/arm-linux-gnueabihf/python3.5m \  
      -DPYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.5/dist-packages/numpy/core/include \  
      -DPYTHON3_CVPY_SUFFIX="" \  
      -DENABLE_NEON=ON \  
      -DINF_ENGINE_LIB_DIRS="/home/pi/inference_engine_vpu_arm/deployment_tools/inference_engine/lib/raspbian_9/armv7l" \  
      -DINF_ENGINE_INCLUDE_DIRS="/home/pi/inference_engine_vpu_arm/deployment_tools/inference_engine/include" \  
      -DCMAKE_FIND_ROOT_PATH="/home/pi/inference_engine_vpu_arm/" \  
      -DENABLE_CXX11=ON ..

then make -j4, come out a error:


[ 62%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/dnn.cpp.o
cd /home/pi/opencv/opencv_build/modules/dnn && /usr/bin/c++   -DCVAPI_EXPORTS -DCV_OCL4DNN=1 -DHAVE_INF_ENGINE=1 -DHAVE_PROTOBUF=1 -DINF_ENGINE_RELEASE=2019010000 -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/pi/opencv/opencv_build -I/home/pi/opencv/modules/dnn/src -I/home/pi/opencv/modules/dnn/include -I/home/pi/opencv/opencv_build/modules/dnn -I/home/pi/opencv/modules/core/include -I/home/pi/opencv/modules/imgproc/include -I/home/pi/opencv/modules/dnn/misc/caffe -I/home/pi/opencv/modules/dnn/misc/tensorflow -I/home/pi/opencv/modules/dnn/misc/onnx -I/home/pi/opencv/3rdparty/include/opencl/1.2 -isystem /home/pi/opencv/3rdparty/protobuf/src -isystem /home/pi/inference_engine_vpu_arm/deployment_tools/inference_engine/include  -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wundef -Winit-self -Wpointer-arith -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -mfpu=neon -mfp16-format=ieee -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated -Wno-missing-declarations -Wno-shadow -Wno-unused-parameter -Wno-sign-compare -Wno-invalid-offsetof -O3 -DNDEBUG  -DNDEBUG -fPIC   -std=c++11  -Winvalid-pch  -include "/home/pi/opencv/opencv_build/modules/dnn/precomp.hpp" -o CMakeFiles/opencv_dnn.dir/src/dnn.cpp.o -c /home/pi/opencv/modules/dnn/src/dnn.cpp

/home/pi/opencv/modules/dnn/src/dnn.cpp: In member function ‘void cv::dnn::dnn4_v20190122::Net::Impl::initInfEngineBackend()’:
/home/pi/opencv/modules/dnn/src/dnn.cpp:1708:68: error: ‘class InferenceEngine::Paramete
’ has no member named ‘as’
                         InferenceEngine::Blob::Ptr bp = it-><InferenceEngine::Blob::Ptr>();
/home/pi/opencv/modules/dnn/src/dnn.cpp:1708:97: error: expected primary-expression before ‘>’ token
             InferenceEngine::Blob::Ptr bp = it-><InferenceEngine::Blob::Ptr>();
/home/pi/opencv/modules/dnn/src/dnn.cpp:1708:99: error: expected primary-expression before ‘)’ token
             InferenceEngine::Blob::Ptr bp = it-><InferenceEngine::Blob::Ptr>();


/home/pi/inference_engine_vpu_arm/deployment_tools/inference_engine/include/ie_parameter.hpp:42:71: error: no matching function for call to ‘to_string ...
edit retag flag offensive close merge delete



@potoo, it looks like a conflict with IE versions. Please show which you downloaded and which is detected by OpenCV (see CMake summary). BTW, we just updated a wiki today and most likely you downloaded 2018R5 but OpenCV switched to 2019R1. So you need to download newer version of IE or specify it's older version manually with cmake flag: -DINF_ENGINE_RELEASE=2018050000.

dkurt gravatar imagedkurt ( 2019-04-08 04:18:32 -0500 )edit

@dkurt Yes, my IE version is 2018_R5, and opencv is newest version. Thanks for you answer, I am trying your approach.

potoo gravatar imagepotoo ( 2019-04-08 04:25:43 -0500 )edit

@dkurt It works, you saved me. But got another situation: open camera very slowly, cam.set() always return False no matter whether it takes effect, cam.get() can't get truth param of camera. Just like IE's built-in opencv. Is there any way to solve it?

potoo gravatar imagepotoo ( 2019-04-08 09:15:26 -0500 )edit

@potoo, Have you followed Try different camera backends (i.e. GStreamer, CAP_GSTREAMER, of Video for Linux, CAP_V4L2). You camera might be slow due to big frame resolution and you cannot change it because of FFMPEG backend. Please check which backend is used by getting CAP_PROP_BACKEND.

dkurt gravatar imagedkurt ( 2019-04-08 10:05:36 -0500 )edit

@dkurt Thank you for your patience and time. I'll have a try.
Usb camera's FPS, width, height could change if I use cam.set(), although it always return and cam.get() cann't get the value what I set.
The truth is everything works fine when I compile opencv without IE backend, I didn't specify or change any camera backend.

potoo gravatar imagepotoo ( 2019-04-08 20:54:10 -0500 )edit

@dkurt The following code is without my IE backend version:

potoo gravatar imagepotoo ( 2019-04-08 20:54:45 -0500 )edit

@dkurt Oh my god! Thank for you advice, when I specify V4L backend, everything just liek what I long for. Thanks again.

potoo gravatar imagepotoo ( 2019-04-09 05:04:16 -0500 )edit

em... I'm sorry, another error... out = net.forward() will raise [1] 20767 segmentation fault

potoo gravatar imagepotoo ( 2019-04-09 08:07:13 -0500 )edit

@potoo, Unfortunately I can say nothing without reproducer. Let's create a separate thread if you don't mind.

dkurt gravatar imagedkurt ( 2019-04-09 08:57:35 -0500 )edit


potoo gravatar imagepotoo ( 2019-04-09 09:43:45 -0500 )edit