From d6fd6a3e5c24897ce55ddf183037dbb754704a48 Mon Sep 17 00:00:00 2001 From: wkcn Date: Mon, 4 Mar 2019 10:27:45 +0800 Subject: [PATCH 01/12] compatibility with opencv4 --- Makefile | 11 ++++-- src/io/image_aug_default.cc | 1 + src/io/image_det_aug_default.cc | 1 + src/io/image_io.cc | 1 + src/io/opencv_compatibility.h | 59 +++++++++++++++++++++++++++++++++ tools/im2rec.cc | 1 + 6 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/io/opencv_compatibility.h diff --git a/Makefile b/Makefile index cd6610581893..fe0d10b486e3 100644 --- a/Makefile +++ b/Makefile @@ -146,8 +146,15 @@ endif # setup opencv ifeq ($(USE_OPENCV), 1) - CFLAGS += -DMXNET_USE_OPENCV=1 $(shell pkg-config --cflags opencv) - LDFLAGS += $(filter-out -lopencv_ts, $(shell pkg-config --libs opencv)) + + ifeq ("$(shell pkg-config --exists opencv4; echo $$?)", "0") + CFLAGS += -DMXNET_USE_OPENCV=1 $(shell pkg-config --cflags opencv4) + LDFLAGS += $(filter-out -lopencv_ts, $(shell pkg-config --libs opencv4)) + else + CFLAGS += -DMXNET_USE_OPENCV=1 $(shell pkg-config --cflags opencv) + LDFLAGS += $(filter-out -lopencv_ts, $(shell pkg-config --libs opencv)) + endif + BIN += bin/im2rec else CFLAGS+= -DMXNET_USE_OPENCV=0 diff --git a/src/io/image_aug_default.cc b/src/io/image_aug_default.cc index 5fb0b0f21e7e..01c0a7ab8c60 100644 --- a/src/io/image_aug_default.cc +++ b/src/io/image_aug_default.cc @@ -32,6 +32,7 @@ #include "../common/utils.h" #if MXNET_USE_OPENCV +#include "./opencv_compatibility.h" // Registers namespace dmlc { DMLC_REGISTRY_ENABLE(::mxnet::io::ImageAugmenterReg); diff --git a/src/io/image_det_aug_default.cc b/src/io/image_det_aug_default.cc index 91711bfb0359..74e51b51603b 100644 --- a/src/io/image_det_aug_default.cc +++ b/src/io/image_det_aug_default.cc @@ -203,6 +203,7 @@ std::vector ListDefaultDetAugParams() { } #if MXNET_USE_OPENCV +#include "./opencv_compatibility.h" using Rect = cv::Rect_; #ifdef _MSC_VER diff --git a/src/io/image_io.cc b/src/io/image_io.cc index ab55c1a4c901..2196983928bb 100644 --- a/src/io/image_io.cc +++ b/src/io/image_io.cc @@ -41,6 +41,7 @@ #if MXNET_USE_OPENCV #include + #include "./opencv_compatibility.h" #endif // MXNET_USE_OPENCV namespace mxnet { diff --git a/src/io/opencv_compatibility.h b/src/io/opencv_compatibility.h new file mode 100644 index 000000000000..7f42328497ed --- /dev/null +++ b/src/io/opencv_compatibility.h @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/*! + * Copyright (c) 2019 by Contributors + * \file opencv_compatibility.h + * \brief To be compatible with multiple versions of opencv + */ +#ifndef MXNET_IO_OPENCV_COMPATIBILITY_H_ +#define MXNET_IO_OPENCV_COMPATIBILITY_H_ + +#if MXNET_USE_OPENCV +#include + +#if CV_VERSION_MAJOR >= 4 +#include +#define CV_RGB2GRAY cv::COLOR_RGB2GRAY +#define CV_BGR2GRAY cv::COLOR_BGR2GRAY + +#define CV_GRAY2RGB cv::COLOR_GRAY2RGB +#define CV_GRAY2BGR cv::COLOR_GRAY2BGR + +#define CV_RGB2HLS cv::COLOR_RGB2HLS +#define CV_BGR2HLS cv::COLOR_BGR2HLS + +#define CV_HLS2RGB cv::COLOR_HLS2RGB +#define CV_HLS2BGR cv::COLOR_HLS2BGR + +#define CV_RGB2BGR cv::COLOR_RGB2BGR +#define CV_BGR2RGB cv::COLOR_BGR2RGB + +#define CV_INTER_LINEAR cv::INTER_LINEAR +#define CV_INTER_NEAREST cv::INTER_NEAREST + +#define CV_LOAD_IMAGE_COLOR cv::IMREAD_COLOR +#define CV_IMWRITE_PNG_COMPRESSION cv::IMWRITE_PNG_COMPRESSION +#define CV_IMWRITE_JPEG_QUALITY cv::IMWRITE_JPEG_QUALITY + +#endif // CV_VERSION_MAJOR >= 4 + +#endif // MXNET_USE_OPENCV + +#endif // MXNET_IO_OPENCV_COMPATIBILITY_H_ diff --git a/tools/im2rec.cc b/tools/im2rec.cc index 915b78029c87..989b3147830d 100644 --- a/tools/im2rec.cc +++ b/tools/im2rec.cc @@ -39,6 +39,7 @@ #include #include #include +#include "../src/io/opencv_compatibility.h" #include "../src/io/image_recordio.h" #include /*! From be69a194e99b127152cab95068af2f93ac6f7e9c Mon Sep 17 00:00:00 2001 From: wkcn Date: Mon, 4 Mar 2019 10:46:25 +0800 Subject: [PATCH 02/12] update makefile --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index fe0d10b486e3..4b54b409e0e1 100644 --- a/Makefile +++ b/Makefile @@ -146,18 +146,18 @@ endif # setup opencv ifeq ($(USE_OPENCV), 1) - ifeq ("$(shell pkg-config --exists opencv4; echo $$?)", "0") - CFLAGS += -DMXNET_USE_OPENCV=1 $(shell pkg-config --cflags opencv4) - LDFLAGS += $(filter-out -lopencv_ts, $(shell pkg-config --libs opencv4)) + OPENCV_LIB = opencv4 else - CFLAGS += -DMXNET_USE_OPENCV=1 $(shell pkg-config --cflags opencv) - LDFLAGS += $(filter-out -lopencv_ts, $(shell pkg-config --libs opencv)) + OPENCV_LIB = opencv endif + CFLAGS += -DMXNET_USE_OPENCV=1 $(shell pkg-config --cflags $(OPENCV_LIB)) + LDFLAGS += $(filter-out -lopencv_ts, $(shell pkg-config --libs $(OPENCV_LIB))) + BIN += bin/im2rec else - CFLAGS+= -DMXNET_USE_OPENCV=0 + CFLAGS += -DMXNET_USE_OPENCV=0 endif ifeq ($(USE_OPENMP), 1) From c32045fc440ab237e639416a0f4722d9ad3d518e Mon Sep 17 00:00:00 2001 From: wkcn Date: Mon, 4 Mar 2019 12:45:23 +0800 Subject: [PATCH 03/12] update Makefile --- Makefile | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 4b54b409e0e1..8b2835ede449 100644 --- a/Makefile +++ b/Makefile @@ -146,15 +146,18 @@ endif # setup opencv ifeq ($(USE_OPENCV), 1) - ifeq ("$(shell pkg-config --exists opencv4; echo $$?)", "0") - OPENCV_LIB = opencv4 + CFLAGS += -DMXNET_USE_OPENCV=1 + LDFLAGS += -lopencv_core -lopencv_imgcodecs -lopencv_imgproc + ifneq ($(USE_OPENCV_PATH), NONE) + CFLAGS += -I$(USE_OPENCV_PATH) else - OPENCV_LIB = opencv + ifeq ("$(shell pkg-config --exists opencv4; echo $$?)", "0") + OPENCV_LIB = opencv4 + else + OPENCV_LIB = opencv + endif + CFLAGS += $(shell pkg-config --cflags $(OPENCV_LIB)) endif - - CFLAGS += -DMXNET_USE_OPENCV=1 $(shell pkg-config --cflags $(OPENCV_LIB)) - LDFLAGS += $(filter-out -lopencv_ts, $(shell pkg-config --libs $(OPENCV_LIB))) - BIN += bin/im2rec else CFLAGS += -DMXNET_USE_OPENCV=0 From e253032e5578c2eba365acb8cff578bf1b5bc705 Mon Sep 17 00:00:00 2001 From: wkcn Date: Mon, 4 Mar 2019 21:43:14 +0800 Subject: [PATCH 04/12] fix Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8b2835ede449..b71b0bc6fd44 100644 --- a/Makefile +++ b/Makefile @@ -148,7 +148,7 @@ endif ifeq ($(USE_OPENCV), 1) CFLAGS += -DMXNET_USE_OPENCV=1 LDFLAGS += -lopencv_core -lopencv_imgcodecs -lopencv_imgproc - ifneq ($(USE_OPENCV_PATH), NONE) + ifneq ($(USE_OPENCV_PATH), ) CFLAGS += -I$(USE_OPENCV_PATH) else ifeq ("$(shell pkg-config --exists opencv4; echo $$?)", "0") From e7625d89618a62dcc0638b0690eda0cf626add39 Mon Sep 17 00:00:00 2001 From: wkcn Date: Mon, 4 Mar 2019 22:54:20 +0800 Subject: [PATCH 05/12] fix lib path --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b71b0bc6fd44..32af914f7905 100644 --- a/Makefile +++ b/Makefile @@ -147,9 +147,11 @@ endif # setup opencv ifeq ($(USE_OPENCV), 1) CFLAGS += -DMXNET_USE_OPENCV=1 - LDFLAGS += -lopencv_core -lopencv_imgcodecs -lopencv_imgproc ifneq ($(USE_OPENCV_PATH), ) CFLAGS += -I$(USE_OPENCV_PATH) + ifneq ($(USE_OPENCV_LIB_PATH), ) + LDFLAGS += -L$(USE_OPENCV_LIB_PATH) + endif else ifeq ("$(shell pkg-config --exists opencv4; echo $$?)", "0") OPENCV_LIB = opencv4 @@ -157,7 +159,10 @@ ifeq ($(USE_OPENCV), 1) OPENCV_LIB = opencv endif CFLAGS += $(shell pkg-config --cflags $(OPENCV_LIB)) + LDFLAGS += $(shell pkg-config --libs-only-L $(OPENCV_LIB)) endif + LDFLAGS += -lopencv_core -lopencv_imgcodecs -lopencv_imgproc + BIN += bin/im2rec else CFLAGS += -DMXNET_USE_OPENCV=0 From 16760f0931e65d6ea4c02788c8a6a627671bd798 Mon Sep 17 00:00:00 2001 From: wkcn Date: Tue, 5 Mar 2019 10:50:54 +0800 Subject: [PATCH 06/12] update make.mk --- Makefile | 18 ++++++++++++------ make/config.mk | 8 ++++++-- make/crosscompile.jetson.mk | 4 ++++ make/maven/maven_darwin_mkl.mk | 4 ++++ make/maven/maven_linux_cu90mkl.mk | 4 ++++ make/maven/maven_linux_cu92mkl.mk | 4 ++++ make/maven/maven_linux_mkl.mk | 4 ++++ make/osx.mk | 4 ++++ make/pip/pip_darwin_cpu.mk | 4 ++++ make/pip/pip_darwin_mkl.mk | 4 ++++ make/pip/pip_linux_cpu.mk | 4 ++++ make/pip/pip_linux_cu100.mk | 4 ++++ make/pip/pip_linux_cu100mkl.mk | 4 ++++ make/pip/pip_linux_cu75.mk | 4 ++++ make/pip/pip_linux_cu75mkl.mk | 4 ++++ make/pip/pip_linux_cu80.mk | 4 ++++ make/pip/pip_linux_cu80mkl.mk | 4 ++++ make/pip/pip_linux_cu90.mk | 4 ++++ make/pip/pip_linux_cu90mkl.mk | 4 ++++ make/pip/pip_linux_cu91.mk | 4 ++++ make/pip/pip_linux_cu91mkl.mk | 4 ++++ make/pip/pip_linux_cu92.mk | 4 ++++ make/pip/pip_linux_cu92mkl.mk | 4 ++++ make/pip/pip_linux_mkl.mk | 4 ++++ make/readthedocs.mk | 4 ++++ 25 files changed, 110 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 32af914f7905..ccb92b7b962b 100644 --- a/Makefile +++ b/Makefile @@ -147,10 +147,16 @@ endif # setup opencv ifeq ($(USE_OPENCV), 1) CFLAGS += -DMXNET_USE_OPENCV=1 - ifneq ($(USE_OPENCV_PATH), ) - CFLAGS += -I$(USE_OPENCV_PATH) - ifneq ($(USE_OPENCV_LIB_PATH), ) - LDFLAGS += -L$(USE_OPENCV_LIB_PATH) + ifneq ($(USE_OPENCV_DEP_PATH), NONE) + CFLAGS += -I$(USE_OPENCV_DEP_PATH)/include + ifeq ($(USE_OPENCV_LIB_PATH), NONE) + USE_OPENCV_LIB_PATH = $(USE_OPENCV_DEP_PATH)/lib + endif + LDFLAGS += -L$(USE_OPENCV_LIB_PATH) + LDFLAGS += -lopencv_core -lopencv_imgproc + # Add flag -lopencv_imgcodecs for OpenCV 3+ + ifneq ($(wildcard $(USE_OPENCV_LIB_PATH)/libopencv_imgcodecs.*), ) + LDFLAGS += -lopencv_imgcodecs endif else ifeq ("$(shell pkg-config --exists opencv4; echo $$?)", "0") @@ -160,9 +166,9 @@ ifeq ($(USE_OPENCV), 1) endif CFLAGS += $(shell pkg-config --cflags $(OPENCV_LIB)) LDFLAGS += $(shell pkg-config --libs-only-L $(OPENCV_LIB)) + LDFLAGS += -lopencv_core -lopencv_imgproc + LDFLAGS += $(filter -lopencv_imgcodecs, $(shell pkg-config --libs-only-l $(OPENCV_LIB))) endif - LDFLAGS += -lopencv_core -lopencv_imgcodecs -lopencv_imgproc - BIN += bin/im2rec else CFLAGS += -DMXNET_USE_OPENCV=0 diff --git a/make/config.mk b/make/config.mk index 8a1aa2c165c4..469e706ac0be 100644 --- a/make/config.mk +++ b/make/config.mk @@ -89,10 +89,14 @@ USE_NCCL_PATH = NONE # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE -#whether use libjpeg-turbo for image decode without OpenCV wrapper +# whether use libjpeg-turbo for image decode without OpenCV wrapper USE_LIBJPEG_TURBO = 0 -#add the path to libjpeg-turbo library +# add the path to libjpeg-turbo library USE_LIBJPEG_TURBO_PATH = NONE # use openmp for parallelization diff --git a/make/crosscompile.jetson.mk b/make/crosscompile.jetson.mk index 171f846d20dd..e9c7e3b62af4 100644 --- a/make/crosscompile.jetson.mk +++ b/make/crosscompile.jetson.mk @@ -89,6 +89,10 @@ USE_NCCL_PATH = NONE # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 0 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE #whether use libjpeg-turbo for image decode without OpenCV wrapper USE_LIBJPEG_TURBO = 0 diff --git a/make/maven/maven_darwin_mkl.mk b/make/maven/maven_darwin_mkl.mk index f5b77ae784ad..5ad7b8f24fb4 100644 --- a/make/maven/maven_darwin_mkl.mk +++ b/make/maven/maven_darwin_mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=apple # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 0 diff --git a/make/maven/maven_linux_cu90mkl.mk b/make/maven/maven_linux_cu90mkl.mk index 661f444ceac3..e52ae68ab712 100644 --- a/make/maven/maven_linux_cu90mkl.mk +++ b/make/maven/maven_linux_cu90mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/maven/maven_linux_cu92mkl.mk b/make/maven/maven_linux_cu92mkl.mk index ecd252769216..b9b97008940f 100644 --- a/make/maven/maven_linux_cu92mkl.mk +++ b/make/maven/maven_linux_cu92mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/maven/maven_linux_mkl.mk b/make/maven/maven_linux_mkl.mk index 6cb9f326bb7d..8101005923d8 100644 --- a/make/maven/maven_linux_mkl.mk +++ b/make/maven/maven_linux_mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 0 diff --git a/make/osx.mk b/make/osx.mk index 3e2e592323f4..a9bb1940b8aa 100644 --- a/make/osx.mk +++ b/make/osx.mk @@ -75,6 +75,10 @@ USE_CUDNN = 0 # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # use openmp for parallelization # apple-clang by default does not have openmp built-in diff --git a/make/pip/pip_darwin_cpu.mk b/make/pip/pip_darwin_cpu.mk index 87a967933f9e..e9407e739d52 100644 --- a/make/pip/pip_darwin_cpu.mk +++ b/make/pip/pip_darwin_cpu.mk @@ -58,6 +58,10 @@ USE_BLAS=apple # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 0 diff --git a/make/pip/pip_darwin_mkl.mk b/make/pip/pip_darwin_mkl.mk index 339c95fdd502..65537b78c877 100644 --- a/make/pip/pip_darwin_mkl.mk +++ b/make/pip/pip_darwin_mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=apple # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 0 diff --git a/make/pip/pip_linux_cpu.mk b/make/pip/pip_linux_cpu.mk index d680f6da38d2..2198160f3c3a 100644 --- a/make/pip/pip_linux_cpu.mk +++ b/make/pip/pip_linux_cpu.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 0 diff --git a/make/pip/pip_linux_cu100.mk b/make/pip/pip_linux_cu100.mk index 0f3f84a417a8..dc4b744dcf0d 100644 --- a/make/pip/pip_linux_cu100.mk +++ b/make/pip/pip_linux_cu100.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_cu100mkl.mk b/make/pip/pip_linux_cu100mkl.mk index b4792e3d81bb..dd9d06093376 100644 --- a/make/pip/pip_linux_cu100mkl.mk +++ b/make/pip/pip_linux_cu100mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_cu75.mk b/make/pip/pip_linux_cu75.mk index ff05ec80c68d..37ced7a9b9de 100644 --- a/make/pip/pip_linux_cu75.mk +++ b/make/pip/pip_linux_cu75.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_cu75mkl.mk b/make/pip/pip_linux_cu75mkl.mk index a8259205a5d7..222bce36223c 100644 --- a/make/pip/pip_linux_cu75mkl.mk +++ b/make/pip/pip_linux_cu75mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_cu80.mk b/make/pip/pip_linux_cu80.mk index 7abf09f02eb6..90137000accc 100644 --- a/make/pip/pip_linux_cu80.mk +++ b/make/pip/pip_linux_cu80.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_cu80mkl.mk b/make/pip/pip_linux_cu80mkl.mk index be42cca0ef2b..1e1a87fe2b09 100644 --- a/make/pip/pip_linux_cu80mkl.mk +++ b/make/pip/pip_linux_cu80mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_cu90.mk b/make/pip/pip_linux_cu90.mk index 12bc7741bef4..24425d54e069 100644 --- a/make/pip/pip_linux_cu90.mk +++ b/make/pip/pip_linux_cu90.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_cu90mkl.mk b/make/pip/pip_linux_cu90mkl.mk index 770f292598c3..cdcb97b6e2c9 100644 --- a/make/pip/pip_linux_cu90mkl.mk +++ b/make/pip/pip_linux_cu90mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_cu91.mk b/make/pip/pip_linux_cu91.mk index 9e399f97d18f..f99fd9504a2c 100644 --- a/make/pip/pip_linux_cu91.mk +++ b/make/pip/pip_linux_cu91.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_cu91mkl.mk b/make/pip/pip_linux_cu91mkl.mk index 80ef690a00e5..89fb6aa1279d 100644 --- a/make/pip/pip_linux_cu91mkl.mk +++ b/make/pip/pip_linux_cu91mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_cu92.mk b/make/pip/pip_linux_cu92.mk index b0731addbc2d..14638d5829b9 100644 --- a/make/pip/pip_linux_cu92.mk +++ b/make/pip/pip_linux_cu92.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_cu92mkl.mk b/make/pip/pip_linux_cu92mkl.mk index 768fcc9c1cd0..478ee34ab82f 100644 --- a/make/pip/pip_linux_cu92mkl.mk +++ b/make/pip/pip_linux_cu92mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 1 diff --git a/make/pip/pip_linux_mkl.mk b/make/pip/pip_linux_mkl.mk index ea11061e1e82..91f106b9d701 100644 --- a/make/pip/pip_linux_mkl.mk +++ b/make/pip/pip_linux_mkl.mk @@ -58,6 +58,10 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile USE_CUDA = 0 diff --git a/make/readthedocs.mk b/make/readthedocs.mk index 0a45e6f03151..b17e7bd5122f 100644 --- a/make/readthedocs.mk +++ b/make/readthedocs.mk @@ -36,6 +36,10 @@ USE_CUDA_PATH = NONE # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 0 +# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ +USE_OPENCV_DEP_PATH = NONE +# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +USE_OPENCV_LIB_PATH = NONE # whether use CUDNN R3 library USE_CUDNN = 0 From 4c95001cf58fc96fea390b2f53819358f92b4456 Mon Sep 17 00:00:00 2001 From: wkcn Date: Tue, 5 Mar 2019 11:54:46 +0800 Subject: [PATCH 07/12] add -lopencv_highgui --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ccb92b7b962b..0b67939256cf 100644 --- a/Makefile +++ b/Makefile @@ -153,7 +153,6 @@ ifeq ($(USE_OPENCV), 1) USE_OPENCV_LIB_PATH = $(USE_OPENCV_DEP_PATH)/lib endif LDFLAGS += -L$(USE_OPENCV_LIB_PATH) - LDFLAGS += -lopencv_core -lopencv_imgproc # Add flag -lopencv_imgcodecs for OpenCV 3+ ifneq ($(wildcard $(USE_OPENCV_LIB_PATH)/libopencv_imgcodecs.*), ) LDFLAGS += -lopencv_imgcodecs @@ -166,9 +165,9 @@ ifeq ($(USE_OPENCV), 1) endif CFLAGS += $(shell pkg-config --cflags $(OPENCV_LIB)) LDFLAGS += $(shell pkg-config --libs-only-L $(OPENCV_LIB)) - LDFLAGS += -lopencv_core -lopencv_imgproc LDFLAGS += $(filter -lopencv_imgcodecs, $(shell pkg-config --libs-only-l $(OPENCV_LIB))) endif + LDFLAGS += -lopencv_core -lopencv_imgproc -lopencv_highgui BIN += bin/im2rec else CFLAGS += -DMXNET_USE_OPENCV=0 From f0bbe75cbdd7e450886dc564ed3f9a6fbaed708f Mon Sep 17 00:00:00 2001 From: JackieWu Date: Tue, 5 Mar 2019 17:59:29 +0800 Subject: [PATCH 08/12] retrigger CI --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0b67939256cf..358a8c4bccb4 100644 --- a/Makefile +++ b/Makefile @@ -129,7 +129,7 @@ ifdef CAFFE_PATH endif ifndef LINT_LANG - LINT_LANG="all" + LINT_LANG = "all" endif ifeq ($(USE_MKLDNN), 1) From 472f3e6bcabd050950a90aec10374ea6712abb79 Mon Sep 17 00:00:00 2001 From: wkcn Date: Tue, 5 Mar 2019 22:04:50 +0800 Subject: [PATCH 09/12] update makefile --- Makefile | 16 +++++++++------- make/config.mk | 10 +++++----- make/crosscompile.jetson.mk | 6 +++--- make/maven/maven_darwin_mkl.mk | 6 +++--- make/maven/maven_linux_cu90mkl.mk | 6 +++--- make/maven/maven_linux_cu92mkl.mk | 6 +++--- make/maven/maven_linux_mkl.mk | 6 +++--- make/osx.mk | 6 +++--- make/pip/pip_darwin_cpu.mk | 6 +++--- make/pip/pip_darwin_mkl.mk | 6 +++--- make/pip/pip_linux_cpu.mk | 6 +++--- make/pip/pip_linux_cu100.mk | 6 +++--- make/pip/pip_linux_cu100mkl.mk | 6 +++--- make/pip/pip_linux_cu75.mk | 6 +++--- make/pip/pip_linux_cu75mkl.mk | 6 +++--- make/pip/pip_linux_cu80.mk | 6 +++--- make/pip/pip_linux_cu80mkl.mk | 6 +++--- make/pip/pip_linux_cu90.mk | 6 +++--- make/pip/pip_linux_cu90mkl.mk | 6 +++--- make/pip/pip_linux_cu91.mk | 6 +++--- make/pip/pip_linux_cu91mkl.mk | 6 +++--- make/pip/pip_linux_cu92.mk | 6 +++--- make/pip/pip_linux_cu92mkl.mk | 6 +++--- make/pip/pip_linux_mkl.mk | 6 +++--- make/readthedocs.mk | 6 +++--- 25 files changed, 83 insertions(+), 81 deletions(-) diff --git a/Makefile b/Makefile index 358a8c4bccb4..443162046583 100644 --- a/Makefile +++ b/Makefile @@ -147,16 +147,18 @@ endif # setup opencv ifeq ($(USE_OPENCV), 1) CFLAGS += -DMXNET_USE_OPENCV=1 - ifneq ($(USE_OPENCV_DEP_PATH), NONE) - CFLAGS += -I$(USE_OPENCV_DEP_PATH)/include + ifneq ($(USE_OPENCV_INC_PATH), NONE) + CFLAGS += -I$(USE_OPENCV_INC_PATH)/include ifeq ($(USE_OPENCV_LIB_PATH), NONE) - USE_OPENCV_LIB_PATH = $(USE_OPENCV_DEP_PATH)/lib +$(error Please add the path of OpenCV shared library path into `USE_OPENCV_LIB_PATH`, when `USE_OPENCV_INC_PATH` is not NONE) endif LDFLAGS += -L$(USE_OPENCV_LIB_PATH) - # Add flag -lopencv_imgcodecs for OpenCV 3+ - ifneq ($(wildcard $(USE_OPENCV_LIB_PATH)/libopencv_imgcodecs.*), ) + ifneq ($(wildcard $(USE_OPENCV_LIB_PATH)/libopencv_imgcodecs.*),) LDFLAGS += -lopencv_imgcodecs endif + ifneq ($(wildcard $(USE_OPENCV_LIB_PATH)/libopencv_highgui.*),) + LDFLAGS += -lopencv_highgui + endif else ifeq ("$(shell pkg-config --exists opencv4; echo $$?)", "0") OPENCV_LIB = opencv4 @@ -165,9 +167,9 @@ ifeq ($(USE_OPENCV), 1) endif CFLAGS += $(shell pkg-config --cflags $(OPENCV_LIB)) LDFLAGS += $(shell pkg-config --libs-only-L $(OPENCV_LIB)) - LDFLAGS += $(filter -lopencv_imgcodecs, $(shell pkg-config --libs-only-l $(OPENCV_LIB))) + LDFLAGS += $(filter -lopencv_imgcodecs -lopencv_highgui, $(shell pkg-config --libs-only-l $(OPENCV_LIB))) endif - LDFLAGS += -lopencv_core -lopencv_imgproc -lopencv_highgui + LDFLAGS += -lopencv_core -lopencv_imgproc BIN += bin/im2rec else CFLAGS += -DMXNET_USE_OPENCV=0 diff --git a/make/config.mk b/make/config.mk index 469e706ac0be..f9ac4cf10048 100644 --- a/make/config.mk +++ b/make/config.mk @@ -89,14 +89,14 @@ USE_NCCL_PATH = NONE # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE -# whether use libjpeg-turbo for image decode without OpenCV wrapper +#whether use libjpeg-turbo for image decode without OpenCV wrapper USE_LIBJPEG_TURBO = 0 -# add the path to libjpeg-turbo library +#add the path to libjpeg-turbo library USE_LIBJPEG_TURBO_PATH = NONE # use openmp for parallelization diff --git a/make/crosscompile.jetson.mk b/make/crosscompile.jetson.mk index e9c7e3b62af4..3db2b98847f3 100644 --- a/make/crosscompile.jetson.mk +++ b/make/crosscompile.jetson.mk @@ -89,9 +89,9 @@ USE_NCCL_PATH = NONE # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 0 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE #whether use libjpeg-turbo for image decode without OpenCV wrapper diff --git a/make/maven/maven_darwin_mkl.mk b/make/maven/maven_darwin_mkl.mk index 5ad7b8f24fb4..f68f1565f990 100644 --- a/make/maven/maven_darwin_mkl.mk +++ b/make/maven/maven_darwin_mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=apple # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/maven/maven_linux_cu90mkl.mk b/make/maven/maven_linux_cu90mkl.mk index e52ae68ab712..3d3b2c48c58b 100644 --- a/make/maven/maven_linux_cu90mkl.mk +++ b/make/maven/maven_linux_cu90mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/maven/maven_linux_cu92mkl.mk b/make/maven/maven_linux_cu92mkl.mk index b9b97008940f..ab93801b0b56 100644 --- a/make/maven/maven_linux_cu92mkl.mk +++ b/make/maven/maven_linux_cu92mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/maven/maven_linux_mkl.mk b/make/maven/maven_linux_mkl.mk index 8101005923d8..dfe5065b9a9c 100644 --- a/make/maven/maven_linux_mkl.mk +++ b/make/maven/maven_linux_mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/osx.mk b/make/osx.mk index a9bb1940b8aa..7e32d81a5d71 100644 --- a/make/osx.mk +++ b/make/osx.mk @@ -75,9 +75,9 @@ USE_CUDNN = 0 # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # use openmp for parallelization diff --git a/make/pip/pip_darwin_cpu.mk b/make/pip/pip_darwin_cpu.mk index e9407e739d52..2c80c42387ad 100644 --- a/make/pip/pip_darwin_cpu.mk +++ b/make/pip/pip_darwin_cpu.mk @@ -58,9 +58,9 @@ USE_BLAS=apple # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_darwin_mkl.mk b/make/pip/pip_darwin_mkl.mk index 65537b78c877..2fac512140d0 100644 --- a/make/pip/pip_darwin_mkl.mk +++ b/make/pip/pip_darwin_mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=apple # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cpu.mk b/make/pip/pip_linux_cpu.mk index 2198160f3c3a..9ed88bb5bd1b 100644 --- a/make/pip/pip_linux_cpu.mk +++ b/make/pip/pip_linux_cpu.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu100.mk b/make/pip/pip_linux_cu100.mk index dc4b744dcf0d..f3bea65a7260 100644 --- a/make/pip/pip_linux_cu100.mk +++ b/make/pip/pip_linux_cu100.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu100mkl.mk b/make/pip/pip_linux_cu100mkl.mk index dd9d06093376..4dfcb213feb1 100644 --- a/make/pip/pip_linux_cu100mkl.mk +++ b/make/pip/pip_linux_cu100mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu75.mk b/make/pip/pip_linux_cu75.mk index 37ced7a9b9de..c686c20db456 100644 --- a/make/pip/pip_linux_cu75.mk +++ b/make/pip/pip_linux_cu75.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu75mkl.mk b/make/pip/pip_linux_cu75mkl.mk index 222bce36223c..ec87676c6c96 100644 --- a/make/pip/pip_linux_cu75mkl.mk +++ b/make/pip/pip_linux_cu75mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu80.mk b/make/pip/pip_linux_cu80.mk index 90137000accc..72a04deeb400 100644 --- a/make/pip/pip_linux_cu80.mk +++ b/make/pip/pip_linux_cu80.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu80mkl.mk b/make/pip/pip_linux_cu80mkl.mk index 1e1a87fe2b09..1bd295138936 100644 --- a/make/pip/pip_linux_cu80mkl.mk +++ b/make/pip/pip_linux_cu80mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu90.mk b/make/pip/pip_linux_cu90.mk index 24425d54e069..b831d6586795 100644 --- a/make/pip/pip_linux_cu90.mk +++ b/make/pip/pip_linux_cu90.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu90mkl.mk b/make/pip/pip_linux_cu90mkl.mk index cdcb97b6e2c9..8ab13075b3d0 100644 --- a/make/pip/pip_linux_cu90mkl.mk +++ b/make/pip/pip_linux_cu90mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu91.mk b/make/pip/pip_linux_cu91.mk index f99fd9504a2c..cb66394683a9 100644 --- a/make/pip/pip_linux_cu91.mk +++ b/make/pip/pip_linux_cu91.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu91mkl.mk b/make/pip/pip_linux_cu91mkl.mk index 89fb6aa1279d..a94874503c92 100644 --- a/make/pip/pip_linux_cu91mkl.mk +++ b/make/pip/pip_linux_cu91mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu92.mk b/make/pip/pip_linux_cu92.mk index 14638d5829b9..8796a3bbdaa7 100644 --- a/make/pip/pip_linux_cu92.mk +++ b/make/pip/pip_linux_cu92.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_cu92mkl.mk b/make/pip/pip_linux_cu92mkl.mk index 478ee34ab82f..b9766ec36dc8 100644 --- a/make/pip/pip_linux_cu92mkl.mk +++ b/make/pip/pip_linux_cu92mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/pip/pip_linux_mkl.mk b/make/pip/pip_linux_mkl.mk index 91f106b9d701..95146ee225ba 100644 --- a/make/pip/pip_linux_mkl.mk +++ b/make/pip/pip_linux_mkl.mk @@ -58,9 +58,9 @@ USE_BLAS=openblas # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 1 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDA during compile diff --git a/make/readthedocs.mk b/make/readthedocs.mk index b17e7bd5122f..b33dd3c5d21f 100644 --- a/make/readthedocs.mk +++ b/make/readthedocs.mk @@ -36,9 +36,9 @@ USE_CUDA_PATH = NONE # you can disable it, however, you will not able to use # imbin iterator USE_OPENCV = 0 -# Add OpenCV dependency path, the directory `opencv2` is in $(USE_OPENCV_DEP_PATH)/ -USE_OPENCV_DEP_PATH = NONE -# Add OpenCV shared library path if the shared libraries are not in $(USE_OPENCV_DEP_PATH)/lib +# Add OpenCV include path, in which the directory `opencv2` exists +USE_OPENCV_INC_PATH = NONE +# Add OpenCV shared library path, in which the shared library exists USE_OPENCV_LIB_PATH = NONE # whether use CUDNN R3 library From 8d35dd4a7253fb0fab6eb5f2d2e53b7cc23fe5ea Mon Sep 17 00:00:00 2001 From: JackieWu Date: Wed, 6 Mar 2019 07:25:36 +0800 Subject: [PATCH 10/12] remove libs-L --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 443162046583..a3433b60ee60 100644 --- a/Makefile +++ b/Makefile @@ -166,7 +166,6 @@ $(error Please add the path of OpenCV shared library path into `USE_OPENCV_LIB_P OPENCV_LIB = opencv endif CFLAGS += $(shell pkg-config --cflags $(OPENCV_LIB)) - LDFLAGS += $(shell pkg-config --libs-only-L $(OPENCV_LIB)) LDFLAGS += $(filter -lopencv_imgcodecs -lopencv_highgui, $(shell pkg-config --libs-only-l $(OPENCV_LIB))) endif LDFLAGS += -lopencv_core -lopencv_imgproc From 80b826abac7fb737abfe5f269e6f0b81f8682ec9 Mon Sep 17 00:00:00 2001 From: JackieWu Date: Wed, 6 Mar 2019 07:54:32 +0800 Subject: [PATCH 11/12] Fix OpenCV linking order --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a3433b60ee60..00d1128b7f67 100644 --- a/Makefile +++ b/Makefile @@ -153,6 +153,7 @@ ifeq ($(USE_OPENCV), 1) $(error Please add the path of OpenCV shared library path into `USE_OPENCV_LIB_PATH`, when `USE_OPENCV_INC_PATH` is not NONE) endif LDFLAGS += -L$(USE_OPENCV_LIB_PATH) + LDFLAGS += -lopencv_core -lopencv_imgproc ifneq ($(wildcard $(USE_OPENCV_LIB_PATH)/libopencv_imgcodecs.*),) LDFLAGS += -lopencv_imgcodecs endif @@ -166,9 +167,10 @@ $(error Please add the path of OpenCV shared library path into `USE_OPENCV_LIB_P OPENCV_LIB = opencv endif CFLAGS += $(shell pkg-config --cflags $(OPENCV_LIB)) + LDFLAGS += $(shell pkg-config --libs-only-L $(OPENCV_LIB)) + LDFLAGS += -lopencv_core -lopencv_imgproc LDFLAGS += $(filter -lopencv_imgcodecs -lopencv_highgui, $(shell pkg-config --libs-only-l $(OPENCV_LIB))) endif - LDFLAGS += -lopencv_core -lopencv_imgproc BIN += bin/im2rec else CFLAGS += -DMXNET_USE_OPENCV=0 From 232304d2c9827ebd670ce0a798f92f4bd770de87 Mon Sep 17 00:00:00 2001 From: wkcn Date: Wed, 6 Mar 2019 09:34:05 +0800 Subject: [PATCH 12/12] try to fix the bug of linking static libraries --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 00d1128b7f67..331c0b46c510 100644 --- a/Makefile +++ b/Makefile @@ -153,7 +153,6 @@ ifeq ($(USE_OPENCV), 1) $(error Please add the path of OpenCV shared library path into `USE_OPENCV_LIB_PATH`, when `USE_OPENCV_INC_PATH` is not NONE) endif LDFLAGS += -L$(USE_OPENCV_LIB_PATH) - LDFLAGS += -lopencv_core -lopencv_imgproc ifneq ($(wildcard $(USE_OPENCV_LIB_PATH)/libopencv_imgcodecs.*),) LDFLAGS += -lopencv_imgcodecs endif @@ -168,9 +167,9 @@ $(error Please add the path of OpenCV shared library path into `USE_OPENCV_LIB_P endif CFLAGS += $(shell pkg-config --cflags $(OPENCV_LIB)) LDFLAGS += $(shell pkg-config --libs-only-L $(OPENCV_LIB)) - LDFLAGS += -lopencv_core -lopencv_imgproc LDFLAGS += $(filter -lopencv_imgcodecs -lopencv_highgui, $(shell pkg-config --libs-only-l $(OPENCV_LIB))) endif + LDFLAGS += -lopencv_imgproc -lopencv_core BIN += bin/im2rec else CFLAGS += -DMXNET_USE_OPENCV=0