How to convert unsigned int to unsigned char* in C++ ?
const uchar* ptr = (const uchar*) (edgeImage.step + row * edgeImage.step);
Definition of uchar:
typedef unsigned char uchar;
Definition of step function:
struct CV_EXPORTS MStep
{
MStep();
MStep(size_t s);
const size_t& operator[](int i) const;
size_t& operator[](int i);
operator size_t() const;
MStep& operator = (size_t s);
size_t* p;
size_t buf[2];
protected:
MStep& operator = (const MStep&);
};
MStep step;
Definition of size_t: typedef _W64 unsigned int size_t; edgeImage is a MAT type image.
Initially this code was in IplImage format. I converted image from IplImage to Mat and widthstep function to step function (equivalents).
What is the purpose of this code ? When I'm printing *ptr, the compilation props up an error. I once transformed it to this:
int temp= (edgeImage.step + row * edgeImage.step);
const uchar* ptr = (const uchar*) (&temp);
and the error went away. (I think this shows a different value than the initial case and I cant verify it because - the code is too long(StrokeWidthTransform) and it is stuck at a further step in the compilation.)
I am not sure to understand exactly what you want to achieve (apart from convert an unsigned int to an unsigned char*): convert an IplImage to Mat ?
I have done all the conversions- converting all IplImage objects to Mat objects and finding equivalent functions. I think there is a problem in this version- this kind of definition was working for IplImage objects but is not working on Mat objects. Can u help me in that conversion?
So you have some code doing something using the IplImage structure and you want to convert this bunch of code using only the Mat structure ?
widthStep seems to be the width in byte of the image plus some byte padding.
No idead about the purpose of the code:
Or maybe it was:
which just permits to go to the pixel location row*width.
But edgeImage is Mat type. I cannot use widthStep or imageData functions for that. I have used their alternatives - (edgeImage.data + row * edgeImage.step) this is working fine. Thanks.