Skip to content

Commit 31be64e

Browse files
authored
Merge pull request #3794 from vpisarev:new_dnn_engine
New dnn engine #3794 This is a companion for opencv/opencv#26056 - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
1 parent d131137 commit 31be64e

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

modules/dnn_superres/src/dnn_superres.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ class DepthToSpace CV_FINAL : public cv::dnn::Layer
2020

2121
static cv::Ptr<cv::dnn::Layer> create(cv::dnn::LayerParams& params);
2222

23-
virtual bool getMemoryShapes(const std::vector<std::vector<int> > &inputs,
23+
virtual bool getMemoryShapes(const std::vector<MatShape> &inputs_,
2424
const int,
25-
std::vector<std::vector<int> > &outputs,
26-
std::vector<std::vector<int> > &) const CV_OVERRIDE;
25+
std::vector<MatShape> &outputs_,
26+
std::vector<MatShape> &) const CV_OVERRIDE;
2727

2828
virtual void forward(cv::InputArrayOfArrays inputs_arr,
2929
cv::OutputArrayOfArrays outputs_arr,
@@ -308,39 +308,39 @@ cv::Ptr<cv::dnn::Layer> DepthToSpace::create(cv::dnn::LayerParams &params)
308308
return cv::Ptr<cv::dnn::Layer>(new DepthToSpace(params));
309309
}
310310

311-
bool DepthToSpace::getMemoryShapes(const std::vector <std::vector<int>> &inputs,
312-
const int, std::vector <std::vector<int>> &outputs, std::vector <std::vector<int>> &) const
311+
bool DepthToSpace::getMemoryShapes(const std::vector <MatShape> &inpShapes,
312+
const int, std::vector <MatShape> &outShapes, std::vector <MatShape> &) const
313313
{
314-
std::vector<int> outShape(4);
314+
MatShape outShape(4);
315315

316316
int scale;
317-
if( inputs[0][1] == 4 || inputs[0][1] == 9 || inputs[0][1] == 16 ) //Only one image channel
317+
if( inpShapes[0][1] == 4 || inpShapes[0][1] == 9 || inpShapes[0][1] == 16 ) //Only one image channel
318318
{
319-
scale = static_cast<int>(sqrt(inputs[0][1]));
319+
scale = static_cast<int>(sqrt(inpShapes[0][1]));
320320
}
321321
else // Three image channels
322322
{
323-
scale = static_cast<int>(sqrt(inputs[0][1]/3));
323+
scale = static_cast<int>(sqrt(inpShapes[0][1]/3));
324324
}
325325

326-
outShape[0] = inputs[0][0];
327-
outShape[1] = static_cast<int>(inputs[0][1] / pow(scale,2));
328-
outShape[2] = static_cast<int>(scale * inputs[0][2]);
329-
outShape[3] = static_cast<int>(scale * inputs[0][3]);
326+
outShape[0] = inpShapes[0][0];
327+
outShape[1] = static_cast<int>(inpShapes[0][1] / pow(scale,2));
328+
outShape[2] = static_cast<int>(scale * inpShapes[0][2]);
329+
outShape[3] = static_cast<int>(scale * inpShapes[0][3]);
330330

331-
outputs.assign(4, outShape);
331+
outShapes.assign(1, outShape);
332332

333333
return false;
334334
}
335335

336336
void DepthToSpace::forward(cv::InputArrayOfArrays inputs_arr, cv::OutputArrayOfArrays outputs_arr,
337337
cv::OutputArrayOfArrays)
338338
{
339-
std::vector <cv::Mat> inputs, outputs;
340-
inputs_arr.getMatVector(inputs);
341-
outputs_arr.getMatVector(outputs);
342-
cv::Mat &inp = inputs[0];
343-
cv::Mat &out = outputs[0];
339+
std::vector <cv::Mat> inputs_, outputs_;
340+
inputs_arr.getMatVector(inputs_);
341+
outputs_arr.getMatVector(outputs_);
342+
cv::Mat &inp = inputs_[0];
343+
cv::Mat &out = outputs_[0];
344344
const float *inpData = (float *) inp.data;
345345
float *outData = (float *) out.data;
346346

modules/text/src/ocr_holistic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ class OCRHolisticWordRecognizerImpl CV_FINAL : public OCRHolisticWordRecognizer
6969
size_t getClassCount()
7070
{
7171
int id = net.getLayerId("prob");
72-
dnn::MatShape inputShape;
72+
MatShape inputShape;
7373
inputShape.push_back(1);
7474
inputShape.push_back(1);
7575
inputShape.push_back(getPerceptiveField().height);
7676
inputShape.push_back(getPerceptiveField().width);
77-
vector<dnn::MatShape> inShapes, outShapes;
77+
vector<MatShape> inShapes, outShapes;
7878
net.getLayerShapes(inputShape, CV_32F, id, inShapes, outShapes);
7979
CV_Assert(outShapes.size() == 1 && outShapes[0].size() == 4);
8080
CV_Assert(outShapes[0][0] == 1 && outShapes[0][2] == 1 && outShapes[0][3] == 1);

0 commit comments

Comments
 (0)