summaryrefslogtreecommitdiffstats
path: root/meta-oe
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe')
-rw-r--r--meta-oe/recipes-support/opencv/opencv/already-exists.patch394
-rw-r--r--meta-oe/recipes-support/opencv/opencv_3.3.bb1
2 files changed, 395 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/opencv/opencv/already-exists.patch b/meta-oe/recipes-support/opencv/opencv/already-exists.patch
new file mode 100644
index 000000000..6e24f2de8
--- /dev/null
+++ b/meta-oe/recipes-support/opencv/opencv/already-exists.patch
@@ -0,0 +1,394 @@
1From e4bf148cddf277834e57c9afeec8daff8378a655 Mon Sep 17 00:00:00 2001
2From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
3Date: Wed, 22 Nov 2017 15:27:07 +0100
4Subject: [PATCH] Fix: File already exists in database: caffe.proto
5
6Fixes error when importing python cv
7
8Upstream-status: Backport https://github.com/opencv/opencv/pull/10092
9Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
10---
11 modules/dnn/CMakeLists.txt | 6 +++---
12 modules/dnn/src/caffe/caffe_importer.cpp | 1 -
13 modules/dnn/src/caffe/caffe_io.cpp | 1 -
14 modules/dnn/src/caffe/caffe_io.hpp | 2 +-
15 modules/dnn/src/caffe/{caffe.proto => opencv-caffe.proto} | 0
16 5 files changed, 4 insertions(+), 6 deletions(-)
17 rename modules/dnn/src/caffe/{caffe.proto => opencv-caffe.proto} (100%)
18
19diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt
20index c6329a742263..8ef00ef983ff 100644
21--- a/modules/dnn/CMakeLists.txt
22+++ b/modules/dnn/CMakeLists.txt
23@@ -55,13 +55,13 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS
24
25 if(PROTOBUF_UPDATE_FILES)
26 file(GLOB proto_files src/tensorflow/*.proto)
27- list(APPEND proto_files src/caffe/caffe.proto)
28+ list(APPEND proto_files src/caffe/opencv-caffe.proto)
29 PROTOBUF_GENERATE_CPP(Protobuf_HDRS Protobuf_SRCS ${proto_files})
30 else()
31 file(GLOB fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.cc)
32 file(GLOB fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.h)
33- list(APPEND fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.cc)
34- list(APPEND fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.h)
35+ list(APPEND fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/opencv-caffe.pb.cc)
36+ list(APPEND fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/opencv-caffe.pb.h)
37 list(APPEND Protobuf_SRCS ${fw_srcs})
38 list(APPEND Protobuf_HDRS ${fw_hdrs})
39 list(APPEND Protobuf_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe)
40diff --git a/modules/dnn/src/caffe/caffe_importer.cpp b/modules/dnn/src/caffe/caffe_importer.cpp
41index c075651b95b3..2c977c84b0f4 100644
42--- a/modules/dnn/src/caffe/caffe_importer.cpp
43+++ b/modules/dnn/src/caffe/caffe_importer.cpp
44@@ -42,7 +42,6 @@
45 #include "../precomp.hpp"
46
47 #ifdef HAVE_PROTOBUF
48-#include "caffe.pb.h"
49
50 #include <iostream>
51 #include <fstream>
52diff --git a/modules/dnn/src/caffe/caffe_io.cpp b/modules/dnn/src/caffe/caffe_io.cpp
53index 0f46ea77df9a..1d3c518f1328 100644
54--- a/modules/dnn/src/caffe/caffe_io.cpp
55+++ b/modules/dnn/src/caffe/caffe_io.cpp
56@@ -99,7 +99,6 @@
57 #include <fstream>
58 #include <vector>
59
60-#include "caffe.pb.h"
61 #include "caffe_io.hpp"
62 #include "glog_emulator.hpp"
63
64diff --git a/modules/dnn/src/caffe/caffe_io.hpp b/modules/dnn/src/caffe/caffe_io.hpp
65index 09bc5709a24e..f5912c3bcec1 100644
66--- a/modules/dnn/src/caffe/caffe_io.hpp
67+++ b/modules/dnn/src/caffe/caffe_io.hpp
68@@ -91,7 +91,7 @@
69 #define __OPENCV_DNN_CAFFE_IO_HPP__
70 #ifdef HAVE_PROTOBUF
71
72-#include "caffe.pb.h"
73+#include "opencv-caffe.pb.h"
74
75 namespace cv {
76 namespace dnn {
77diff --git a/modules/dnn/src/caffe/caffe.proto b/modules/dnn/src/caffe/opencv-caffe.proto
78similarity index 100%
79rename from modules/dnn/src/caffe/caffe.proto
80rename to modules/dnn/src/caffe/opencv-caffe.proto
81diff --git a/modules/dnn/src/layers/detection_output_layer.cpp b/modules/dnn/src/layers/detection_output_layer.cpp
82index 0b72326f7e7d..f413bad5b81a 100644
83--- a/modules/dnn/src/layers/detection_output_layer.cpp
84+++ b/modules/dnn/src/layers/detection_output_layer.cpp
85@@ -44,7 +44,7 @@
86 #include "layers_common.hpp"
87 #include <float.h>
88 #include <string>
89-#include <caffe.pb.h>
90+#include <opencv-caffe.pb.h>
91
92 namespace cv
93 {
94diff --git a/modules/dnn/src/caffe/caffe_importer.cpp b/modules/dnn/src/caffe/caffe_importer.cpp
95index 2c977c84b0f4..a1827a381117 100644
96--- a/modules/dnn/src/caffe/caffe_importer.cpp
97+++ b/modules/dnn/src/caffe/caffe_importer.cpp
98@@ -78,8 +78,8 @@ static cv::String toString(const T &v)
99
100 class CaffeImporter : public Importer
101 {
102- caffe::NetParameter net;
103- caffe::NetParameter netBinary;
104+ opencvcaffe::NetParameter net;
105+ opencvcaffe::NetParameter netBinary;
106
107 public:
108
109@@ -197,7 +197,7 @@ public:
110 }
111 }
112
113- void blobShapeFromProto(const caffe::BlobProto &pbBlob, MatShape& shape)
114+ void blobShapeFromProto(const opencvcaffe::BlobProto &pbBlob, MatShape& shape)
115 {
116 shape.clear();
117 if (pbBlob.has_num() || pbBlob.has_channels() || pbBlob.has_height() || pbBlob.has_width())
118@@ -209,7 +209,7 @@ public:
119 }
120 else if (pbBlob.has_shape())
121 {
122- const caffe::BlobShape &_shape = pbBlob.shape();
123+ const opencvcaffe::BlobShape &_shape = pbBlob.shape();
124
125 for (int i = 0; i < _shape.dim_size(); i++)
126 shape.push_back((int)_shape.dim(i));
127@@ -218,7 +218,7 @@ public:
128 CV_Error(Error::StsError, "Unknown shape of input blob");
129 }
130
131- void blobFromProto(const caffe::BlobProto &pbBlob, cv::Mat &dstBlob)
132+ void blobFromProto(const opencvcaffe::BlobProto &pbBlob, cv::Mat &dstBlob)
133 {
134 MatShape shape;
135 blobShapeFromProto(pbBlob, shape);
136@@ -233,7 +233,7 @@ public:
137 dstData[i] = pbBlob.data(i);
138 }
139
140- void extractBinaryLayerParms(const caffe::LayerParameter& layer, LayerParams& layerParams)
141+ void extractBinaryLayerParms(const opencvcaffe::LayerParameter& layer, LayerParams& layerParams)
142 {
143 const std::string &name = layer.name();
144
145@@ -247,7 +247,7 @@ public:
146 if (li == netBinary.layer_size() || netBinary.layer(li).blobs_size() == 0)
147 return;
148
149- const caffe::LayerParameter &binLayer = netBinary.layer(li);
150+ const opencvcaffe::LayerParameter &binLayer = netBinary.layer(li);
151 layerParams.blobs.resize(binLayer.blobs_size());
152 for (int bi = 0; bi < binLayer.blobs_size(); bi++)
153 {
154@@ -289,7 +289,7 @@ public:
155
156 for (int li = 0; li < layersSize; li++)
157 {
158- const caffe::LayerParameter &layer = net.layer(li);
159+ const opencvcaffe::LayerParameter &layer = net.layer(li);
160 String name = layer.name();
161 String type = layer.type();
162 LayerParams layerParams;
163@@ -313,7 +313,7 @@ public:
164 addedBlobs.clear();
165 }
166
167- void addOutput(const caffe::LayerParameter &layer, int layerId, int outNum)
168+ void addOutput(const opencvcaffe::LayerParameter &layer, int layerId, int outNum)
169 {
170 const std::string &name = layer.top(outNum);
171
172diff --git a/modules/dnn/src/caffe/caffe_io.hpp b/modules/dnn/src/caffe/caffe_io.hpp
173index f5912c3bcec1..24cd5fa254eb 100644
174--- a/modules/dnn/src/caffe/caffe_io.hpp
175+++ b/modules/dnn/src/caffe/caffe_io.hpp
176@@ -98,9 +98,9 @@ namespace dnn {
177
178 // Read parameters from a file into a NetParameter proto message.
179 void ReadNetParamsFromTextFileOrDie(const char* param_file,
180- caffe::NetParameter* param);
181+ opencvcaffe::NetParameter* param);
182 void ReadNetParamsFromBinaryFileOrDie(const char* param_file,
183- caffe::NetParameter* param);
184+ opencvcaffe::NetParameter* param);
185
186 }
187 }
188diff --git a/modules/dnn/src/caffe/opencv-caffe.proto b/modules/dnn/src/caffe/opencv-caffe.proto
189index 3d23fb48ea6a..df4e1d3269ae 100644
190--- a/modules/dnn/src/caffe/opencv-caffe.proto
191+++ b/modules/dnn/src/caffe/opencv-caffe.proto
192@@ -48,7 +48,7 @@
193
194 syntax = "proto2";
195
196-package caffe;
197+package opencvcaffe;
198
199 // Specifies the shape (dimensions) of a Blob.
200 message BlobShape {
201diff --git a/modules/dnn/src/layers/detection_output_layer.cpp b/modules/dnn/src/layers/detection_output_layer.cpp
202index f413bad5b81a..832c257eebf9 100644
203--- a/modules/dnn/src/layers/detection_output_layer.cpp
204+++ b/modules/dnn/src/layers/detection_output_layer.cpp
205@@ -72,7 +72,7 @@ public:
206
207 int _backgroundLabelId;
208
209- typedef caffe::PriorBoxParameter_CodeType CodeType;
210+ typedef opencvcaffe::PriorBoxParameter_CodeType CodeType;
211 CodeType _codeType;
212
213 bool _varianceEncodedInTarget;
214@@ -85,7 +85,7 @@ public:
215 enum { _numAxes = 4 };
216 static const std::string _layerName;
217
218- typedef std::map<int, std::vector<caffe::NormalizedBBox> > LabelBBox;
219+ typedef std::map<int, std::vector<opencvcaffe::NormalizedBBox> > LabelBBox;
220
221 bool getParameterDict(const LayerParams &params,
222 const std::string &parameterName,
223@@ -131,11 +131,11 @@ public:
224 {
225 String codeTypeString = params.get<String>("code_type").toLowerCase();
226 if (codeTypeString == "corner")
227- _codeType = caffe::PriorBoxParameter_CodeType_CORNER;
228+ _codeType = opencvcaffe::PriorBoxParameter_CodeType_CORNER;
229 else if (codeTypeString == "center_size")
230- _codeType = caffe::PriorBoxParameter_CodeType_CENTER_SIZE;
231+ _codeType = opencvcaffe::PriorBoxParameter_CodeType_CENTER_SIZE;
232 else
233- _codeType = caffe::PriorBoxParameter_CodeType_CORNER;
234+ _codeType = opencvcaffe::PriorBoxParameter_CodeType_CORNER;
235 }
236
237 DetectionOutputLayerImpl(const LayerParams &params)
238@@ -215,7 +215,7 @@ public:
239 GetConfidenceScores(confidenceData, num, numPriors, _numClasses, allConfidenceScores);
240
241 // Retrieve all prior bboxes
242- std::vector<caffe::NormalizedBBox> priorBBoxes;
243+ std::vector<opencvcaffe::NormalizedBBox> priorBBoxes;
244 std::vector<std::vector<float> > priorVariances;
245 GetPriorBBoxes(priorData, numPriors, priorBBoxes, priorVariances);
246
247@@ -272,7 +272,7 @@ public:
248 for (size_t j = 0; j < indices.size(); ++j, ++count)
249 {
250 int idx = indices[j];
251- const caffe::NormalizedBBox& decode_bbox = label_bboxes->second[idx];
252+ const opencvcaffe::NormalizedBBox& decode_bbox = label_bboxes->second[idx];
253 outputsData[count * 7] = i;
254 outputsData[count * 7 + 1] = label;
255 outputsData[count * 7 + 2] = scores[idx];
256@@ -355,7 +355,7 @@ public:
257
258 // Compute bbox size
259 template<bool normalized>
260- static float BBoxSize(const caffe::NormalizedBBox& bbox)
261+ static float BBoxSize(const opencvcaffe::NormalizedBBox& bbox)
262 {
263 if (bbox.xmax() < bbox.xmin() || bbox.ymax() < bbox.ymin())
264 {
265@@ -388,10 +388,10 @@ public:
266 // Decode a bbox according to a prior bbox
267 template<bool variance_encoded_in_target>
268 static void DecodeBBox(
269- const caffe::NormalizedBBox& prior_bbox, const std::vector<float>& prior_variance,
270+ const opencvcaffe::NormalizedBBox& prior_bbox, const std::vector<float>& prior_variance,
271 const CodeType code_type,
272- const bool clip_bbox, const caffe::NormalizedBBox& bbox,
273- caffe::NormalizedBBox& decode_bbox)
274+ const bool clip_bbox, const opencvcaffe::NormalizedBBox& bbox,
275+ opencvcaffe::NormalizedBBox& decode_bbox)
276 {
277 float bbox_xmin = variance_encoded_in_target ? bbox.xmin() : prior_variance[0] * bbox.xmin();
278 float bbox_ymin = variance_encoded_in_target ? bbox.ymin() : prior_variance[1] * bbox.ymin();
279@@ -399,13 +399,13 @@ public:
280 float bbox_ymax = variance_encoded_in_target ? bbox.ymax() : prior_variance[3] * bbox.ymax();
281 switch(code_type)
282 {
283- case caffe::PriorBoxParameter_CodeType_CORNER:
284+ case opencvcaffe::PriorBoxParameter_CodeType_CORNER:
285 decode_bbox.set_xmin(prior_bbox.xmin() + bbox_xmin);
286 decode_bbox.set_ymin(prior_bbox.ymin() + bbox_ymin);
287 decode_bbox.set_xmax(prior_bbox.xmax() + bbox_xmax);
288 decode_bbox.set_ymax(prior_bbox.ymax() + bbox_ymax);
289 break;
290- case caffe::PriorBoxParameter_CodeType_CENTER_SIZE:
291+ case opencvcaffe::PriorBoxParameter_CodeType_CENTER_SIZE:
292 {
293 float prior_width = prior_bbox.xmax() - prior_bbox.xmin();
294 CV_Assert(prior_width > 0);
295@@ -431,7 +431,7 @@ public:
296 };
297 if (clip_bbox)
298 {
299- // Clip the caffe::NormalizedBBox such that the range for each corner is [0, 1]
300+ // Clip the opencvcaffe::NormalizedBBox such that the range for each corner is [0, 1]
301 decode_bbox.set_xmin(std::max(std::min(decode_bbox.xmin(), 1.f), 0.f));
302 decode_bbox.set_ymin(std::max(std::min(decode_bbox.ymin(), 1.f), 0.f));
303 decode_bbox.set_xmax(std::max(std::min(decode_bbox.xmax(), 1.f), 0.f));
304@@ -443,11 +443,11 @@ public:
305
306 // Decode a set of bboxes according to a set of prior bboxes
307 static void DecodeBBoxes(
308- const std::vector<caffe::NormalizedBBox>& prior_bboxes,
309+ const std::vector<opencvcaffe::NormalizedBBox>& prior_bboxes,
310 const std::vector<std::vector<float> >& prior_variances,
311 const CodeType code_type, const bool variance_encoded_in_target,
312- const bool clip_bbox, const std::vector<caffe::NormalizedBBox>& bboxes,
313- std::vector<caffe::NormalizedBBox>& decode_bboxes)
314+ const bool clip_bbox, const std::vector<opencvcaffe::NormalizedBBox>& bboxes,
315+ std::vector<opencvcaffe::NormalizedBBox>& decode_bboxes)
316 {
317 CV_Assert(prior_bboxes.size() == prior_variances.size());
318 CV_Assert(prior_bboxes.size() == bboxes.size());
319@@ -470,7 +470,7 @@ public:
320
321 // Decode all bboxes in a batch
322 static void DecodeBBoxesAll(const std::vector<LabelBBox>& all_loc_preds,
323- const std::vector<caffe::NormalizedBBox>& prior_bboxes,
324+ const std::vector<opencvcaffe::NormalizedBBox>& prior_bboxes,
325 const std::vector<std::vector<float> >& prior_variances,
326 const int num, const bool share_location,
327 const int num_loc_classes, const int background_label_id,
328@@ -503,10 +503,10 @@ public:
329 // Get prior bounding boxes from prior_data
330 // prior_data: 1 x 2 x num_priors * 4 x 1 blob.
331 // num_priors: number of priors.
332- // prior_bboxes: stores all the prior bboxes in the format of caffe::NormalizedBBox.
333+ // prior_bboxes: stores all the prior bboxes in the format of opencvcaffe::NormalizedBBox.
334 // prior_variances: stores all the variances needed by prior bboxes.
335 static void GetPriorBBoxes(const float* priorData, const int& numPriors,
336- std::vector<caffe::NormalizedBBox>& priorBBoxes,
337+ std::vector<opencvcaffe::NormalizedBBox>& priorBBoxes,
338 std::vector<std::vector<float> >& priorVariances)
339 {
340 priorBBoxes.clear(); priorBBoxes.resize(numPriors);
341@@ -514,7 +514,7 @@ public:
342 for (int i = 0; i < numPriors; ++i)
343 {
344 int startIdx = i * 4;
345- caffe::NormalizedBBox& bbox = priorBBoxes[i];
346+ opencvcaffe::NormalizedBBox& bbox = priorBBoxes[i];
347 bbox.set_xmin(priorData[startIdx]);
348 bbox.set_ymin(priorData[startIdx + 1]);
349 bbox.set_xmax(priorData[startIdx + 2]);
350@@ -565,7 +565,7 @@ public:
351 {
352 labelBBox[label].resize(numPredsPerClass);
353 }
354- caffe::NormalizedBBox& bbox = labelBBox[label][p];
355+ opencvcaffe::NormalizedBBox& bbox = labelBBox[label][p];
356 bbox.set_xmin(locData[startIdx + c * 4]);
357 bbox.set_ymin(locData[startIdx + c * 4 + 1]);
358 bbox.set_xmax(locData[startIdx + c * 4 + 2]);
359@@ -612,7 +612,7 @@ public:
360 // nms_threshold: a threshold used in non maximum suppression.
361 // top_k: if not -1, keep at most top_k picked indices.
362 // indices: the kept indices of bboxes after nms.
363- static void ApplyNMSFast(const std::vector<caffe::NormalizedBBox>& bboxes,
364+ static void ApplyNMSFast(const std::vector<opencvcaffe::NormalizedBBox>& bboxes,
365 const std::vector<float>& scores, const float score_threshold,
366 const float nms_threshold, const float eta, const int top_k,
367 std::vector<int>& indices)
368@@ -674,10 +674,10 @@ public:
369
370 // Compute the jaccard (intersection over union IoU) overlap between two bboxes.
371 template<bool normalized>
372- static float JaccardOverlap(const caffe::NormalizedBBox& bbox1,
373- const caffe::NormalizedBBox& bbox2)
374+ static float JaccardOverlap(const opencvcaffe::NormalizedBBox& bbox1,
375+ const opencvcaffe::NormalizedBBox& bbox2)
376 {
377- caffe::NormalizedBBox intersect_bbox;
378+ opencvcaffe::NormalizedBBox intersect_bbox;
379 if (bbox2.xmin() > bbox1.xmax() || bbox2.xmax() < bbox1.xmin() ||
380 bbox2.ymin() > bbox1.ymax() || bbox2.ymax() < bbox1.ymin())
381 {
382diff --git a/modules/dnn/src/caffe/caffe_io.cpp b/modules/dnn/src/caffe/caffe_io.cpp
383index 1d3c518f1328..3cf6e255aa60 100644
384--- a/modules/dnn/src/caffe/caffe_io.cpp
385+++ b/modules/dnn/src/caffe/caffe_io.cpp
386@@ -107,7 +107,7 @@ namespace dnn {
387
388 using std::string;
389 using std::map;
390-using namespace caffe;
391+using namespace opencvcaffe;
392 using namespace ::google::protobuf;
393 using namespace ::google::protobuf::io;
394
diff --git a/meta-oe/recipes-support/opencv/opencv_3.3.bb b/meta-oe/recipes-support/opencv/opencv_3.3.bb
index 773bfe9f7..3663d30e9 100644
--- a/meta-oe/recipes-support/opencv/opencv_3.3.bb
+++ b/meta-oe/recipes-support/opencv/opencv_3.3.bb
@@ -59,6 +59,7 @@ SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \
59 file://CVE-2017-14136.patch \ 59 file://CVE-2017-14136.patch \
60 file://javagen.patch \ 60 file://javagen.patch \
61 file://protobuf.patch \ 61 file://protobuf.patch \
62 file://already-exists.patch \
62" 63"
63PV = "3.3+git${SRCPV}" 64PV = "3.3+git${SRCPV}"
64 65