From c90e6d70e960c96007347730e6784f09223111ab Mon Sep 17 00:00:00 2001 From: Herb Kuta Date: Wed, 29 May 2019 10:01:15 -0700 Subject: [PATCH] DRAFT opencv_3.2: Import from meta-oe@0abf5af3ffd3d13c009a8ffcd5a6f045c36be837 --- ...dparty-ippicv-Use-pre-downloaded-ipp.patch | 28 ++ ...reate-share-library-intead-of-static.patch | 26 ++ ...001-Revert-cuda-fix-fp16-compilation.patch | 27 ++ .../0001-To-fix-errors-as-following.patch | 80 ++++++ ...-instead-of-vector-as-suggests-Eigen.patch | 49 ++++ ...-make-opencv_dnn-dependancy-optional.patch | 243 +++++++++++++++++ ...check-FP16-build-condition-correctly.patch | 245 ++++++++++++++++++ .../opencv/opencv/fixpkgconfig.patch | 29 +++ .../opencv/opencv/uselocalxfeatures.patch | 12 + .../opencv/opencv/useoeprotobuf.patch | 13 + recipes-support/opencv/opencv_3.2.bb | 175 +++++++++++++ 11 files changed, 927 insertions(+) create mode 100644 recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch create mode 100644 recipes-support/opencv/opencv/0001-Make-opencv-ts-create-share-library-intead-of-static.patch create mode 100644 recipes-support/opencv/opencv/0001-Revert-cuda-fix-fp16-compilation.patch create mode 100644 recipes-support/opencv/opencv/0001-To-fix-errors-as-following.patch create mode 100644 recipes-support/opencv/opencv/0001-Use-__vector-instead-of-vector-as-suggests-Eigen.patch create mode 100644 recipes-support/opencv/opencv/0001-tracking-make-opencv_dnn-dependancy-optional.patch create mode 100644 recipes-support/opencv/opencv/0002-Revert-check-FP16-build-condition-correctly.patch create mode 100644 recipes-support/opencv/opencv/fixpkgconfig.patch create mode 100644 recipes-support/opencv/opencv/uselocalxfeatures.patch create mode 100644 recipes-support/opencv/opencv/useoeprotobuf.patch create mode 100644 recipes-support/opencv/opencv_3.2.bb diff --git a/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch b/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch new file mode 100644 index 0000000..1077d05 --- /dev/null +++ b/recipes-support/opencv/opencv/0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch @@ -0,0 +1,28 @@ +From 049f931207631aa54af55a2917318d032b2ef3fa Mon Sep 17 00:00:00 2001 +From: Ricardo Ribalda Delgado +Date: Thu, 31 Mar 2016 00:20:15 +0200 +Subject: [PATCH] 3rdparty/ippicv: Use pre-downloaded ipp + +Signed-off-by: Ricardo Ribalda Delgado +--- + 3rdparty/ippicv/downloader.cmake | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/3rdparty/ippicv/downloader.cmake b/3rdparty/ippicv/downloader.cmake +index a6016dbe10bc..af4062c8e95e 100644 +--- a/3rdparty/ippicv/downloader.cmake ++++ b/3rdparty/ippicv/downloader.cmake +@@ -31,8 +31,10 @@ function(_icv_downloader) + return() # Not supported + endif() + ++ if(NOT DEFINED OPENCV_ICV_PATH) + set(OPENCV_ICV_UNPACK_PATH "${CMAKE_BINARY_DIR}/3rdparty/ippicv") + set(OPENCV_ICV_PATH "${OPENCV_ICV_UNPACK_PATH}${OPENCV_ICV_PACKAGE_SUBDIR}") ++ endif() + + if(DEFINED OPENCV_ICV_PACKAGE_DOWNLOADED + AND OPENCV_ICV_PACKAGE_DOWNLOADED STREQUAL OPENCV_ICV_PACKAGE_HASH +-- +2.8.0.rc3 + diff --git a/recipes-support/opencv/opencv/0001-Make-opencv-ts-create-share-library-intead-of-static.patch b/recipes-support/opencv/opencv/0001-Make-opencv-ts-create-share-library-intead-of-static.patch new file mode 100644 index 0000000..05ec41f --- /dev/null +++ b/recipes-support/opencv/opencv/0001-Make-opencv-ts-create-share-library-intead-of-static.patch @@ -0,0 +1,26 @@ +From 49d1f7c40a5d097f23671318045ac54bc07846cf Mon Sep 17 00:00:00 2001 +From: Bian Naimeng +Date: Wed, 19 Apr 2017 03:11:37 +0900 +Subject: [PATCH] Make opencv-ts create share library intead of static. + +Signed-off-by: Lei Maohui +--- + modules/ts/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt +index bb56da2..7bb4ce9 100644 +--- a/modules/ts/CMakeLists.txt ++++ b/modules/ts/CMakeLists.txt +@@ -4,7 +4,7 @@ if(IOS) + ocv_module_disable(ts) + endif() + +-set(OPENCV_MODULE_TYPE STATIC) ++#set(OPENCV_MODULE_TYPE STATIC) + set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE) + + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) +-- +1.8.4.2 + diff --git a/recipes-support/opencv/opencv/0001-Revert-cuda-fix-fp16-compilation.patch b/recipes-support/opencv/opencv/0001-Revert-cuda-fix-fp16-compilation.patch new file mode 100644 index 0000000..507d796 --- /dev/null +++ b/recipes-support/opencv/opencv/0001-Revert-cuda-fix-fp16-compilation.patch @@ -0,0 +1,27 @@ +From 69f9707678190f6a0948a547dce948251f972676 Mon Sep 17 00:00:00 2001 +From: Randy MacLeod +Date: Wed, 26 Apr 2017 14:57:30 -0400 +Subject: [PATCH 1/2] Revert "cuda: fix fp16 compilation" + +This reverts commit 12e00827be40576b686ea4438a6e6ef85208743d. +--- + modules/core/include/opencv2/core/cvdef.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h +index 699b166..efc24ca 100644 +--- a/modules/core/include/opencv2/core/cvdef.h ++++ b/modules/core/include/opencv2/core/cvdef.h +@@ -303,8 +303,7 @@ enum CpuFeatures { + #define CV_2PI 6.283185307179586476925286766559 + #define CV_LOG2 0.69314718055994530941723212145818 + +-#if defined __ARM_FP16_FORMAT_IEEE \ +- && !defined __CUDACC__ ++#if defined (__ARM_FP16_FORMAT_IEEE) + # define CV_FP16_TYPE 1 + #else + # define CV_FP16_TYPE 0 +-- +2.9.3 + diff --git a/recipes-support/opencv/opencv/0001-To-fix-errors-as-following.patch b/recipes-support/opencv/opencv/0001-To-fix-errors-as-following.patch new file mode 100644 index 0000000..9c1b9b3 --- /dev/null +++ b/recipes-support/opencv/opencv/0001-To-fix-errors-as-following.patch @@ -0,0 +1,80 @@ +From a4abe478bf4514ec95aa10b2d6f258647ce325f5 Mon Sep 17 00:00:00 2001 +From: Huang Qiyu +Date: Fri, 19 May 2017 04:27:50 +0900 +Subject: [PATCH] To fix errors as following: + +"test_main.cpp:45: undefined reference to `parseCustomOptions(int, char**)'" +"perf_abs.cpp:13: undefined reference to `cvtest::param_seed'" +"test_superres.cpp:270: undefined reference to `checkIppStatus()'" + +Signed-off-by: Huang Qiyu + +Also add the visibility changes for certain OpenCL-related functions in +ts module. + +Signed-off-by: Ismo Puustinen +--- + modules/ts/include/opencv2/ts.hpp | 6 +++--- + modules/ts/include/opencv2/ts/ocl_test.hpp | 2 +- + modules/ts/include/opencv2/ts/ts_ext.hpp | 2 +- + 3 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp +index c573905..230f598 100644 +--- a/modules/ts/include/opencv2/ts.hpp ++++ b/modules/ts/include/opencv2/ts.hpp +@@ -539,7 +539,7 @@ protected: + } + }; + +-extern uint64 param_seed; ++CV_EXPORTS extern uint64 param_seed; + + struct CV_EXPORTS DefaultRngAuto + { +@@ -595,14 +595,14 @@ CV_EXPORTS std::string findDataFile(const std::string& relative_path, bool requi + + #ifdef HAVE_OPENCL + namespace ocl { +-void dumpOpenCLDevice(); ++CV_EXPORTS void dumpOpenCLDevice(); + } + #define TEST_DUMP_OCL_INFO cvtest::ocl::dumpOpenCLDevice(); + #else + #define TEST_DUMP_OCL_INFO + #endif + +-void parseCustomOptions(int argc, char **argv); ++CV_EXPORTS void parseCustomOptions(int argc, char **argv); + + #define CV_TEST_MAIN(resourcesubdir, ...) \ + int main(int argc, char **argv) \ +diff --git a/modules/ts/include/opencv2/ts/ocl_test.hpp b/modules/ts/include/opencv2/ts/ocl_test.hpp +index c967cd7..ff35b40 100644 +--- a/modules/ts/include/opencv2/ts/ocl_test.hpp ++++ b/modules/ts/include/opencv2/ts/ocl_test.hpp +@@ -84,7 +84,7 @@ inline UMat ToUMat(InputArray src) + return dst; + } + +-extern int test_loop_times; ++CV_EXPORTS extern int test_loop_times; + + #define MAX_VALUE 357 + +diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp +index 05ccc63..8075065 100644 +--- a/modules/ts/include/opencv2/ts/ts_ext.hpp ++++ b/modules/ts/include/opencv2/ts/ts_ext.hpp +@@ -9,7 +9,7 @@ + #define OPENCV_TS_EXT_HPP + + namespace cvtest { +-void checkIppStatus(); ++CV_EXPORTS void checkIppStatus(); + } + + #define CV_TEST_INIT \ +-- +2.9.4 + diff --git a/recipes-support/opencv/opencv/0001-Use-__vector-instead-of-vector-as-suggests-Eigen.patch b/recipes-support/opencv/opencv/0001-Use-__vector-instead-of-vector-as-suggests-Eigen.patch new file mode 100644 index 0000000..7f809bc --- /dev/null +++ b/recipes-support/opencv/opencv/0001-Use-__vector-instead-of-vector-as-suggests-Eigen.patch @@ -0,0 +1,49 @@ +From 711f07a34ceb504e8f75e978692201efa58268ca Mon Sep 17 00:00:00 2001 +From: Dinar Valeev +Date: Thu, 16 Jan 2014 21:53:49 +0100 +Subject: [PATCH] Use __vector instead of vector as suggests Eigen + +This fixes build on PowerPC where Eigen unsets vector, bool and pixel + +Signed-off-by: Dinar Valeev + +This patch is already part of OpenCV v3.0. The patch can be obtained +from: + + https://github.com/Itseez/opencv/commit/711f07a34ceb504e8f75e978692201efa58268ca.patch + +Upstream-Status: Backport [commit 711f07a34c, part of version 3.0] + +Signed-off-by: Lukas Bulwahn +--- + 3rdparty/include/opencl/1.2/CL/cl_platform.h | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/3rdparty/include/opencl/1.2/CL/cl_platform.h b/3rdparty/include/opencl/1.2/CL/cl_platform.h +index e94949a..42c35d5 100644 +--- a/3rdparty/include/opencl/1.2/CL/cl_platform.h ++++ b/3rdparty/include/opencl/1.2/CL/cl_platform.h +@@ -332,13 +332,13 @@ typedef unsigned int cl_GLenum; + /* Define basic vector types */ + #if defined( __VEC__ ) + #include /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */ +- typedef vector unsigned char __cl_uchar16; +- typedef vector signed char __cl_char16; +- typedef vector unsigned short __cl_ushort8; +- typedef vector signed short __cl_short8; +- typedef vector unsigned int __cl_uint4; +- typedef vector signed int __cl_int4; +- typedef vector float __cl_float4; ++ typedef __vector unsigned char __cl_uchar16; ++ typedef __vector signed char __cl_char16; ++ typedef __vector unsigned short __cl_ushort8; ++ typedef __vector signed short __cl_short8; ++ typedef __vector unsigned int __cl_uint4; ++ typedef __vector signed int __cl_int4; ++ typedef __vector float __cl_float4; + #define __CL_UCHAR16__ 1 + #define __CL_CHAR16__ 1 + #define __CL_USHORT8__ 1 +-- +1.9.3 + diff --git a/recipes-support/opencv/opencv/0001-tracking-make-opencv_dnn-dependancy-optional.patch b/recipes-support/opencv/opencv/0001-tracking-make-opencv_dnn-dependancy-optional.patch new file mode 100644 index 0000000..fba43eb --- /dev/null +++ b/recipes-support/opencv/opencv/0001-tracking-make-opencv_dnn-dependancy-optional.patch @@ -0,0 +1,243 @@ +From 69f86025978b9bbbefa54a7248316a859773aeaf Mon Sep 17 00:00:00 2001 +From: berak +Date: Sat, 4 Mar 2017 12:38:50 +0100 +Subject: [PATCH] tracking: make opencv_dnn dependancy optional + +Upstream-status: Backport [https://github.com/opencv/opencv_contrib/commit/43925b60d392fbd01d6b0449713f010f9babe448] +Signed-off-by: Ismo Puustinen + +--- + modules/tracking/CMakeLists.txt | 3 +-- + modules/tracking/samples/goturnTracker.cpp | 22 +++++++++++++++++++--- + modules/tracking/samples/multiTracker_dataset.cpp | 1 + + modules/tracking/samples/tracker_dataset.cpp | 1 + + modules/tracking/src/gtrTracker.cpp | 11 ++++++++++- + modules/tracking/src/gtrTracker.hpp | 12 ++++++++---- + modules/tracking/src/gtrUtils.cpp | 6 +++--- + modules/tracking/src/gtrUtils.hpp | 5 ++--- + modules/tracking/src/tracker.cpp | 1 + + 9 files changed, 46 insertions(+), 16 deletions(-) + +diff --git a/modules/tracking/CMakeLists.txt b/modules/tracking/CMakeLists.txt +index a8b3183..d27f999 100644 +--- a/modules/tracking/CMakeLists.txt ++++ b/modules/tracking/CMakeLists.txt +@@ -1,2 +1 @@ +-set(the_description "Tracking API") +-ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_dnn opencv_plot OPTIONAL opencv_datasets WRAP python) +\ No newline at end of file ++ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_plot OPTIONAL opencv_dnn opencv_datasets WRAP python) +diff --git a/modules/tracking/samples/goturnTracker.cpp b/modules/tracking/samples/goturnTracker.cpp +index 389771e..1e6632d 100644 +--- a/modules/tracking/samples/goturnTracker.cpp ++++ b/modules/tracking/samples/goturnTracker.cpp +@@ -45,6 +45,9 @@ + //1 - Train you own GOTURN model using + //2 - Download pretrained caffemodel from + ++#include "opencv2/opencv_modules.hpp" ++#if defined(HAVE_OPENCV_DNN) && defined(HAVE_OPENCV_DATASETS) ++ + #include "opencv2/datasets/track_alov.hpp" + #include + #include +@@ -65,8 +68,8 @@ static bool startSelection = false; + Rect2d boundingBox; + + static const char* keys = +-{ "{@dataset_path |true| Dataset path }" +-"{@dataset_id |1| Dataset ID }" ++{ "{@dataset_path || Dataset path }" ++ "{@dataset_id |1| Dataset ID }" + }; + + static void onMouse(int event, int x, int y, int, void*) +@@ -144,9 +147,14 @@ int main(int argc, char *argv[]) + Ptr dataset = TRACK_alov::create(); + dataset->load(datasetRootPath); + dataset->initDataset(datasetID); +- + //Read first frame + dataset->getNextFrame(frame); ++ if (frame.empty()) ++ { ++ cout << "invalid dataset: " << datasetRootPath << endl; ++ return -2; ++ } ++ + frame.copyTo(image); + rectangle(image, boundingBox, Scalar(255, 0, 0), 2, 1); + imshow("GOTURN Tracking", image); +@@ -215,3 +223,11 @@ int main(int argc, char *argv[]) + + return 0; + } ++ ++#else // ! HAVE_OPENCV_DNN && HAVE_OPENCV_DATASETS ++#include ++int main() { ++ CV_Error(cv::Error::StsNotImplemented , "this sample needs to be built with opencv_datasets and opencv_dnn !"); ++ return -1; ++} ++#endif +diff --git a/modules/tracking/samples/multiTracker_dataset.cpp b/modules/tracking/samples/multiTracker_dataset.cpp +index 2826b19..b5c27da 100644 +--- a/modules/tracking/samples/multiTracker_dataset.cpp ++++ b/modules/tracking/samples/multiTracker_dataset.cpp +@@ -234,6 +234,7 @@ int main(int argc, char *argv[]) + } + + #else // ! HAVE_OPENCV_DATASETS ++#include + int main() { + CV_Error(cv::Error::StsNotImplemented , "this sample needs to be built with opencv_datasets !"); + return -1; +diff --git a/modules/tracking/samples/tracker_dataset.cpp b/modules/tracking/samples/tracker_dataset.cpp +index 8b7832a..6178105 100644 +--- a/modules/tracking/samples/tracker_dataset.cpp ++++ b/modules/tracking/samples/tracker_dataset.cpp +@@ -234,6 +234,7 @@ int main(int argc, char *argv[]) + + + #else // ! HAVE_OPENCV_DATASETS ++#include + int main() { + CV_Error(cv::Error::StsNotImplemented , "this sample needs to be built with opencv_datasets !"); + return -1; +diff --git a/modules/tracking/src/gtrTracker.cpp b/modules/tracking/src/gtrTracker.cpp +index 58debfd..4904f47 100644 +--- a/modules/tracking/src/gtrTracker.cpp ++++ b/modules/tracking/src/gtrTracker.cpp +@@ -38,7 +38,7 @@ + // the use of this software, even if advised of the possibility of such damage. + // + //M*/ +- ++#include "opencv2/opencv_modules.hpp" + #include "gtrTracker.hpp" + + +@@ -54,9 +54,16 @@ void TrackerGOTURN::Params::write(cv::FileStorage& /*fs*/) const {} + + Ptr TrackerGOTURN::createTracker(const TrackerGOTURN::Params ¶meters) + { ++#ifdef HAVE_OPENCV_DNN + return Ptr(new gtr::TrackerGOTURNImpl(parameters)); ++#else ++ (void)(parameters); ++ CV_ErrorNoReturn(cv::Error::StsNotImplemented , "to use GOTURN, the tracking module needs to be built with opencv_dnn !"); ++#endif + } + ++ ++#ifdef HAVE_OPENCV_DNN + namespace gtr + { + +@@ -183,9 +190,11 @@ bool TrackerGOTURNImpl::updateImpl(const Mat& image, Rect2d& boundingBox) + //Set new model image and BB from current frame + ((TrackerGOTURNModel*)static_cast(model))->setImage(curFrame); + ((TrackerGOTURNModel*)static_cast(model))->setBoudingBox(curBB); ++ + return true; + } + + } ++#endif // OPENCV_HAVE_DNN + + } +diff --git a/modules/tracking/src/gtrTracker.hpp b/modules/tracking/src/gtrTracker.hpp +index 34f2c48..21ae3d9 100644 +--- a/modules/tracking/src/gtrTracker.hpp ++++ b/modules/tracking/src/gtrTracker.hpp +@@ -45,11 +45,15 @@ + + #include "precomp.hpp" + #include "opencv2/video/tracking.hpp" +-#include "opencv2/dnn.hpp" + #include "gtrUtils.hpp" + #include "opencv2/imgproc.hpp" +-#include +-#include ++ ++#include ++#include ++ ++#include "opencv2/opencv_modules.hpp" ++#ifdef HAVE_OPENCV_DNN ++#include "opencv2/dnn.hpp" + + namespace cv + { +@@ -72,5 +76,5 @@ public: + + } + } +- ++#endif + #endif +diff --git a/modules/tracking/src/gtrUtils.cpp b/modules/tracking/src/gtrUtils.cpp +index 0df1197..e80dda1 100644 +--- a/modules/tracking/src/gtrUtils.cpp ++++ b/modules/tracking/src/gtrUtils.cpp +@@ -58,7 +58,7 @@ double generateRandomLaplacian(double b, double m) + return m - b*log(n); + } + +-Rect2f anno2rect(vector annoBB) ++Rect2f anno2rect(std::vector annoBB) + { + Rect2f rectBB; + rectBB.x = min(annoBB[0].x, annoBB[1].x); +@@ -69,9 +69,9 @@ Rect2f anno2rect(vector annoBB) + return rectBB; + } + +-vector gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB) ++std::vector gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB) + { +- vector trainingSamples; ++ std::vector trainingSamples; + Point2f currCenter, prevCenter; + Rect2f targetPatchRect, searchPatchRect; + Mat targetPatch, searchPatch; +diff --git a/modules/tracking/src/gtrUtils.hpp b/modules/tracking/src/gtrUtils.hpp +index 8f388be..41aad21 100644 +--- a/modules/tracking/src/gtrUtils.hpp ++++ b/modules/tracking/src/gtrUtils.hpp +@@ -4,7 +4,6 @@ + #include "precomp.hpp" + #include + #include "opencv2/highgui.hpp" +-#include + + namespace cv + { +@@ -50,10 +49,10 @@ struct TrainingSample + double generateRandomLaplacian(double b, double m); + + //Convert ALOV300++ anno coordinates to Rectangle BB +-Rect2f anno2rect(vector annoBB); ++Rect2f anno2rect(std::vector annoBB); + + //Gather samples from random video frame +-vector gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB); ++std::vector gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB); + + } + } +diff --git a/modules/tracking/src/tracker.cpp b/modules/tracking/src/tracker.cpp +index 8127f2a..b96aca8 100644 +--- a/modules/tracking/src/tracker.cpp ++++ b/modules/tracking/src/tracker.cpp +@@ -112,6 +112,7 @@ Ptr Tracker::create( const String& trackerType ) + BOILERPLATE_CODE("TLD",TrackerTLD); + BOILERPLATE_CODE("KCF",TrackerKCF); + BOILERPLATE_CODE("GOTURN", TrackerGOTURN); ++ + return Ptr(); + } + +-- +2.9.4 + diff --git a/recipes-support/opencv/opencv/0002-Revert-check-FP16-build-condition-correctly.patch b/recipes-support/opencv/opencv/0002-Revert-check-FP16-build-condition-correctly.patch new file mode 100644 index 0000000..d1950a9 --- /dev/null +++ b/recipes-support/opencv/opencv/0002-Revert-check-FP16-build-condition-correctly.patch @@ -0,0 +1,245 @@ +From 9108e39e5584ef9b41f80751639b4ec72b3e9538 Mon Sep 17 00:00:00 2001 +From: Randy MacLeod +Date: Wed, 26 Apr 2017 15:00:32 -0400 +Subject: [PATCH 2/2] Revert "check FP16 build condition correctly" + +This reverts commit c7cb116dc08441fe56cf82d5b21f929e5b674c13. + +Fix up revert conflicts to take previous behaviour. +--- + cmake/OpenCVCompilerOptions.cmake | 45 +++++++++-------------- + modules/core/include/opencv2/core/cvdef.h | 2 +- + modules/core/src/convert.cpp | 11 +++--- + modules/core/test/test_intrin.cpp | 60 ++++++++++++++----------------- + 4 files changed, 48 insertions(+), 70 deletions(-) + +diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake +index 5bb0479..4b19fdb 100644 +--- a/cmake/OpenCVCompilerOptions.cmake ++++ b/cmake/OpenCVCompilerOptions.cmake +@@ -185,7 +185,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) + add_extra_compiler_option("-mfp16-format=ieee") + endif(ARM) + if(ENABLE_NEON) +- add_extra_compiler_option("-mfpu=neon") ++ add_extra_compiler_option("-mfpu=neon-fp16") + endif() + if(ENABLE_VFPV3 AND NOT ENABLE_NEON) + add_extra_compiler_option("-mfpu=vfpv3") +@@ -370,34 +370,6 @@ if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_OPENCV_GCC_VERSION_NUM GREATER 399) + add_extra_compiler_option(-fvisibility-inlines-hidden) + endif() + +-if(NOT OPENCV_FP16_DISABLE AND NOT IOS) +- if(ARM AND ENABLE_NEON) +- set(FP16_OPTION "-mfpu=neon-fp16") +- elseif((X86 OR X86_64) AND NOT MSVC AND ENABLE_AVX) +- set(FP16_OPTION "-mf16c") +- endif() +- try_compile(__VALID_FP16 +- "${OpenCV_BINARY_DIR}" +- "${OpenCV_SOURCE_DIR}/cmake/checks/fp16.cpp" +- COMPILE_DEFINITIONS "-DCHECK_FP16" "${FP16_OPTION}" +- OUTPUT_VARIABLE TRY_OUT +- ) +- if(NOT __VALID_FP16) +- if((X86 OR X86_64) AND NOT MSVC AND NOT ENABLE_AVX) +- # GCC enables AVX when mf16c is passed +- message(STATUS "FP16: Feature disabled") +- else() +- message(STATUS "FP16: Compiler support is not available") +- endif() +- else() +- message(STATUS "FP16: Compiler support is available") +- set(HAVE_FP16 1) +- if(NOT ${FP16_OPTION} STREQUAL "") +- add_extra_compiler_option(${FP16_OPTION}) +- endif() +- endif() +-endif() +- + #combine all "extra" options + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}") +@@ -450,6 +422,21 @@ if(MSVC) + endif() + endif() + ++if(NOT OPENCV_FP16_DISABLE) ++ try_compile(__VALID_FP16 ++ "${OpenCV_BINARY_DIR}" ++ "${OpenCV_SOURCE_DIR}/cmake/checks/fp16.cpp" ++ COMPILE_DEFINITIONS "-DCHECK_FP16" ++ OUTPUT_VARIABLE TRY_OUT ++ ) ++ if(NOT __VALID_FP16) ++ message(STATUS "FP16: Compiler support is not available") ++ else() ++ message(STATUS "FP16: Compiler support is available") ++ set(HAVE_FP16 1) ++ endif() ++endif() ++ + if(APPLE AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{LDFLAGS} AND EXISTS "/usr/local/lib") + link_directories("/usr/local/lib") + endif() +diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h +index efc24ca..a10936b 100644 +--- a/modules/core/include/opencv2/core/cvdef.h ++++ b/modules/core/include/opencv2/core/cvdef.h +@@ -312,7 +312,7 @@ enum CpuFeatures { + typedef union Cv16suf + { + short i; +-#if CV_FP16_TYPE ++#if ( defined (__arm__) || defined (__aarch64__) ) && !defined (__CUDACC__) && ( defined (__GNUC__) && ( ( ( 4 <= __GNUC__ ) && ( 7 <= __GNUC__ ) ) || ( 5 <= __GNUC__ ) ) ) + __fp16 h; + #endif + struct _fp16Format +diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp +index e04d89e..46db26f 100644 +--- a/modules/core/src/convert.cpp ++++ b/modules/core/src/convert.cpp +@@ -44,7 +44,6 @@ + #include "precomp.hpp" + + #include "opencl_kernels_core.hpp" +-#include "opencv2/core/hal/intrin.hpp" + + #include "opencv2/core/openvx/ovx_defs.hpp" + +@@ -4382,7 +4381,7 @@ struct Cvt_SIMD + + #endif + +-#if !CV_FP16_TYPE ++#if !( ( defined (__arm__) || defined (__aarch64__) ) && ( defined (__GNUC__) && ( ( ( 4 <= __GNUC__ ) && ( 7 <= __GNUC__ ) ) || ( 5 <= __GNUC__ ) ) ) ) + // const numbers for floating points format + const unsigned int kShiftSignificand = 13; + const unsigned int kMaskFp16Significand = 0x3ff; +@@ -4390,7 +4389,7 @@ const unsigned int kBiasFp16Exponent = 15; + const unsigned int kBiasFp32Exponent = 127; + #endif + +-#if CV_FP16_TYPE ++#if ( defined (__arm__) || defined (__aarch64__) ) && ( defined (__GNUC__) && ( ( ( 4 <= __GNUC__ ) && ( 7 <= __GNUC__ ) ) || ( 5 <= __GNUC__ ) ) ) + static float convertFp16SW(short fp16) + { + // Fp16 -> Fp32 +@@ -4452,7 +4451,7 @@ static float convertFp16SW(short fp16) + } + #endif + +-#if CV_FP16_TYPE ++#if ( defined (__arm__) || defined (__aarch64__) ) && ( defined (__GNUC__) && ( ( ( 4 <= __GNUC__ ) && ( 7 <= __GNUC__ ) ) || ( 5 <= __GNUC__ ) ) ) + static short convertFp16SW(float fp32) + { + // Fp32 -> Fp16 +@@ -4560,7 +4559,7 @@ cvtScaleHalf_( const float* src, size_t sstep, short* dst, size_t + if ( ( (intptr_t)dst & 0xf ) == 0 ) + #endif + { +-#if CV_FP16 && CV_SIMD128 ++#if CV_FP16 + for ( ; x <= size.width - 4; x += 4) + { + v_float32x4 v_src = v_load(src + x); +@@ -4606,7 +4605,7 @@ cvtScaleHalf_( const short* src, size_t sstep, float* dst, size_t + if ( ( (intptr_t)src & 0xf ) == 0 ) + #endif + { +-#if CV_FP16 && CV_SIMD128 ++#if CV_FP16 + for ( ; x <= size.width - 4; x += 4) + { + v_float16x4 v_src = v_load_f16(src + x); +diff --git a/modules/core/test/test_intrin.cpp b/modules/core/test/test_intrin.cpp +index 66b2083..7349d48 100644 +--- a/modules/core/test/test_intrin.cpp ++++ b/modules/core/test/test_intrin.cpp +@@ -729,56 +729,48 @@ template struct TheTest + return *this; + } + ++#if CV_FP16 + TheTest & test_loadstore_fp16() + { +-#if CV_FP16 + AlignedData data; + AlignedData out; + +- if(checkHardwareSupport(CV_CPU_FP16)) +- { +- // check if addresses are aligned and unaligned respectively +- EXPECT_EQ((size_t)0, (size_t)&data.a.d % 16); +- EXPECT_NE((size_t)0, (size_t)&data.u.d % 16); +- EXPECT_EQ((size_t)0, (size_t)&out.a.d % 16); +- EXPECT_NE((size_t)0, (size_t)&out.u.d % 16); +- +- // check some initialization methods +- R r1 = data.u; +- R r2 = v_load_f16(data.a.d); +- R r3(r2); +- EXPECT_EQ(data.u[0], r1.get0()); +- EXPECT_EQ(data.a[0], r2.get0()); +- EXPECT_EQ(data.a[0], r3.get0()); +- +- // check some store methods +- out.a.clear(); +- v_store_f16(out.a.d, r1); +- EXPECT_EQ(data.a, out.a); +- } ++ // check if addresses are aligned and unaligned respectively ++ EXPECT_EQ((size_t)0, (size_t)&data.a.d % 16); ++ EXPECT_NE((size_t)0, (size_t)&data.u.d % 16); ++ EXPECT_EQ((size_t)0, (size_t)&out.a.d % 16); ++ EXPECT_NE((size_t)0, (size_t)&out.u.d % 16); ++ ++ // check some initialization methods ++ R r1 = data.u; ++ R r2 = v_load_f16(data.a.d); ++ R r3(r2); ++ EXPECT_EQ(data.u[0], r1.get0()); ++ EXPECT_EQ(data.a[0], r2.get0()); ++ EXPECT_EQ(data.a[0], r3.get0()); ++ ++ // check some store methods ++ out.a.clear(); ++ v_store_f16(out.a.d, r1); ++ EXPECT_EQ(data.a, out.a); + + return *this; +-#endif + } + + TheTest & test_float_cvt_fp16() + { +-#if CV_FP16 + AlignedData data; + +- if(checkHardwareSupport(CV_CPU_FP16)) +- { +- // check conversion +- v_float32x4 r1 = v_load(data.a.d); +- v_float16x4 r2 = v_cvt_f16(r1); +- v_float32x4 r3 = v_cvt_f32(r2); +- EXPECT_EQ(0x3c00, r2.get0()); +- EXPECT_EQ(r3.get0(), r1.get0()); +- } ++ // check conversion ++ v_float32x4 r1 = v_load(data.a.d); ++ v_float16x4 r2 = v_cvt_f16(r1); ++ v_float32x4 r3 = v_cvt_f32(r2); ++ EXPECT_EQ(0x3c00, r2.get0()); ++ EXPECT_EQ(r3.get0(), r1.get0()); + + return *this; +-#endif + } ++#endif + + }; + +-- +2.9.3 + diff --git a/recipes-support/opencv/opencv/fixpkgconfig.patch b/recipes-support/opencv/opencv/fixpkgconfig.patch new file mode 100644 index 0000000..3aeda7d --- /dev/null +++ b/recipes-support/opencv/opencv/fixpkgconfig.patch @@ -0,0 +1,29 @@ +diff --git a/cmake/OpenCVGenPkgconfig.cmake b/cmake/OpenCVGenPkgconfig.cmake +index b8cb8777c06b..75281ee964fd 100644 +--- a/cmake/OpenCVGenPkgconfig.cmake ++++ b/cmake/OpenCVGenPkgconfig.cmake +@@ -27,7 +27,7 @@ macro(fix_prefix lst isown) + get_filename_component(libdir "${item}" PATH) + get_filename_component(libname "${item}" NAME_WE) + string(REGEX REPLACE "^lib(.*)" "\\1" libname "${libname}") +- list(APPEND _lst "-L${libdir}" "-l${libname}") ++ list(APPEND _lst "-l${libname}") + else() + list(APPEND _lst "-l${item}") + endif() +@@ -66,10 +66,14 @@ ocv_list_unique(_3rdparty) + + set(OPENCV_PC_LIBS + "-L\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}" ++ "-L\${exec_prefix}/${OPENCV_3P_LIB_INSTALL_PATH}" + "${_modules}" + ) + if (BUILD_SHARED_LIBS) +- set(OPENCV_PC_LIBS_PRIVATE "${_extra}") ++ set(OPENCV_PC_LIBS_PRIVATE ++ "-L\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}" ++ "${_extra}" ++ ) + else() + set(OPENCV_PC_LIBS_PRIVATE + "-L\${exec_prefix}/${OPENCV_3P_LIB_INSTALL_PATH}" diff --git a/recipes-support/opencv/opencv/uselocalxfeatures.patch b/recipes-support/opencv/opencv/uselocalxfeatures.patch new file mode 100644 index 0000000..a2db48d --- /dev/null +++ b/recipes-support/opencv/opencv/uselocalxfeatures.patch @@ -0,0 +1,12 @@ +diff --git a/modules/xfeatures2d/CMakeLists.txt b/modules/xfeatures2d/CMakeLists.txt +index f295bddaed66..6086e75ec37b 100644 +--- a/modules/xfeatures2d/CMakeLists.txt ++++ b/modules/xfeatures2d/CMakeLists.txt +@@ -1,5 +1,5 @@ + set(the_description "Contributed/Experimental Algorithms for Salient 2D Features Detection") + ocv_define_module(xfeatures2d opencv_core opencv_imgproc opencv_features2d opencv_calib3d opencv_shape opencv_highgui opencv_videoio opencv_ml + OPTIONAL opencv_cudaarithm WRAP python java) +-include(cmake/download_vgg.cmake) +-include(cmake/download_boostdesc.cmake) ++#include(cmake/download_vgg.cmake) ++#include(cmake/download_boostdesc.cmake) diff --git a/recipes-support/opencv/opencv/useoeprotobuf.patch b/recipes-support/opencv/opencv/useoeprotobuf.patch new file mode 100644 index 0000000..3068bd4 --- /dev/null +++ b/recipes-support/opencv/opencv/useoeprotobuf.patch @@ -0,0 +1,13 @@ +diff --git a/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake b/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake +index eb2a729cc2eb..8717736484de 100644 +--- a/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake ++++ b/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake +@@ -24,7 +24,7 @@ if(NOT BUILD_PROTOBUF AND NOT (DEFINED PROTOBUF_INCLUDE_DIR AND DEFINED PROTOBUF + find_package(Protobuf QUIET) + endif() + +-if(PROTOBUF_FOUND) ++if(PROTOBUF_FOUND OR (DEFINED PROTOBUF_INCLUDE_DIR AND DEFINED PROTOBUF_LIBRARIES)) + # nothing + else() + include(${CMAKE_CURRENT_LIST_DIR}/download_protobuf.cmake) diff --git a/recipes-support/opencv/opencv_3.2.bb b/recipes-support/opencv/opencv_3.2.bb new file mode 100644 index 0000000..fc62e99 --- /dev/null +++ b/recipes-support/opencv/opencv_3.2.bb @@ -0,0 +1,175 @@ +SUMMARY = "Opencv : The Open Computer Vision Library" +HOMEPAGE = "http://opencv.org/" +SECTION = "libs" + +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=2b2f8752cc5edf504d283107d033f544" + +ARM_INSTRUCTION_SET_armv4 = "arm" +ARM_INSTRUCTION_SET_armv5 = "arm" + +DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp" + +SRCREV_opencv = "70bbf17b133496bd7d54d034b0f94bd869e0e810" +SRCREV_contrib = "86342522b0eb2b16fa851c020cc4e0fef4e010b7" +SRCREV_ipp = "81a676001ca8075ada498583e4166079e5744668" +SRCREV_bootdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" +SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" +IPP_MD5 = "808b791a6eac9ed78d32a7666804320e" + +SRCREV_FORMAT = "opencv" +SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \ + git://github.com/opencv/opencv_contrib.git;destsuffix=contrib;name=contrib \ + git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20151201;destsuffix=ipp;name=ipp \ + git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=bootdesc;name=bootdesc \ + git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=vgg;name=vgg \ + file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \ + file://fixpkgconfig.patch \ + file://uselocalxfeatures.patch;patchdir=../contrib/ \ + file://useoeprotobuf.patch;patchdir=../contrib/ \ + file://0001-Revert-cuda-fix-fp16-compilation.patch \ + file://0002-Revert-check-FP16-build-condition-correctly.patch \ + file://0001-Make-opencv-ts-create-share-library-intead-of-static.patch \ + file://0001-To-fix-errors-as-following.patch \ + file://0001-tracking-make-opencv_dnn-dependancy-optional.patch;patchdir=../contrib/ \ +" + +PV = "3.2+git${SRCPV}" + +S = "${WORKDIR}/git" + +do_unpack_extra() { + tar xzf ${WORKDIR}/ipp/ippicv/ippicv_linux_20151201.tgz -C ${WORKDIR} + cp ${WORKDIR}/vgg/*.i ${WORKDIR}/contrib/modules/xfeatures2d/src + cp ${WORKDIR}/bootdesc/*.i ${WORKDIR}/contrib/modules/xfeatures2d/src +} +addtask unpack_extra after do_unpack before do_patch + +EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \ + -DWITH_1394=OFF \ + -DCMAKE_SKIP_RPATH=ON \ + -DOPENCV_ICV_PACKAGE_DOWNLOADED=${IPP_MD5} \ + -DOPENCV_ICV_PATH=${WORKDIR}/ippicv_lnx \ + ${@bb.utils.contains("TARGET_CC_ARCH", "-msse3", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1", "", d)} \ + ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.1", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1", "", d)} \ + ${@bb.utils.contains("TARGET_CC_ARCH", "-msse4.2", "-DENABLE_SSE=1 -DENABLE_SSE2=1 -DENABLE_SSE3=1 -DENABLE_SSSE3=1 -DENABLE_SSE41=1 -DENABLE_SSE42=1", "", d)} \ + ${@base_conditional("libdir", "/usr/lib64", "-DLIB_SUFFIX=64", "", d)} \ + ${@base_conditional("libdir", "/usr/lib32", "-DLIB_SUFFIX=32", "", d)} \ +" +EXTRA_OECMAKE_append_x86 = " -DX86=ON" + +PACKAGECONFIG ??= "python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb gphoto2 \ + ${@bb.utils.contains("DISTRO_FEATURES", "x11", "gtk", "", d)} \ + ${@bb.utils.contains("LICENSE_FLAGS_WHITELIST", "commercial", "libav", "", d)}" + +PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas," +PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft," +PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DUPDATE_PROTO_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native," +PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog," +PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype," +PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2," +PACKAGECONFIG[gstreamer] = "-DWITH_GSTREAMER=ON,-DWITH_GSTREAMER=OFF,gstreamer1.0 gstreamer1.0-plugins-base," +PACKAGECONFIG[gtk] = "-DWITH_GTK=ON,-DWITH_GTK=OFF,gtk+3," +PACKAGECONFIG[jasper] = "-DWITH_JASPER=ON,-DWITH_JASPER=OFF,jasper," +PACKAGECONFIG[java] = "-DJAVA_INCLUDE_PATH=${JAVA_HOME}/include -DJAVA_INCLUDE_PATH2=${JAVA_HOME}/include/linux -DJAVA_AWT_INCLUDE_PATH=${JAVA_HOME}/include -DJAVA_AWT_LIBRARY=${JAVA_HOME}/lib/amd64/libjawt.so -DJAVA_JVM_LIBRARY=${JAVA_HOME}/lib/amd64/server/libjvm.so,,ant-native fastjar-native openjdk-8-native," +PACKAGECONFIG[jpeg] = "-DWITH_JPEG=ON,-DWITH_JPEG=OFF,jpeg," +PACKAGECONFIG[libav] = "-DWITH_FFMPEG=ON,-DWITH_FFMPEG=OFF,libav," +PACKAGECONFIG[libv4l] = "-DWITH_LIBV4L=ON,-DWITH_LIBV4L=OFF,v4l-utils," +PACKAGECONFIG[opencl] = "-DWITH_OPENCL=ON,-DWITH_OPENCL=OFF,opencl-headers virtual/opencl-icd," +PACKAGECONFIG[oracle-java] = "-DJAVA_INCLUDE_PATH=${ORACLE_JAVA_HOME}/include -DJAVA_INCLUDE_PATH2=${ORACLE_JAVA_HOME}/include/linux -DJAVA_AWT_INCLUDE_PATH=${ORACLE_JAVA_HOME}/include -DJAVA_AWT_LIBRARY=${ORACLE_JAVA_HOME}/lib/amd64/libjawt.so -DJAVA_JVM_LIBRARY=${ORACLE_JAVA_HOME}/lib/amd64/server/libjvm.so,,ant-native oracle-jse-jdk oracle-jse-jdk-native," +PACKAGECONFIG[png] = "-DWITH_PNG=ON,-DWITH_PNG=OFF,libpng," +PACKAGECONFIG[python2] = "-DPYTHON2_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python-numpy," +PACKAGECONFIG[python3] = "-DPYTHON3_NUMPY_INCLUDE_DIRS:PATH=${STAGING_LIBDIR}/${PYTHON_DIR}/site-packages/numpy/core/include,,python3-numpy," +PACKAGECONFIG[samples] = "-DBUILD_EXAMPLES=ON -DINSTALL_PYTHON_EXAMPLES=ON,-DBUILD_EXAMPLES=OFF,," +PACKAGECONFIG[tbb] = "-DWITH_TBB=ON,-DWITH_TBB=OFF,tbb," +PACKAGECONFIG[text] = "-DBUILD_opencv_text=ON,-DBUILD_opencv_text=OFF,tesseract," +PACKAGECONFIG[tiff] = "-DWITH_TIFF=ON,-DWITH_TIFF=OFF,tiff," +PACKAGECONFIG[v4l] = "-DWITH_V4L=ON,-DWITH_V4L=OFF,v4l-utils," + +inherit pkgconfig cmake + +inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'distutils3-base', '', d)} +inherit ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'distutils-base', '', d)} + +export PYTHON_CSPEC="-I${STAGING_INCDIR}/${PYTHON_DIR}" +export PYTHON="${STAGING_BINDIR_NATIVE}/${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3', 'python', d)}" +export ORACLE_JAVA_HOME="${STAGING_DIR_NATIVE}/usr/bin/java" +export JAVA_HOME="${STAGING_DIR_NATIVE}/usr/lib/jvm/openjdk-8-native" +export ANT_DIR="${STAGING_DIR_NATIVE}/usr/share/ant/" + +TARGET_CC_ARCH += "-I${S}/include " + +PACKAGES += "${@bb.utils.contains('PACKAGECONFIG', 'samples', '${PN}-samples', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'oracle-java', '${PN}-java', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'java', '${PN}-java', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'python2', 'python-${BPN}', '', d)} \ + ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3-${BPN}', '', d)} \ + ${PN}-apps" + +python populate_packages_prepend () { + cv_libdir = d.expand('${libdir}') + do_split_packages(d, cv_libdir, '^lib(.*)\.so$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev', allow_links=True) + do_split_packages(d, cv_libdir, '^lib(.*)\.la$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') + do_split_packages(d, cv_libdir, '^lib(.*)\.a$', 'lib%s-dev', 'OpenCV %s development package', extra_depends='${PN}-dev') + do_split_packages(d, cv_libdir, '^lib(.*)\.so\.*', 'lib%s', 'OpenCV %s library', extra_depends='', allow_links=True) + + pn = d.getVar('PN') + metapkg = pn + '-dev' + d.setVar('ALLOW_EMPTY_' + metapkg, "1") + blacklist = [ metapkg ] + metapkg_rdepends = [ ] + packages = d.getVar('PACKAGES').split() + for pkg in packages[1:]: + if not pkg in blacklist and not pkg in metapkg_rdepends and pkg.endswith('-dev'): + metapkg_rdepends.append(pkg) + d.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rdepends)) + + metapkg = pn + d.setVar('ALLOW_EMPTY_' + metapkg, "1") + blacklist = [ metapkg, "libopencv-ts" ] + metapkg_rdepends = [ ] + for pkg in packages[1:]: + if not pkg in blacklist and not pkg in metapkg_rdepends and not pkg.endswith('-dev') and not pkg.endswith('-dbg') and not pkg.endswith('-doc') and not pkg.endswith('-locale') and not pkg.endswith('-staticdev'): + metapkg_rdepends.append(pkg) + d.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends)) + +} + +PACKAGES_DYNAMIC += "^libopencv-.*" + +FILES_${PN} = "" +FILES_${PN}-dbg += "${datadir}/OpenCV/java/.debug/* ${datadir}/OpenCV/samples/bin/.debug/*" +FILES_${PN}-dev = "${includedir} ${libdir}/pkgconfig ${datadir}/OpenCV/*.cmake" +FILES_${PN}-staticdev += "${datadir}/OpenCV/3rdparty/lib/*.a" +FILES_${PN}-apps = "${bindir}/* ${datadir}/OpenCV" +FILES_${PN}-java = "${datadir}/OpenCV/java" +FILES_${PN}-samples = "${datadir}/OpenCV/samples/" + +INSANE_SKIP_${PN}-java = "libdir" +INSANE_SKIP_${PN}-dbg = "libdir" + +ALLOW_EMPTY_${PN} = "1" + +SUMMARY_python-opencv = "Python bindings to opencv" +FILES_python-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" +RDEPENDS_python-opencv = "python-core python-numpy" + +SUMMARY_python3-opencv = "Python bindings to opencv" +FILES_python3-opencv = "${PYTHON_SITEPACKAGES_DIR}/*" +RDEPENDS_python3-opencv = "python3-core python3-numpy" + +do_install_append() { + cp ${S}/include/opencv/*.h ${D}${includedir}/opencv/ + sed -i '/blobtrack/d' ${D}${includedir}/opencv/cvaux.h + + # Move Python files into correct library folder (for multilib build) + if [ "$libdir" != "/usr/lib" -a -d ${D}/usr/lib ]; then + mv ${D}/usr/lib/* ${D}/${libdir}/ + rm -rf ${D}/usr/lib + fi + + if ${@bb.utils.contains("PACKAGECONFIG", "samples", "true", "false", d)}; then + install -d ${D}${datadir}/OpenCV/samples/bin/ + cp -f bin/*-tutorial-* bin/*-example-* ${D}${datadir}/OpenCV/samples/bin/ + fi +}