Search code examples
pythonc++opencvcaffecrf

OpenCV v3.1.0 with CRF-RNN


I'm building CRFasRNN which itself is based on caffe) after upgrading openCV to version 3.1.0 (the previous one was 2.4 I think). I keep getting errors like

io.cpp:(.text+0x11f8): undefined reference to `cv::imdecode(cv::_InputArray const&, int)'

during compilation, specifically when complining . This didn't happen the previous time I installed it. I built caffe and pycaffe (version 1.0.0.) without much complications, but the one that crf-rnn requires apparently has a problem with opencv 3.1.0. Installing pycaffe for crf-rnn alone doesn't work either. All paths to libraries seem to work fine, I'm not sure what I'm doing wrong.

I tried working something out with dependencies of opencv, but I keep getting messages like

The following packages have unmet dependencies.
 libopencv-dev : Depends: libopencv-objdetect-dev (= 2.3.1-7) but it is not going to be installed
                 Depends: libopencv-highgui-dev (= 2.3.1-7) but it is not going to be installed
                 Depends: libopencv-calib3d-dev (= 2.3.1-7) but it is not going to be installed
                 Depends: libopencv-features2d-dev (= 2.3.1-7) but it is not going to be installed
                 Depends: libopencv-legacy-dev (= 2.3.1-7) but it is not going to be installed
                 Depends: libopencv-contrib-dev (= 2.3.1-7) but it is not going to be installed

OpenCV alone works fine. Before this installation I had no problems.

Any suggestions?


Solution

  • OK I solved the problem by copying code from Makefile in the Caffe installation to Makefile for caffe-crfrnn. By 'code' I mean bits related to opencv. In addition to OPENCV_VERSION := 3 in Makefile.config I added

    USE_OPENCV ?= 1
    
    ifeq ($(USE_OPENCV), 1)
            LIBRARIES += opencv_core opencv_highgui opencv_imgproc
    
            ifeq ($(OPENCV_VERSION), 3)
                    LIBRARIES += opencv_imgcodecs
            endif
    endif
    
    # OpenCV
    ifeq ($(USE_OPENCV), 1)
            COMMON_FLAGS += -DUSE_OPENCV
    endif
    

    An it worked!