Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCV Error! #65

Open
KeeganRen opened this issue Jul 26, 2016 · 6 comments
Open

OpenCV Error! #65

KeeganRen opened this issue Jul 26, 2016 · 6 comments

Comments

@KeeganRen
Copy link

Ubuntu 14.04.4 LTS
opencv 2.4.12
compile caffe is ok, but when i compile ssd, it will ....

./include/caffe/layers/video_data_layer.hpp:52:3: error: ‘VideoCapture’ in namespace ‘cv’ does not name a type
cv::VideoCapture cap_;
^
src/caffe/layers/video_data_layer.cpp: In destructor ‘virtual caffe::VideoDataLayer::~VideoDataLayer()’:
src/caffe/layers/video_data_layer.cpp:28:7: error: ‘cap_’ was not declared in this scope
if (cap_.isOpened()) {
^
src/caffe/layers/video_data_layer.cpp: In member function ‘virtual void caffe::VideoDataLayer::DataLayerSetUp(const std::vectorcaffe::Blob<Dtype_>&, const std::vectorcaffe::Blob<Dtype_>&)’:
src/caffe/layers/video_data_layer.cpp:45:10: error: ‘cap_’ was not declared in this scope
if (!cap_.open(device_id)) {
^
src/caffe/layers/video_data_layer.cpp:48:5: error: ‘cap_’ was not declared in this scope
cap_ >> cv_img;
^
src/caffe/layers/video_data_layer.cpp:52:10: error: ‘cap_’ was not declared in this scope
if (!cap_.open(video_file)) {
^
src/caffe/layers/video_data_layer.cpp:55:21: error: ‘cap_’ was not declared in this scope
total_frames_ = cap_.get(CV_CAP_PROP_FRAME_COUNT);
^
src/caffe/layers/video_data_layer.cpp:55:30: error: ‘CV_CAP_PROP_FRAME_COUNT’ was not declared in this scope
total_frames_ = cap_.get(CV_CAP_PROP_FRAME_COUNT);
^
src/caffe/layers/video_data_layer.cpp:60:14: error: ‘CV_CAP_PROP_POS_FRAMES’ was not declared in this scope
cap_.set(CV_CAP_PROP_POS_FRAMES, 0);
^
In file included from ./include/caffe/common.hpp:6:0,
from ./include/caffe/blob.hpp:8,
from ./include/caffe/data_transformer.hpp:8,
from src/caffe/layers/video_data_layer.cpp:14:
src/caffe/layers/video_data_layer.cpp:64:15: error: invalid use of incomplete type ‘class cv::Mat’
CHECK(cv_img.data) << "Could not load image!";
^
In file included from ./include/caffe/blob.hpp:8:0,
from ./include/caffe/data_transformer.hpp:8,
from src/caffe/layers/video_data_layer.cpp:14:
./include/caffe/common.hpp:73:22: error: forward declaration of ‘class cv::Mat’
namespace cv { class Mat; }
^
src/caffe/layers/video_data_layer.cpp: In member function ‘virtual void caffe::VideoDataLayer::load_batch(caffe::Batch)’:
src/caffe/layers/video_data_layer.cpp:116:7: error: ‘cap
’ was not declared in this scope
cap_ >> cv_img;
^
src/caffe/layers/video_data_layer.cpp:123:7: error: ‘cap_’ was not declared in this scope
cap_ >> cv_img;
^
In file included from ./include/caffe/common.hpp:6:0,
from ./include/caffe/blob.hpp:8,
from ./include/caffe/data_transformer.hpp:8,
from src/caffe/layers/video_data_layer.cpp:14:
src/caffe/layers/video_data_layer.cpp:127:17: error: invalid use of incomplete type ‘class cv::Mat’
CHECK(cv_img.data) << "Could not load image!";
^
In file included from ./include/caffe/blob.hpp:8:0,
from ./include/caffe/data_transformer.hpp:8,
from src/caffe/layers/video_data_layer.cpp:14:
./include/caffe/common.hpp:73:22: error: forward declaration of ‘class cv::Mat’
namespace cv { class Mat; }
^
src/caffe/layers/video_data_layer.cpp: In instantiation of ‘void caffe::VideoDataLayer::DataLayerSetUp(const std::vectorcaffe::Blob<Dtype_>&, const std::vectorcaffe::Blob<Dtype_>&) [with Dtype = float]’:
src/caffe/layers/video_data_layer.cpp:146:1: required from here
src/caffe/layers/video_data_layer.cpp:42:11: error: ‘cv::Mat cv_img’ has incomplete type
cv::Mat cv_img;
^
src/caffe/layers/video_data_layer.cpp: In instantiation of ‘void caffe::VideoDataLayer::load_batch(caffe::Batch) [with Dtype = float]’:
src/caffe/layers/video_data_layer.cpp:146:1: required from here
src/caffe/layers/video_data_layer.cpp:114:13: error: ‘cv::Mat cv_img’ has incomplete type
cv::Mat cv_img;
^
src/caffe/layers/video_data_layer.cpp: In instantiation of ‘void caffe::VideoDataLayer::DataLayerSetUp(const std::vectorcaffe::Blob<Dtype
>&, const std::vectorcaffe::Blob<Dtype_>&) [with Dtype = double]’:
src/caffe/layers/video_data_layer.cpp:146:1: required from here
src/caffe/layers/video_data_layer.cpp:42:11: error: ‘cv::Mat cv_img’ has incomplete type
cv::Mat cv_img;
^
src/caffe/layers/video_data_layer.cpp: In instantiation of ‘void caffe::VideoDataLayer::load_batch(caffe::Batch) [with Dtype = double]’:
src/caffe/layers/video_data_layer.cpp:146:1: required from here
src/caffe/layers/video_data_layer.cpp:114:13: error: ‘cv::Mat cv_img’ has incomplete type
cv::Mat cv_img;
^
make: *
* [.build_release/src/caffe/layers/video_data_layer.o] Error 1
make: *** Waiting for unfinished jobs....

@weiliu89
Copy link
Owner

It seems to be an OpenCV issue. According to here, you only need to have #include "opencv2/opencv.hpp". I have specified the different header file at here.

I am guessing you have uncommented this line in your Makefile.config. You shouldn't since you are not using OpenCV 3.

@KeeganRen
Copy link
Author

KeeganRen commented Jul 29, 2016

``## Refer to http://caffe.berkeleyvision.org/installation.html

Contributions simplifying and improving our build system are welcome!

cuDNN acceleration switch (uncomment to build with cuDNN).

USE_CUDNN := 1

CPU-only switch (uncomment to build without GPU support).

CPU_ONLY := 1

uncomment to disable IO dependencies and corresponding data layers

USE_OPENCV := 0

USE_LEVELDB := 0

USE_LMDB := 0

uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)

You should not set this flag if you will be reading LMDBs with any

possibility of simultaneous read and write

ALLOW_LMDB_NOLOCK := 1

Uncomment if you're using OpenCV 3

OPENCV_VERSION := 3

To customize your choice of compiler, uncomment and set the following.

N.B. the default for Linux is g++ and the default for OSX is clang++

CUSTOM_CXX := g++

CUDA directory contains bin/ and lib/ directories that we need.

CUDA_DIR := /usr/local/cuda

On Ubuntu 14.04, if cuda tools are installed via

"sudo apt-get install nvidia-cuda-toolkit" then use this instead:

CUDA_DIR := /usr

CUDA architecture setting: going with all of them.

For CUDA < 6.0, comment the *_50 lines for compatibility.

CUDA_ARCH := -gencode arch=compute_20,code=sm_20
-gencode arch=compute_20,code=sm_21
-gencode arch=compute_30,code=sm_30
-gencode arch=compute_35,code=sm_35
-gencode arch=compute_50,code=sm_50
-gencode arch=compute_50,code=compute_50

BLAS choice:

atlas for ATLAS (default)

mkl for MKL

open for OpenBlas

BLAS := mkl

Custom (MKL/ATLAS/OpenBLAS) include and lib directories.

Leave commented to accept the defaults for your choice of BLAS

(which should work)!

BLAS_INCLUDE := /path/to/your/blas

BLAS_LIB := /path/to/your/blas

BLAS_INCLUDE := /opt/intel/composer_xe_2013_sp1.3.174/mkl/include
BLAS_LIB := /opt/intel/composer_xe_2013_sp1.3.174/mkl/lib /opt/intel/composer_xe_2013_sp1.3.174/mkl/lib/intel64

Homebrew puts openblas in a directory that is not on the standard search path

BLAS_INCLUDE := $(shell brew --prefix openblas)/include

BLAS_LIB := $(shell brew --prefix openblas)/lib

This is required only if you will compile the matlab interface.

MATLAB directory should contain the mex binary in /bin.

MATLAB_DIR := /usr/local

MATLAB_DIR := /Applications/MATLAB_R2012b.app

MATLAB_DIR :=/usr/local/MATLAB/R2014a

NOTE: this is required only if you will compile the python interface.

We need to be able to find Python.h and numpy/arrayobject.h.

PYTHON_INCLUDE := /usr/include/python2.7
/usr/lib/python2.7/dist-packages/numpy/core/include

Anaconda Python distribution is quite popular. Include path:

Verify anaconda location, sometimes it's in root.

ANACONDA_HOME := $(HOME)/anaconda

PYTHON_INCLUDE := $(ANACONDA_HOME)/include \

    # $(ANACONDA_HOME)/include/python2.7 \
    # $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \

Uncomment to use Python 3 (default is Python 2)

PYTHON_LIBRARIES := boost_python3 python3.5m

PYTHON_INCLUDE := /usr/include/python3.5m \

/usr/lib/python3.5/dist-packages/numpy/core/include

We need to be able to find libpythonX.X.so or .dylib.

PYTHON_LIB := /usr/lib

PYTHON_LIB := $(ANACONDA_HOME)/lib

Homebrew installs numpy in a non standard path (keg only)

PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.file)'))/include

PYTHON_LIB += $(shell brew --prefix numpy)/lib

Uncomment to support layers written in Python (will link against Python libs)

WITH_PYTHON_LAYER := 1

Whatever else you find you need goes here.

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/local/hdf5/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/local/hdf5/lib

If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies

INCLUDE_DIRS += $(shell brew --prefix)/include

LIBRARY_DIRS += $(shell brew --prefix)/lib

Uncomment to use pkg-config to specify OpenCV library paths.

(Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)

USE_PKG_CONFIG := 1

N.B. both build and distribute dirs are cleared on make clean

BUILD_DIR := build
DISTRIBUTE_DIR := distribute

Uncomment for debugging. Does not work on OSX due to BVLC#171

DEBUG := 1

The ID of the GPU that 'make runtest' will use to run unit tests.

TEST_GPUID := 0

enable pretty build (comment to see full commands)

Q ?= @``

@KeeganRen
Copy link
Author

KeeganRen commented Jul 29, 2016

我把这几句话注释掉就好了
USE_OPENCV := 0
USE_LEVELDB := 0
USE_LMDB := 0
但是我直接下载下来的caffe是没问题的

@AndrewZhao
Copy link

@KeeganRen if you comment these code, the caffe will not be compiled with opencv and lmdb...the minist test would not passed..

@KeeganRen
Copy link
Author

@AndrewZhao oh no, the minist not passed ...., but if I uncomment these code, it will error on opencv, but it's include & libs are added.

@AndrewZhao
Copy link

@KeeganRen because the type of the minist file is lmdb.do you have followed the weiliu89's suggest?if the caffe still has errors, i think you may try to reinstall the opencv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants