Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

cv::Mat assignment to Scalar

$
0
0
I am getting unexpected behavior for assigning the elements of a matrix--it seems the last element of the matrix is not assigned properly. The following is a minimum code example and output. typedef unsigned short ValueType; cv::Mat matrix; matrix.create(5, 1, CV_16U); matrix = 6; for (unsigned int idx = 0; idx < matrix.rows; idx++) { std::cout << idx << ": " << matrix.at(idx, 1) << std::endl; } Output: 0: 6 1: 6 2: 6 3: 6 4: 0 I am running this on WIndows 7, OpenCV version 2.4.10 and 2.4.11 compiled with Visual Studio 2012, 64bit. I can't imagine something like this would be a problem in OpenCV, so I'm assuming there's something else going on here. Does anyone know what it might be? It does not matter if I replace the assignment line with any of these or other variations or even using different element types in the matrix. matrix = cv::Scalar(6); matrix.setTo(6);

Viewing all articles
Browse latest Browse all 41027

Trending Articles