Merge pull request #6911 from ilya-lavrenov:push_back
This commit is contained in:
commit
1efa7f4d27
@ -839,9 +839,9 @@ void Mat::push_back(const Mat& elems)
|
||||
bool eq = size == elems.size;
|
||||
size.p[0] = r;
|
||||
if( !eq )
|
||||
CV_Error(CV_StsUnmatchedSizes, "");
|
||||
CV_Error(CV_StsUnmatchedSizes, "Pushed vector length is not equal to matrix row length");
|
||||
if( type() != elems.type() )
|
||||
CV_Error(CV_StsUnmatchedFormats, "");
|
||||
CV_Error(CV_StsUnmatchedFormats, "Pushed vector type is not the same as matrix type");
|
||||
|
||||
if( isSubmatrix() || dataend + step.p[0]*delta > datalimit )
|
||||
reserve( std::max(r + delta, (r*3+1)/2) );
|
||||
|
@ -1520,3 +1520,21 @@ TEST(Reduce, regression_should_fail_bug_4594)
|
||||
EXPECT_NO_THROW(cv::reduce(src, dst, 0, CV_REDUCE_SUM, CV_32S));
|
||||
EXPECT_NO_THROW(cv::reduce(src, dst, 0, CV_REDUCE_AVG, CV_32S));
|
||||
}
|
||||
|
||||
TEST(Mat, push_back_vector)
|
||||
{
|
||||
cv::Mat result(1, 5, CV_32FC1);
|
||||
|
||||
std::vector<float> vec1(result.cols + 1);
|
||||
std::vector<int> vec2(result.cols);
|
||||
|
||||
EXPECT_THROW(result.push_back(vec1), cv::Exception);
|
||||
EXPECT_THROW(result.push_back(vec2), cv::Exception);
|
||||
|
||||
vec1.resize(result.cols);
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
result.push_back(cv::Mat(vec1).reshape(1, 1));
|
||||
|
||||
ASSERT_EQ(6, result.rows);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user