Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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;

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.)

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.)

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.)