-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Semantic conflicts in cv::InputArray for std::array, float[] and std::vector #10614
Copy link
Copy link
Open
Labels
RFCcategory: corefutureThis issue can't be fixed during restrictions of the compatibility requirementsThis issue can't be fixed during restrictions of the compatibility requirements
Milestone
Description
System information (version)
- OpenCV => master
Detailed description
While converting
std::array<float, N>std::vector<float>float[]
tocv::InputArray,
std::arrayis treated as a column vector, see here
template<typename _Tp, std::size_t _Nm> inline
_InputArray::_InputArray(const std::array<_Tp, _Nm>& arr)
{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_READ, arr.data(), Size(1, _Nm)); }Size(1,_Nm): 1 column, _Nm rows,
while float[] and std::vector<float> are treated as row vectors,
see here
template<typename _Tp> inline
_InputArray::_InputArray(const _Tp* vec, int n)
{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, vec, Size(n, 1)); }Size(n,1): n columns, 1 row,
and here
return szb == szi ? Size((int)szb, 1) : Size((int)(szb/CV_ELEM_SIZE(flags)), 1);Furthermore, when a std::vector<float> is used to
initialize a cv::Mat, it is considered as a column vector,
see here
template<typename _Tp> inline
Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)which confilcts with cv::InputArray::getMat, since it returns a row vector
when initialized with std::vector<float>.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
RFCcategory: corefutureThis issue can't be fixed during restrictions of the compatibility requirementsThis issue can't be fixed during restrictions of the compatibility requirements