mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
Merge pull request #13678 from smirnov-alexey:gapi_fix_descrof_overloading
* Return vector of MetaArg instead of MatDesc and fix test with ADL check * Fix construction of vector * Change names and tests according to review Also add GAPI_EXPORTS prefix for two ostream operators
This commit is contained in:
parent
e2dbf054ac
commit
a65ccc0603
@ -133,8 +133,6 @@ static inline GMatDesc empty_gmat_desc() { return GMatDesc{-1,-1,{-1,-1}}; }
|
||||
class Mat;
|
||||
GAPI_EXPORTS GMatDesc descr_of(const cv::Mat &mat);
|
||||
GAPI_EXPORTS GMatDesc descr_of(const cv::UMat &mat);
|
||||
GAPI_EXPORTS std::vector<GMatDesc> descr_of(const std::vector<cv::Mat> &vec);
|
||||
GAPI_EXPORTS std::vector<GMatDesc> descr_of(const std::vector<cv::UMat> &vec);
|
||||
#endif // !defined(GAPI_STANDALONE)
|
||||
|
||||
/** @} */
|
||||
@ -142,10 +140,9 @@ GAPI_EXPORTS std::vector<GMatDesc> descr_of(const std::vector<cv::UMat> &vec);
|
||||
namespace gapi { namespace own {
|
||||
class Mat;
|
||||
GAPI_EXPORTS GMatDesc descr_of(const Mat &mat);
|
||||
GAPI_EXPORTS std::vector<GMatDesc> descr_of(const std::vector<Mat> &vec);
|
||||
}}//gapi::own
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const cv::GMatDesc &desc);
|
||||
GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const cv::GMatDesc &desc);
|
||||
|
||||
} // namespace cv
|
||||
|
||||
|
@ -37,7 +37,7 @@ using GMetaArg = util::variant
|
||||
, GScalarDesc
|
||||
, GArrayDesc
|
||||
>;
|
||||
std::ostream& operator<<(std::ostream& os, const GMetaArg &);
|
||||
GAPI_EXPORTS std::ostream& operator<<(std::ostream& os, const GMetaArg &);
|
||||
|
||||
using GMetaArgs = std::vector<GMetaArg>;
|
||||
|
||||
@ -61,6 +61,15 @@ namespace detail
|
||||
|
||||
} // namespace detail
|
||||
|
||||
class Mat;
|
||||
class UMat;
|
||||
GAPI_EXPORTS cv::GMetaArgs descr_of(const std::vector<cv::Mat> &vec);
|
||||
GAPI_EXPORTS cv::GMetaArgs descr_of(const std::vector<cv::UMat> &vec);
|
||||
namespace gapi { namespace own {
|
||||
class Mat;
|
||||
GAPI_EXPORTS cv::GMetaArgs descr_of(const std::vector<Mat> &vec);
|
||||
}} // namespace gapi::own
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_GAPI_GMETAARG_HPP
|
||||
|
@ -33,15 +33,19 @@ const cv::GOrigin& cv::GMat::priv() const
|
||||
return *m_priv;
|
||||
}
|
||||
|
||||
template <typename T> std::vector<cv::GMatDesc> vec_descr_of(const std::vector<T> &vec)
|
||||
{
|
||||
std::vector<cv::GMatDesc> vec_descr;
|
||||
for(auto& mat : vec){
|
||||
vec_descr.emplace_back(descr_of(mat));
|
||||
namespace{
|
||||
template <typename T> cv::GMetaArgs vec_descr_of(const std::vector<T> &vec)
|
||||
{
|
||||
cv::GMetaArgs vec_descr;
|
||||
vec_descr.reserve(vec.size());
|
||||
for(auto& mat : vec){
|
||||
vec_descr.emplace_back(descr_of(mat));
|
||||
}
|
||||
return vec_descr;
|
||||
}
|
||||
return vec_descr;
|
||||
}
|
||||
|
||||
|
||||
#if !defined(GAPI_STANDALONE)
|
||||
cv::GMatDesc cv::descr_of(const cv::Mat &mat)
|
||||
{
|
||||
@ -53,12 +57,12 @@ cv::GMatDesc cv::descr_of(const cv::UMat &mat)
|
||||
return GMatDesc{ mat.depth(), mat.channels(),{ mat.cols, mat.rows } };
|
||||
}
|
||||
|
||||
std::vector<cv::GMatDesc> cv::descr_of(const std::vector<cv::Mat> &vec)
|
||||
cv::GMetaArgs cv::descr_of(const std::vector<cv::Mat> &vec)
|
||||
{
|
||||
return vec_descr_of(vec);
|
||||
}
|
||||
|
||||
std::vector<cv::GMatDesc> cv::descr_of(const std::vector<cv::UMat> &vec)
|
||||
cv::GMetaArgs cv::descr_of(const std::vector<cv::UMat> &vec)
|
||||
{
|
||||
return vec_descr_of(vec);
|
||||
}
|
||||
@ -69,7 +73,7 @@ cv::GMatDesc cv::gapi::own::descr_of(const cv::gapi::own::Mat &mat)
|
||||
return GMatDesc{mat.depth(), mat.channels(), {mat.cols, mat.rows}};
|
||||
}
|
||||
|
||||
std::vector<cv::GMatDesc> cv::gapi::own::descr_of(const std::vector<cv::gapi::own::Mat> &vec)
|
||||
cv::GMetaArgs cv::gapi::own::descr_of(const std::vector<cv::gapi::own::Mat> &vec)
|
||||
{
|
||||
return vec_descr_of(vec);
|
||||
}
|
||||
|
@ -46,19 +46,13 @@ TEST(GAPI_MetaDesc, VecMatDesc)
|
||||
cv::Mat(240, 320, CV_8U)};
|
||||
|
||||
const auto desc1 = cv::descr_of(vec1);
|
||||
EXPECT_EQ(CV_8U, desc1[0].depth);
|
||||
EXPECT_EQ(1, desc1[0].chan);
|
||||
EXPECT_EQ(320, desc1[0].size.width);
|
||||
EXPECT_EQ(240, desc1[0].size.height);
|
||||
EXPECT_EQ((GMatDesc{CV_8U, 1, {320, 240}}), get<GMatDesc>(desc1[0]));
|
||||
|
||||
std::vector<cv::UMat> vec2 = {
|
||||
cv::UMat(480, 640, CV_8UC3)};
|
||||
|
||||
const auto desc2 = cv::descr_of(vec2);
|
||||
EXPECT_EQ(CV_8U, desc2[0].depth);
|
||||
EXPECT_EQ(3, desc2[0].chan);
|
||||
EXPECT_EQ(640, desc2[0].size.width);
|
||||
EXPECT_EQ(480, desc2[0].size.height);
|
||||
EXPECT_EQ((GMatDesc{CV_8U, 3, {640, 480}}), get<GMatDesc>(desc2[0]));
|
||||
}
|
||||
|
||||
TEST(GAPI_MetaDesc, VecOwnMatDesc)
|
||||
@ -68,15 +62,19 @@ TEST(GAPI_MetaDesc, VecOwnMatDesc)
|
||||
cv::gapi::own::Mat(480, 640, CV_8UC3, nullptr)};
|
||||
|
||||
const auto desc = cv::gapi::own::descr_of(vec);
|
||||
EXPECT_EQ(CV_8U, desc[0].depth);
|
||||
EXPECT_EQ(1, desc[0].chan);
|
||||
EXPECT_EQ(320, desc[0].size.width);
|
||||
EXPECT_EQ(240, desc[0].size.height);
|
||||
EXPECT_EQ((GMatDesc{CV_8U, 1, {320, 240}}), get<GMatDesc>(desc[0]));
|
||||
EXPECT_EQ((GMatDesc{CV_8U, 3, {640, 480}}), get<GMatDesc>(desc[1]));
|
||||
}
|
||||
|
||||
EXPECT_EQ(CV_8U, desc[1].depth);
|
||||
EXPECT_EQ(3, desc[1].chan);
|
||||
EXPECT_EQ(640, desc[1].size.width);
|
||||
EXPECT_EQ(480, desc[1].size.height);
|
||||
TEST(GAPI_MetaDesc, AdlVecOwnMatDesc)
|
||||
{
|
||||
std::vector<cv::gapi::own::Mat> vec = {
|
||||
cv::gapi::own::Mat(240, 320, CV_8U, nullptr),
|
||||
cv::gapi::own::Mat(480, 640, CV_8UC3, nullptr)};
|
||||
|
||||
const auto desc = descr_of(vec);
|
||||
EXPECT_EQ((GMatDesc{CV_8U, 1, {320, 240}}), get<GMatDesc>(desc[0]));
|
||||
EXPECT_EQ((GMatDesc{CV_8U, 3, {640, 480}}), get<GMatDesc>(desc[1]));
|
||||
}
|
||||
|
||||
TEST(GAPI_MetaDesc, Compare_Equal_MatDesc)
|
||||
|
Loading…
Reference in New Issue
Block a user