diff options
| -rw-r--r-- | meta-oe/recipes-support/opencv/opencv/0001-tracking-make-opencv_dnn-dependancy-optional.patch | 243 | ||||
| -rw-r--r-- | meta-oe/recipes-support/opencv/opencv_3.2.bb | 3 |
2 files changed, 245 insertions, 1 deletions
diff --git a/meta-oe/recipes-support/opencv/opencv/0001-tracking-make-opencv_dnn-dependancy-optional.patch b/meta-oe/recipes-support/opencv/opencv/0001-tracking-make-opencv_dnn-dependancy-optional.patch new file mode 100644 index 0000000000..fba43eba75 --- /dev/null +++ b/meta-oe/recipes-support/opencv/opencv/0001-tracking-make-opencv_dnn-dependancy-optional.patch | |||
| @@ -0,0 +1,243 @@ | |||
| 1 | From 69f86025978b9bbbefa54a7248316a859773aeaf Mon Sep 17 00:00:00 2001 | ||
| 2 | From: berak <px1704@web.de> | ||
| 3 | Date: Sat, 4 Mar 2017 12:38:50 +0100 | ||
| 4 | Subject: [PATCH] tracking: make opencv_dnn dependancy optional | ||
| 5 | |||
| 6 | Upstream-status: Backport [https://github.com/opencv/opencv_contrib/commit/43925b60d392fbd01d6b0449713f010f9babe448] | ||
| 7 | Signed-off-by: Ismo Puustinen <ismo.puustinen@intel.com> | ||
| 8 | |||
| 9 | --- | ||
| 10 | modules/tracking/CMakeLists.txt | 3 +-- | ||
| 11 | modules/tracking/samples/goturnTracker.cpp | 22 +++++++++++++++++++--- | ||
| 12 | modules/tracking/samples/multiTracker_dataset.cpp | 1 + | ||
| 13 | modules/tracking/samples/tracker_dataset.cpp | 1 + | ||
| 14 | modules/tracking/src/gtrTracker.cpp | 11 ++++++++++- | ||
| 15 | modules/tracking/src/gtrTracker.hpp | 12 ++++++++---- | ||
| 16 | modules/tracking/src/gtrUtils.cpp | 6 +++--- | ||
| 17 | modules/tracking/src/gtrUtils.hpp | 5 ++--- | ||
| 18 | modules/tracking/src/tracker.cpp | 1 + | ||
| 19 | 9 files changed, 46 insertions(+), 16 deletions(-) | ||
| 20 | |||
| 21 | diff --git a/modules/tracking/CMakeLists.txt b/modules/tracking/CMakeLists.txt | ||
| 22 | index a8b3183..d27f999 100644 | ||
| 23 | --- a/modules/tracking/CMakeLists.txt | ||
| 24 | +++ b/modules/tracking/CMakeLists.txt | ||
| 25 | @@ -1,2 +1 @@ | ||
| 26 | -set(the_description "Tracking API") | ||
| 27 | -ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_dnn opencv_plot OPTIONAL opencv_datasets WRAP python) | ||
| 28 | \ No newline at end of file | ||
| 29 | +ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_plot OPTIONAL opencv_dnn opencv_datasets WRAP python) | ||
| 30 | diff --git a/modules/tracking/samples/goturnTracker.cpp b/modules/tracking/samples/goturnTracker.cpp | ||
| 31 | index 389771e..1e6632d 100644 | ||
| 32 | --- a/modules/tracking/samples/goturnTracker.cpp | ||
| 33 | +++ b/modules/tracking/samples/goturnTracker.cpp | ||
| 34 | @@ -45,6 +45,9 @@ | ||
| 35 | //1 - Train you own GOTURN model using <https://github.com/Auron-X/GOTURN_Training_Toolkit> | ||
| 36 | //2 - Download pretrained caffemodel from <https://github.com/opencv/opencv_extra> | ||
| 37 | |||
| 38 | +#include "opencv2/opencv_modules.hpp" | ||
| 39 | +#if defined(HAVE_OPENCV_DNN) && defined(HAVE_OPENCV_DATASETS) | ||
| 40 | + | ||
| 41 | #include "opencv2/datasets/track_alov.hpp" | ||
| 42 | #include <opencv2/core/utility.hpp> | ||
| 43 | #include <opencv2/tracking.hpp> | ||
| 44 | @@ -65,8 +68,8 @@ static bool startSelection = false; | ||
| 45 | Rect2d boundingBox; | ||
| 46 | |||
| 47 | static const char* keys = | ||
| 48 | -{ "{@dataset_path |true| Dataset path }" | ||
| 49 | -"{@dataset_id |1| Dataset ID }" | ||
| 50 | +{ "{@dataset_path || Dataset path }" | ||
| 51 | + "{@dataset_id |1| Dataset ID }" | ||
| 52 | }; | ||
| 53 | |||
| 54 | static void onMouse(int event, int x, int y, int, void*) | ||
| 55 | @@ -144,9 +147,14 @@ int main(int argc, char *argv[]) | ||
| 56 | Ptr<cv::datasets::TRACK_alov> dataset = TRACK_alov::create(); | ||
| 57 | dataset->load(datasetRootPath); | ||
| 58 | dataset->initDataset(datasetID); | ||
| 59 | - | ||
| 60 | //Read first frame | ||
| 61 | dataset->getNextFrame(frame); | ||
| 62 | + if (frame.empty()) | ||
| 63 | + { | ||
| 64 | + cout << "invalid dataset: " << datasetRootPath << endl; | ||
| 65 | + return -2; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | frame.copyTo(image); | ||
| 69 | rectangle(image, boundingBox, Scalar(255, 0, 0), 2, 1); | ||
| 70 | imshow("GOTURN Tracking", image); | ||
| 71 | @@ -215,3 +223,11 @@ int main(int argc, char *argv[]) | ||
| 72 | |||
| 73 | return 0; | ||
| 74 | } | ||
| 75 | + | ||
| 76 | +#else // ! HAVE_OPENCV_DNN && HAVE_OPENCV_DATASETS | ||
| 77 | +#include <opencv2/core.hpp> | ||
| 78 | +int main() { | ||
| 79 | + CV_Error(cv::Error::StsNotImplemented , "this sample needs to be built with opencv_datasets and opencv_dnn !"); | ||
| 80 | + return -1; | ||
| 81 | +} | ||
| 82 | +#endif | ||
| 83 | diff --git a/modules/tracking/samples/multiTracker_dataset.cpp b/modules/tracking/samples/multiTracker_dataset.cpp | ||
| 84 | index 2826b19..b5c27da 100644 | ||
| 85 | --- a/modules/tracking/samples/multiTracker_dataset.cpp | ||
| 86 | +++ b/modules/tracking/samples/multiTracker_dataset.cpp | ||
| 87 | @@ -234,6 +234,7 @@ int main(int argc, char *argv[]) | ||
| 88 | } | ||
| 89 | |||
| 90 | #else // ! HAVE_OPENCV_DATASETS | ||
| 91 | +#include <opencv2/core.hpp> | ||
| 92 | int main() { | ||
| 93 | CV_Error(cv::Error::StsNotImplemented , "this sample needs to be built with opencv_datasets !"); | ||
| 94 | return -1; | ||
| 95 | diff --git a/modules/tracking/samples/tracker_dataset.cpp b/modules/tracking/samples/tracker_dataset.cpp | ||
| 96 | index 8b7832a..6178105 100644 | ||
| 97 | --- a/modules/tracking/samples/tracker_dataset.cpp | ||
| 98 | +++ b/modules/tracking/samples/tracker_dataset.cpp | ||
| 99 | @@ -234,6 +234,7 @@ int main(int argc, char *argv[]) | ||
| 100 | |||
| 101 | |||
| 102 | #else // ! HAVE_OPENCV_DATASETS | ||
| 103 | +#include <opencv2/core.hpp> | ||
| 104 | int main() { | ||
| 105 | CV_Error(cv::Error::StsNotImplemented , "this sample needs to be built with opencv_datasets !"); | ||
| 106 | return -1; | ||
| 107 | diff --git a/modules/tracking/src/gtrTracker.cpp b/modules/tracking/src/gtrTracker.cpp | ||
| 108 | index 58debfd..4904f47 100644 | ||
| 109 | --- a/modules/tracking/src/gtrTracker.cpp | ||
| 110 | +++ b/modules/tracking/src/gtrTracker.cpp | ||
| 111 | @@ -38,7 +38,7 @@ | ||
| 112 | // the use of this software, even if advised of the possibility of such damage. | ||
| 113 | // | ||
| 114 | //M*/ | ||
| 115 | - | ||
| 116 | +#include "opencv2/opencv_modules.hpp" | ||
| 117 | #include "gtrTracker.hpp" | ||
| 118 | |||
| 119 | |||
| 120 | @@ -54,9 +54,16 @@ void TrackerGOTURN::Params::write(cv::FileStorage& /*fs*/) const {} | ||
| 121 | |||
| 122 | Ptr<TrackerGOTURN> TrackerGOTURN::createTracker(const TrackerGOTURN::Params ¶meters) | ||
| 123 | { | ||
| 124 | +#ifdef HAVE_OPENCV_DNN | ||
| 125 | return Ptr<gtr::TrackerGOTURNImpl>(new gtr::TrackerGOTURNImpl(parameters)); | ||
| 126 | +#else | ||
| 127 | + (void)(parameters); | ||
| 128 | + CV_ErrorNoReturn(cv::Error::StsNotImplemented , "to use GOTURN, the tracking module needs to be built with opencv_dnn !"); | ||
| 129 | +#endif | ||
| 130 | } | ||
| 131 | |||
| 132 | + | ||
| 133 | +#ifdef HAVE_OPENCV_DNN | ||
| 134 | namespace gtr | ||
| 135 | { | ||
| 136 | |||
| 137 | @@ -183,9 +190,11 @@ bool TrackerGOTURNImpl::updateImpl(const Mat& image, Rect2d& boundingBox) | ||
| 138 | //Set new model image and BB from current frame | ||
| 139 | ((TrackerGOTURNModel*)static_cast<TrackerModel*>(model))->setImage(curFrame); | ||
| 140 | ((TrackerGOTURNModel*)static_cast<TrackerModel*>(model))->setBoudingBox(curBB); | ||
| 141 | + | ||
| 142 | return true; | ||
| 143 | } | ||
| 144 | |||
| 145 | } | ||
| 146 | +#endif // OPENCV_HAVE_DNN | ||
| 147 | |||
| 148 | } | ||
| 149 | diff --git a/modules/tracking/src/gtrTracker.hpp b/modules/tracking/src/gtrTracker.hpp | ||
| 150 | index 34f2c48..21ae3d9 100644 | ||
| 151 | --- a/modules/tracking/src/gtrTracker.hpp | ||
| 152 | +++ b/modules/tracking/src/gtrTracker.hpp | ||
| 153 | @@ -45,11 +45,15 @@ | ||
| 154 | |||
| 155 | #include "precomp.hpp" | ||
| 156 | #include "opencv2/video/tracking.hpp" | ||
| 157 | -#include "opencv2/dnn.hpp" | ||
| 158 | #include "gtrUtils.hpp" | ||
| 159 | #include "opencv2/imgproc.hpp" | ||
| 160 | -#include<algorithm> | ||
| 161 | -#include<limits.h> | ||
| 162 | + | ||
| 163 | +#include <algorithm> | ||
| 164 | +#include <limits.h> | ||
| 165 | + | ||
| 166 | +#include "opencv2/opencv_modules.hpp" | ||
| 167 | +#ifdef HAVE_OPENCV_DNN | ||
| 168 | +#include "opencv2/dnn.hpp" | ||
| 169 | |||
| 170 | namespace cv | ||
| 171 | { | ||
| 172 | @@ -72,5 +76,5 @@ public: | ||
| 173 | |||
| 174 | } | ||
| 175 | } | ||
| 176 | - | ||
| 177 | +#endif | ||
| 178 | #endif | ||
| 179 | diff --git a/modules/tracking/src/gtrUtils.cpp b/modules/tracking/src/gtrUtils.cpp | ||
| 180 | index 0df1197..e80dda1 100644 | ||
| 181 | --- a/modules/tracking/src/gtrUtils.cpp | ||
| 182 | +++ b/modules/tracking/src/gtrUtils.cpp | ||
| 183 | @@ -58,7 +58,7 @@ double generateRandomLaplacian(double b, double m) | ||
| 184 | return m - b*log(n); | ||
| 185 | } | ||
| 186 | |||
| 187 | -Rect2f anno2rect(vector<Point2f> annoBB) | ||
| 188 | +Rect2f anno2rect(std::vector<Point2f> annoBB) | ||
| 189 | { | ||
| 190 | Rect2f rectBB; | ||
| 191 | rectBB.x = min(annoBB[0].x, annoBB[1].x); | ||
| 192 | @@ -69,9 +69,9 @@ Rect2f anno2rect(vector<Point2f> annoBB) | ||
| 193 | return rectBB; | ||
| 194 | } | ||
| 195 | |||
| 196 | -vector <TrainingSample> gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB) | ||
| 197 | +std::vector <TrainingSample> gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB) | ||
| 198 | { | ||
| 199 | - vector <TrainingSample> trainingSamples; | ||
| 200 | + std::vector <TrainingSample> trainingSamples; | ||
| 201 | Point2f currCenter, prevCenter; | ||
| 202 | Rect2f targetPatchRect, searchPatchRect; | ||
| 203 | Mat targetPatch, searchPatch; | ||
| 204 | diff --git a/modules/tracking/src/gtrUtils.hpp b/modules/tracking/src/gtrUtils.hpp | ||
| 205 | index 8f388be..41aad21 100644 | ||
| 206 | --- a/modules/tracking/src/gtrUtils.hpp | ||
| 207 | +++ b/modules/tracking/src/gtrUtils.hpp | ||
| 208 | @@ -4,7 +4,6 @@ | ||
| 209 | #include "precomp.hpp" | ||
| 210 | #include <vector> | ||
| 211 | #include "opencv2/highgui.hpp" | ||
| 212 | -#include <opencv2/datasets/track_alov.hpp> | ||
| 213 | |||
| 214 | namespace cv | ||
| 215 | { | ||
| 216 | @@ -50,10 +49,10 @@ struct TrainingSample | ||
| 217 | double generateRandomLaplacian(double b, double m); | ||
| 218 | |||
| 219 | //Convert ALOV300++ anno coordinates to Rectangle BB | ||
| 220 | -Rect2f anno2rect(vector<Point2f> annoBB); | ||
| 221 | +Rect2f anno2rect(std::vector<Point2f> annoBB); | ||
| 222 | |||
| 223 | //Gather samples from random video frame | ||
| 224 | -vector <TrainingSample> gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB); | ||
| 225 | +std::vector <TrainingSample> gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB); | ||
| 226 | |||
| 227 | } | ||
| 228 | } | ||
| 229 | diff --git a/modules/tracking/src/tracker.cpp b/modules/tracking/src/tracker.cpp | ||
| 230 | index 8127f2a..b96aca8 100644 | ||
| 231 | --- a/modules/tracking/src/tracker.cpp | ||
| 232 | +++ b/modules/tracking/src/tracker.cpp | ||
| 233 | @@ -112,6 +112,7 @@ Ptr<Tracker> Tracker::create( const String& trackerType ) | ||
| 234 | BOILERPLATE_CODE("TLD",TrackerTLD); | ||
| 235 | BOILERPLATE_CODE("KCF",TrackerKCF); | ||
| 236 | BOILERPLATE_CODE("GOTURN", TrackerGOTURN); | ||
| 237 | + | ||
| 238 | return Ptr<Tracker>(); | ||
| 239 | } | ||
| 240 | |||
| 241 | -- | ||
| 242 | 2.9.4 | ||
| 243 | |||
diff --git a/meta-oe/recipes-support/opencv/opencv_3.2.bb b/meta-oe/recipes-support/opencv/opencv_3.2.bb index b6db37dd8d..535c761fa5 100644 --- a/meta-oe/recipes-support/opencv/opencv_3.2.bb +++ b/meta-oe/recipes-support/opencv/opencv_3.2.bb | |||
| @@ -31,6 +31,7 @@ SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \ | |||
| 31 | file://0002-Revert-check-FP16-build-condition-correctly.patch \ | 31 | file://0002-Revert-check-FP16-build-condition-correctly.patch \ |
| 32 | file://0001-Make-opencv-ts-create-share-library-intead-of-static.patch \ | 32 | file://0001-Make-opencv-ts-create-share-library-intead-of-static.patch \ |
| 33 | file://0001-To-fix-errors-as-following.patch \ | 33 | file://0001-To-fix-errors-as-following.patch \ |
| 34 | file://0001-tracking-make-opencv_dnn-dependancy-optional.patch;patchdir=../contrib/ \ | ||
| 34 | " | 35 | " |
| 35 | 36 | ||
| 36 | PV = "3.2+git${SRCPV}" | 37 | PV = "3.2+git${SRCPV}" |
| @@ -63,7 +64,7 @@ PACKAGECONFIG ??= "python3 eigen jpeg png tiff v4l libv4l gstreamer samples tbb | |||
| 63 | 64 | ||
| 64 | PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas," | 65 | PACKAGECONFIG[amdblas] = "-DWITH_OPENCLAMDBLAS=ON,-DWITH_OPENCLAMDBLAS=OFF,libclamdblas," |
| 65 | PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft," | 66 | PACKAGECONFIG[amdfft] = "-DWITH_OPENCLAMDFFT=ON,-DWITH_OPENCLAMDFFT=OFF,libclamdfft," |
| 66 | PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DUPDATE_PROTO_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,lapack protobuf protobuf-native," | 67 | PACKAGECONFIG[dnn] = "-DBUILD_opencv_dnn=ON -DUPDATE_PROTO_FILES=ON -DBUILD_PROTOBUF=OFF,-DBUILD_opencv_dnn=OFF,protobuf protobuf-native," |
| 67 | PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog," | 68 | PACKAGECONFIG[eigen] = "-DWITH_EIGEN=ON,-DWITH_EIGEN=OFF,libeigen gflags glog," |
| 68 | PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype," | 69 | PACKAGECONFIG[freetype] = "-DBUILD_opencv_freetype=ON,-DBUILD_opencv_freetype=OFF,freetype," |
| 69 | PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2," | 70 | PACKAGECONFIG[gphoto2] = "-DWITH_GPHOTO2=ON,-DWITH_GPHOTO2=OFF,libgphoto2," |
