Add a row to a matrix in OpenCV

前端 未结 1 1455
Happy的楠姐
Happy的楠姐 2020-12-15 06:05

This is a very simple question but I couldn\'t find the answer in Google or in OpenCV documentation. How do you insert a row with either a vector or a default number at the

1条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 06:43

    The added element must be a Mat with the same number of columns as the container matrix:

    cv::Mat m = cv::Mat::ones(4, 3, CV_64F);    // 3 cols, 4 rows
    cv::Mat row = cv::Mat::ones(1, 3, CV_64F);  // 3 cols, 1 row
    m.push_back(row);                           // 3 cols, 5 rows
    

    0 讨论(0)
提交回复
热议问题