You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when create new Mat with multi-channels(i.e., 8) with the particular value(i.e. 0.9), it will raise error (error: (-215:Assertion failed) cn <= 4 in function 'scalarToRawData')
#25575
Open
2 of 4 tasks
destinyzs opened this issue
May 13, 2024
· 2 comments
In the comment of cv::Mat::Mat and setTo, both of them seem to use Mat::operator=(const Scalar& s) operator to rewrite the value of the given Mat.
/** @overload
@param rows Number of rows in a 2D array.
@param cols Number of columns in a 2D array.
@param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or
CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
@param s An optional value to initialize each matrix element with. To set all the matrix elements to
the particular value after the construction, use the assignment operator
Mat::operator=(const Scalar& value) .
*/
Mat(int rows, int cols, int type, const Scalar& s);
cv::Mat &cv::Mat::setTo(cv::InputArray value, cv::InputArray mask = noArray())
Sets all or some of the array elements to the specified value. This is an advanced variant of the Mat::operator=(const Scalar& s) operator.
System Information
OpenCV version: 4.1.0
Operating System / Platform: Ubuntu 20.04
Detailed description
None
Steps to reproduce
It will raise error:
But, if i create it like this, it success.
Issue submission checklist
The text was updated successfully, but these errors were encountered: