installation error: ‘CV_LOAD_IMAGE_COLOR’ was not declared

12,745 views
Skip to first unread message

bbkslh

unread,
Dec 12, 2014, 9:04:58 PM12/12/14
to caffe...@googlegroups.com
Hi , I tried to install Caffe on Ubuntu 12.04. However I am getting the following error: 

src/caffe/layers/window_data_layer.cpp: In member function ‘virtual void caffe::WindowDataLayer<Dtype>::InternalThreadEntry()’:
src/caffe/layers/window_data_layer.cpp:230:48: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope

Have you ever experienced this problem?

Mohamed Zahoor

unread,
Dec 14, 2014, 2:53:09 PM12/14/14
to caffe...@googlegroups.com
Your Opencv installation has some problems...
Which version did you install?

./zahoor

bbkslh

unread,
Dec 14, 2014, 6:11:17 PM12/14/14
to caffe...@googlegroups.com
I have two versions of opencv installed:  2.3 and 3 

Friendly User

unread,
Dec 15, 2014, 3:54:46 AM12/15/14
to caffe...@googlegroups.com
opencv 3 is still beta and opencv 2.3 is a bit too old, use 2.4.9 ;)

Greg Hines

unread,
Feb 18, 2015, 11:57:22 AM2/18/15
to caffe...@googlegroups.com
I manually changed the one line to cv::IMREAD_COLOR and am now getting the errors:
g++ .build_release/tools/extract_features.o .build_release/lib/libcaffe.a -o .build_release/tools/extract_features.bin -fPIC -DNDEBUG -O2 -DCPU_ONLY -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include -I.build_release/src -I./src -I./include -Wall -Wno-sign-compare -L/usr/lib -L/usr/local/lib -L/usr/lib -lglog -lgflags -lprotobuf -lleveldb -lsnappy -llmdb -lboost_system -lhdf5_hl -lhdf5 -lopencv_core -lopencv_highgui -lopencv_imgproc -lpthread -lboost_thread -lcblas -latlas
.build_release/lib/libcaffe.a(window_data_layer.o): In function `caffe::WindowDataLayer<float>::InternalThreadEntry()':
window_data_layer.cpp:(.text._ZN5caffe15WindowDataLayerIfE19InternalThreadEntryEv[_ZN5caffe15WindowDataLayerIfE19InternalThreadEntryEv]+0x35f): undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.a(window_data_layer.o): In function `caffe::WindowDataLayer<double>::InternalThreadEntry()':
window_data_layer.cpp:(.text._ZN5caffe15WindowDataLayerIdE19InternalThreadEntryEv[_ZN5caffe15WindowDataLayerIdE19InternalThreadEntryEv]+0x36b): undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.a(io.o): In function `caffe::ReadImageToDatum(std::string const&, int, int, int, bool, caffe::Datum*)':

Any suggestions? Having trouble building opencv 2.4.10 or I would just use that.

Sancho McCann

unread,
Feb 18, 2015, 12:08:14 PM2/18/15
to caffe...@googlegroups.com
The cv::imread function was moved to the libopencv_imgcodecs library. You have to also add opencv_imgcodecs to the list of libraries in the Makefile.

See: https://github.com/BVLC/caffe/pull/1714 and https://github.com/BVLC/caffe/pull/1667 ... looks like they're working to make this all easier for us OpenCV 3 users.

Greg Hines

unread,
Feb 18, 2015, 12:20:03 PM2/18/15
to caffe...@googlegroups.com
Thanks, that worked. FYI for anyone else. On line 172 of the Makefile, I added opencv_imgcodecs to the list (that line starts opencv_core).

Anatoly Baksheev

unread,
Feb 18, 2015, 1:51:02 PM2/18/15
to Greg Hines, caffe...@googlegroups.com
Right, `opencv_imgcodecs` should be added to Makefile for 3.x!  Both #1714 and #1667 fix this by adding proper includes in sources and libraries to link in CMake only.



-- Anatoly

On Wed, Feb 18, 2015 at 8:20 PM, Greg Hines <gr...@zooniverse.org> wrote:
Thanks, that worked. FYI for anyone else. On line 172 of the Makefile, I added opencv_imgcodecs to the list (that line starts opencv_core).

--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/f360715e-2c89-452b-b53a-e26de55e5e9a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Sancho McCann

unread,
Dec 18, 2014, 6:16:19 PM12/18/14
to caffe...@googlegroups.com
That means you're likely compiling against opencv 3.0. The symbol "CV_LOAD_IMAGE_COLOR" has been replaced with "cv::IMREAD_COLOR". Just edit the window_data_layer.cpp file and you should be good. It's the only deprecated symbol used in Caffe.

karina.c...@gmail.com

unread,
Feb 6, 2019, 2:52:26 PM2/6/19
to Caffe Users
"CV_LOAD_IMAGE_COLOR"  change it to "cv::IMREAD_COLOR"

Basheer Alwaely

unread,
Sep 3, 2020, 6:35:07 AM9/3/20
to Caffe Users
I got the same issue

Tamas Nemes

unread,
Sep 3, 2020, 8:40:04 AM9/3/20
to Caffe Users
It should be helpful if you write which OpenCV version you are using. As mentioned in the posts before, with OpenCV 3 and above the macros CV_LOAD_IMAGE_COLOR and CV_LOAD_IMAGE_GRAYSCALE were changed to "cv::IMREAD_COLOR" and "cv::IMREAD_GRAYSCALE" along with many others. I got the same issue when compiling, just go to the source files that give the error message (found in [CAFFE_ROOT]/src/caffe) and change them manually. You can search the internet for the equivalent definitions in the 3 and 4 version.
Or you could go easier and use this guide: https://qengineering.eu/install-caffe-on-ubuntu-20.04-with-opencv-4.4.html Here, it is explained step-by-step what you have to do and even provide a modified Caffe repo which was adapted to OpenCV 4, so you just have to follow the instructions. Works also with version 3.

Good luck to everyone!

Reply all
Reply to author
Forward
0 new messages