diff --git a/CMakeLists.txt b/CMakeLists.txt index 152037b2..35841340 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,10 @@ find_package(PkgConfig REQUIRED) find_package(OpenCV REQUIRED) +if(NOT (${OpenCV_VERSION} VERSION_LESS 3)) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENCV_LEGACY_MODE") +endif() + include_directories(${OpenCV_INCLUDE_DIRS}) link_directories(${OpenCV_LIBRARY_DIRS}) diff --git a/README.md b/README.md index 787e5016..c2e0fe9b 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ See the new features in our latest release. ## Installation -First grab Aeon's dependencies: +First grab aeon's dependencies: -### Ubuntu (release 16.04 LTS and later): +### Ubuntu (release 16.04 LTS and later) apt-get install git clang libopencv-dev @@ -24,7 +24,7 @@ First grab Aeon's dependencies: apt-get install python3-dev python3-pip python3-numpy -### CentOS (release 7.2 and later): +### CentOS (release 7.2 and later) yum install epel-release yum install git clang gcc-c++ make cmake opencv-devel @@ -37,7 +37,7 @@ First grab Aeon's dependencies: yum install python-pip python34-pip python34-devel python34-opencv python34-numpy -### OSX: +### OSX brew tap homebrew/science brew install opencv @@ -57,9 +57,9 @@ First grab Aeon's dependencies: # If you want to generate report when unit test fails: make -i coverage make coverage -### To install Aeon: +### To install aeon - git clone https://github.com/NervanaSystems/aeon.git + git clone -b develop https://github.com/NervanaSystems/aeon.git ##### For Python 2.7 @@ -73,6 +73,40 @@ First grab Aeon's dependencies: pip3 install -r requirements.txt mkdir -p build && cd $_ && cmake .. && pip3 install . +### To install aeon with the latest OpenCV version + +##### Clone aeon repository + + git clone -b develop https://github.com/NervanaSystems/aeon.git + +##### Build OpenCV + + mkdir -p aeon/build/3rdparty && cd $_ + git clone https://github.com/opencv/opencv.git + cd opencv && mkdir build && cd $_ + + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/installation/OpenCV -DINSTALL_C_EXAMPLES=OFF -DINSTALL_PYTHON_EXAMPLES=OFF -DWITH_TBB=OFF -DWITH_V4L=OFF -DWITH_QT=OFF -DWITH_OPENGL=OFF -DBUILD_EXAMPLES=OFF -DWITH_CUDA=OFF -DOPENCV_FORCE_3RDPARTY_BUILD=OFF -DWITH_IPP=OFF -DWITH_ITT=OFF -DBUILD_ZLIB=OFF -DBUILD_TIFF=OFF -DBUILD_JASPER=OFF -DBUILD_JPEG=OFF -DBUILD_PNG=OFF -DBUILD_OPENEXR=OFF -DBUILD_WEBP=OFF -DBUILD_opencv_gpu=OFF -DOPENCV_GENERATE_PKGCONFIG=ON -DOPENCV_PC_FILE_NAME=opencv.pc .. + + make -j8 # for example it runs 8 jobs in parallel + make install + +##### Install aeon + + cd ../../../ + cmake -DCMAKE_PREFIX_PATH=$(pwd)/3rdparty/opencv/build/installation/OpenCV .. + +##### For Python 2.7 + + pip install -r ../requirements.txt + pip install . + +##### For Python 3.n + + pip3 install -r ../requirements.txt + pip3 install . + +You can also build wheel package with command `python setup.py bdist_wheel` + Note: if installing system wide (as opposed to within a virtual environment) you may need to run `sudo` Now continue on to the [user guide](http://aeon.nervanasys.com/index.html/user_guide.html) to get started using aeon. Or to the diff --git a/src/cap_mjpeg_decoder.hpp b/src/cap_mjpeg_decoder.hpp index d90e9135..a10a7923 100644 --- a/src/cap_mjpeg_decoder.hpp +++ b/src/cap_mjpeg_decoder.hpp @@ -10,8 +10,12 @@ #include #include #include -#include "opencv2/imgproc/imgproc_c.h" +#include #include +#ifdef OPENCV_LEGACY_MODE +#include +#include +#endif #include "util.hpp" #include "avi.hpp" diff --git a/src/etl_image.cpp b/src/etl_image.cpp index 9467ed1a..e1943c01 100644 --- a/src/etl_image.cpp +++ b/src/etl_image.cpp @@ -77,6 +77,10 @@ image::extractor::extractor(const image::config& cfg) { _pixel_type = CV_MAKETYPE(CV_8U, cfg.channels); _color_mode = cfg.channels == 1 ? CV_LOAD_IMAGE_GRAYSCALE : CV_LOAD_IMAGE_COLOR; +#ifdef OPENCV_LEGACY_MODE + // Do not run ApplyExifOrientation as this causes Segmentation faults + _color_mode = _color_mode | CV_LOAD_IMAGE_IGNORE_ORIENTATION; +#endif } } @@ -86,7 +90,11 @@ shared_ptr image::extractor::extract(const void* inbuf, size_t i // It is bad to cast away const, but opencv does not support a const Mat // The Mat is only used for imdecode on the next line so it is OK here +#ifdef OPENCV_LEGACY_MODE + cv::Mat input_img(insize * CV_MAT_CN(_pixel_type), 1, CV_8UC1, (char*)inbuf); +#else cv::Mat input_img(1, insize, _pixel_type, (char*)inbuf); +#endif cv::imdecode(input_img, _color_mode, &output_img); if (output_img.empty()) { diff --git a/src/etl_image.hpp b/src/etl_image.hpp index b3dd3897..2c5aefca 100644 --- a/src/etl_image.hpp +++ b/src/etl_image.hpp @@ -19,6 +19,10 @@ #include #include #include +#ifdef OPENCV_LEGACY_MODE +#include +#include +#endif #include #include "interface.hpp" #include "image.hpp" diff --git a/src/image.hpp b/src/image.hpp index e070302a..6c53c4bd 100644 --- a/src/image.hpp +++ b/src/image.hpp @@ -21,6 +21,9 @@ #include #include +#ifdef OPENCV_LEGACY_MODE +#include +#endif namespace nervana { diff --git a/src/setup.py.in b/src/setup.py.in index 0f2f0256..3ae969b3 100644 --- a/src/setup.py.in +++ b/src/setup.py.in @@ -26,19 +26,21 @@ def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=N import distutils.ccompiler distutils.ccompiler.CCompiler.compile=parallelCCompile -lib_dirs = "" -lib_dirs += " -L${CMAKE_PREFIX_PATH}/lib " -libs = "" -include_dirs = "" -include_dirs += " -I${CMAKE_PREFIX_PATH}/include " +lib_dirs = "${CMAKE_PREFIX_PATH}/lib" +include_dirs = "${OpenCV_INCLUDE_DIRS}".replace(';', ' ') -status, tmp = getstatusoutput("pkg-config --cflags opencv") +if "${CMAKE_PREFIX_PATH}": + export_cv_pkg_config_path = "export PKG_CONFIG_PATH=${CMAKE_PREFIX_PATH}/lib/pkgconfig;" +else: + export_cv_pkg_config_path = "" + +status, tmp = getstatusoutput(export_cv_pkg_config_path + "pkg-config --cflags opencv") if status != 0: print("required package 'opencv' not found") exit() -include_dirs += tmp -lib_dirs += getoutput("pkg-config --libs-only-L opencv") -libs += getoutput("pkg-config --libs-only-l opencv") +include_dirs += " " + tmp +lib_dirs += " " + getoutput(export_cv_pkg_config_path + "pkg-config --libs-only-L opencv") +libs = getoutput(export_cv_pkg_config_path + "pkg-config --libs-only-l opencv") libs += ' -lstdc++fs'