Ask Your Question
0

Trying to run dnn module

asked 2016-12-08 06:28:22 -0500

kevgeo gravatar image

updated 2016-12-08 10:35:39 -0500

berak gravatar image

I have installed Opencv 3.1.0 along with Opencv_contrib module with the aim of reading caffe models into Opencv. I followed the official Opencv installation documentation and with a change in Cmake command, I was able to build it successfully on Ubuntu 14.04lts.

When I type the following command to run the sample program -

g++ -o 1 ssd_object_detection.cpp  `pkg-config --cflags --libs opencv`

I get the error below.

ssd_object_detection.cpp:1:27: fatal error: opencv2/dnn.hpp: No such file or directory
 #include <opencv2/dnn.hpp>
                           ^
compilation terminated.

I looked at the opencv_contrib github repo and they mentioned that you have to run it with a linker to the specific module which you want. So my command then became-

g++ -o 1 ssd_object_detection.cpp  `pkg-config --cflags --libs opencv` -lopencv_dnn

But I still get the same error. Does this mean that my dnn module hasn't been built properly? The error is from the header file opencv2/dnn.hpp not being recognised but I don't know why?

The sample program is from this link- sample program to load caffe model and run

Output of cmake-

cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTRA_MODULES=~/opt/opencv_contrib/modules -D CMAKE_INSTALL_PREFIX=/usr/local ..
-- The CXX compiler identification is GNU 4.8.4
-- The C compiler identification is GNU 4.8.4
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Detected version of GNU GCC: 48 (408)
-- Performing Test HAVE_CXX_FSIGNED_CHAR
-- Performing Test HAVE_CXX_FSIGNED_CHAR - Success
-- Performing Test HAVE_C_FSIGNED_CHAR
-- Performing Test HAVE_C_FSIGNED_CHAR - Success
-- Performing Test HAVE_CXX_W
-- Performing Test HAVE_CXX_W - Success
-- Performing Test HAVE_C_W
-- Performing Test HAVE_C_W - Success
-- Performing Test HAVE_CXX_WALL
-- Performing Test HAVE_CXX_WALL - Success
-- Performing Test HAVE_C_WALL
-- Performing Test HAVE_C_WALL - Success
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_C_WERROR_RETURN_TYPE
-- Performing Test HAVE_C_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_CXX_WERROR_ADDRESS
-- Performing Test HAVE_CXX_WERROR_ADDRESS - Success
-- Performing Test HAVE_C_WERROR_ADDRESS
-- Performing Test HAVE_C_WERROR_ADDRESS - Success
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_CXX_WFORMAT
-- Performing Test HAVE_CXX_WFORMAT - Success
-- Performing Test HAVE_C_WFORMAT
-- Performing Test HAVE_C_WFORMAT - Success
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_C_WMISSING_DECLARATIONS
-- Performing Test HAVE_C_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed
-- Performing Test HAVE_C_WMISSING_PROTOTYPES
-- Performing Test HAVE_C_WMISSING_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Failed
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WUNDEF
-- Performing Test HAVE_CXX_WUNDEF - Success
-- Performing Test HAVE_C_WUNDEF
-- Performing Test HAVE_C_WUNDEF - Success
-- Performing Test HAVE_CXX_WINIT_SELF
-- Performing Test HAVE_CXX_WINIT_SELF - Success
-- Performing Test HAVE_C_WINIT_SELF
-- Performing Test HAVE_C_WINIT_SELF - Success
-- Performing Test HAVE_CXX_WPOINTER_ARITH
-- Performing Test ...
(more)
edit retag flag offensive close merge delete

Comments

  • please check the cmake output again, to see, if the dnn module was actually built.
  • did you run make install ?
  • what does pkg-config --cflags --libs opencv say, when run standalone on cmdliine ?
  • you could try to use cmake to generate a makefile (alternative to the pkg-config approach)
berak gravatar imageberak ( 2016-12-08 07:28:43 -0500 )edit

Hi berak,

  1. Yes i ran make install.
  2. When i run the pkg-config --cflags --libs opencv command, there is no mention of dnn module.
  3. I tried running using cmake from the link you gave but it gives the same error.
kevgeo gravatar imagekevgeo ( 2016-12-08 09:37:03 -0500 )edit

in that case, can you try to run cmake again, and add the output to your question (i know, it's pretty long, but there will be something helpful buried in that) ?

berak gravatar imageberak ( 2016-12-08 09:52:31 -0500 )edit
1

I'm really sorry but I'm not sure how to edit the cmake output properly in opencv q&A

kevgeo gravatar imagekevgeo ( 2016-12-08 10:32:31 -0500 )edit

^^ don't worry ;)

berak gravatar imageberak ( 2016-12-08 10:34:06 -0500 )edit

looking at it, it seems, it did not build any module from opencv_contrib. (see: "To be build" section)

can you check again, if ~/opt/opencv_contrib/modules is the correct path for your OPENCV_EXTRA_MODULES cmdline argument ?

( the ~ in front of it looks pretty suspicious to me ;) )

berak gravatar imageberak ( 2016-12-08 10:40:26 -0500 )edit

what did you do to format the output? Also as you can see from output, the extra modules from opencv_contrib are not being built but are also not unavailable? How is that possible even when my cmake path points to the opencv_contrib folder?

kevgeo gravatar imagekevgeo ( 2016-12-08 10:41:18 -0500 )edit

Yes, it is the correct path. Sometimes without the ~, it goes to the other opt folder and not the one i made at home.

kevgeo gravatar imagekevgeo ( 2016-12-08 10:42:02 -0500 )edit

what did you do to format the output?

mark all cmake output with mouse (not only 1st line), then press "10101" button

berak gravatar imageberak ( 2016-12-08 10:49:02 -0500 )edit

but again, my "current work hypothesis" is: cmake did not find the opencv_contrib modules (due to something wrong in OPENCV_EXTRA_MODULES

try an absolute path, not a relative one

berak gravatar imageberak ( 2016-12-08 10:51:40 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-12-09 06:09:11 -0500

pi-null-mezon gravatar image

Your CMAKE log shows that no one of opencv_contrib module have been built. To change this

1) install CMake-gui

2) Run it and point to opencv sources (you should dowload it first, and the opencv_contrib sources too)

3) In OPENCV group in CMake-gui you will find EXTRA_MODULES_PATH (search on figure I have attached), point to opencv_contrib/modules

4) Press "configure" button untill no one red property last

5) Press "generate"

6) Now in CMAKE/build directory (where all prepared sources has been copied) run make

7) After make you can also install by make install

image description

edit flag offensive delete link more

Comments

thanks, for answering, pi !

(situation has progressed to missing protobuf files, could you look at the comments above, again ? maybe you have an idea there, too ! ;)

berak gravatar imageberak ( 2016-12-09 06:37:13 -0500 )edit

On Windows opencv_dnn could be built without protobuf. Try to unckeck it.

pi-null-mezon gravatar imagepi-null-mezon ( 2016-12-09 09:15:37 -0500 )edit

Hey pi, using cmake on command line, I got a linking error for protobuf. So I manually copied protobuf from their github repo and it built perfectly fine. I can compile the sample dnn program but can't run it. I guess I will as it as a separate question.

kevgeo gravatar imagekevgeo ( 2016-12-09 22:31:47 -0500 )edit

Hey pi, using cmake on command line, I got a linking error for protobuf. So I manually copied protobuf from their github repo and it built perfectly fine. I can compile the sample dnn program but can't run it. I guess I will ask it as a separate question.

kevgeo gravatar imagekevgeo ( 2016-12-09 22:32:00 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-12-08 06:28:22 -0500

Seen: 2,157 times

Last updated: Dec 09 '16