Ask Your Question

Revision history [back]

First I haven't image declaration. I have supposed this :

RNG r; Mat image(64,64,CV_32S); r.fill(image,RNG::UNIFORM,-128000,128000);

std::cout << "Float = " << image.at<float>(0,28) << ", Uchar = " << image.at<unsigned int="">(0, 28) << std::endl;

This line is not good but it depends how you compile your code. In debug there is an exception

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si ze.p[0] && (unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * cha nnels()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3) - 1))*4) & 15) == elemSize1()) in cv::Mat::at, file F:\lib\opencv\modules\ core\include\opencv2/core/mat.inl.hpp, line 894

and in release something like this happen Float = -1.#QNAN, Uchar = 4294854902

You cannot access to image data with a wrong using at type because there is some check in method at.

PS I hope I well understand your question

First I haven't image declaration. I have supposed this :

RNG r;
r;
Mat image(64,64,CV_32S);
r.fill(image,RNG::UNIFORM,-128000,128000);

image(64,64,CV_32S); r.fill(image,RNG::UNIFORM,-128000,128000);

std::cout << "Float = " << image.at<float>(0,28) << ", Uchar = " << image.at<unsigned int="">(0, int>(0, 28) << std::endl;

std::endl;

This line is not good but it depends how you compile your code. In debug there is an exception

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si ze.p[0] && (unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * cha nnels()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3) - 1))*4) & 15) == elemSize1()) in cv::Mat::at, file F:\lib\opencv\modules\ core\include\opencv2/core/mat.inl.hpp, line 894

and in release something like this happen happen

Float = -1.#QNAN, Uchar = 42948549024294854902**

You cannot access to image data with a wrong using at type because there is some check in method at.

PS I hope I well understand your question

First I haven't image declaration. I have supposed this :

RNG r; 
Mat image(64,64,CV_32S); 
r.fill(image,RNG::UNIFORM,-128000,128000);

std::cout << "Float = " << image.at<float>(0,28) << ", Uchar = " << image.at<unsigned int>(0, 28) << std::endl;

This line is not good but it depends how you compile your code. In debug there is an exception

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si ze.p[0] && (unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * cha nnels()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3) - 1))*4) & 15) == elemSize1()) in cv::Mat::at, file F:\lib\opencv\modules\ core\include\opencv2/core/mat.inl.hpp, line 894

and in release something like this happen

Float = -1.#QNAN, Uchar = 4294854902**

You cannot access to image data with a wrong using at type because there is some check in method at.at. I am not sure but I think there is no unsigned int for type only signed int exist.

PS I hope I well understand your question

First I haven't image declaration. I have supposed this :

RNG r; 
Mat image(64,64,CV_32S); 
r.fill(image,RNG::UNIFORM,-128000,128000);

std::cout << "Float = " << image.at<float>(0,28) << ", Uchar = " << image.at<unsigned int>(0, 28) << std::endl;

This line is not good but it depends how you compile your code. In debug there is an exception

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si ze.p[0] && (unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * cha nnels()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3) - 1))*4) & 15) == elemSize1()) in cv::Mat::at, file F:\lib\opencv\modules\ core\include\opencv2/core/mat.inl.hpp, line 894

and in release something like this happen

Float = -1.#QNAN, Uchar = 4294854902**4294854902

You cannot access to image data with a wrong using at type because there is some check in method at. I am not sure but I think there is no unsigned int for type only signed int exist.

PS I hope I well understand your question

First I haven't image declaration. I have supposed this :

RNG r; 
Mat image(64,64,CV_32S); 
r.fill(image,RNG::UNIFORM,-128000,128000);

std::cout << "Float = " << image.at<float>(0,28) << ", Uchar = " << image.at<unsigned int>(0, 28) << std::endl;

This line is not good but it depends how you compile your code. In debug there is an exception

OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si ze.p[0] && (unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * cha nnels()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3) - 1))*4) & 15) == elemSize1()) in cv::Mat::at, file F:\lib\opencv\modules\ core\include\opencv2/core/mat.inl.hpp, line 894

and in release something like this happen

Float = -1.#QNAN, Uchar = 4294854902

You cannot access to image data with a wrong using at type because there is some check in method at. I am not sure but I think there is is no unsigned int int for type only signed int exist.

PS I hope I well understand your question