1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #10126 from alalek:dnn_issue_10125

This commit is contained in:
Alexander Alekhin
2017-11-22 18:03:51 +00:00
5 changed files with 91 additions and 82 deletions
@@ -357,6 +357,9 @@ public:
void assign(const UMat& u) const;
void assign(const Mat& m) const;
void assign(const std::vector<UMat>& v) const;
void assign(const std::vector<Mat>& v) const;
};
+76
View File
@@ -3053,6 +3053,82 @@ void _OutputArray::assign(const Mat& m) const
}
void _OutputArray::assign(const std::vector<UMat>& v) const
{
int k = kind();
if (k == STD_VECTOR_UMAT)
{
std::vector<UMat>& this_v = *(std::vector<UMat>*)obj;
CV_Assert(this_v.size() == v.size());
for (size_t i = 0; i < v.size(); i++)
{
const UMat& m = v[i];
UMat& this_m = this_v[i];
if (this_m.u != NULL && this_m.u == m.u)
continue; // same object (see dnn::Layer::forward_fallback)
m.copyTo(this_m);
}
}
else if (k == STD_VECTOR_MAT)
{
std::vector<Mat>& this_v = *(std::vector<Mat>*)obj;
CV_Assert(this_v.size() == v.size());
for (size_t i = 0; i < v.size(); i++)
{
const UMat& m = v[i];
Mat& this_m = this_v[i];
if (this_m.u != NULL && this_m.u == m.u)
continue; // same object (see dnn::Layer::forward_fallback)
m.copyTo(this_m);
}
}
else
{
CV_Error(Error::StsNotImplemented, "");
}
}
void _OutputArray::assign(const std::vector<Mat>& v) const
{
int k = kind();
if (k == STD_VECTOR_UMAT)
{
std::vector<UMat>& this_v = *(std::vector<UMat>*)obj;
CV_Assert(this_v.size() == v.size());
for (size_t i = 0; i < v.size(); i++)
{
const Mat& m = v[i];
UMat& this_m = this_v[i];
if (this_m.u != NULL && this_m.u == m.u)
continue; // same object (see dnn::Layer::forward_fallback)
m.copyTo(this_m);
}
}
else if (k == STD_VECTOR_MAT)
{
std::vector<Mat>& this_v = *(std::vector<Mat>*)obj;
CV_Assert(this_v.size() == v.size());
for (size_t i = 0; i < v.size(); i++)
{
const Mat& m = v[i];
Mat& this_m = this_v[i];
if (this_m.u != NULL && this_m.u == m.u)
continue; // same object (see dnn::Layer::forward_fallback)
m.copyTo(this_m);
}
}
else
{
CV_Error(Error::StsNotImplemented, "");
}
}
static _InputOutputArray _none;
InputOutputArray noArray() { return _none; }