开发者

Return type of CvMat's type attribute is 1111638021 instead of 5 or 6..pointer error?

I'm having a really strange bug, and maybe it is a pointer error, but I can't see it. I have the following code...

// file scope
static CvMat *cam1_points;
const int n_boards = 2;
const int board_n = 54;

// snip

// function scope...
void initializeAndDoStuff()
{
    cam1_points = cvCreateMat(n_boards*board_n, 2, CV_32FC1);
    printf("Type: %d\n", cam1_points->type); // should be 5.  returns crazy number in title.
};

Is something going wrong somewhere? Why am I not getting the rig开发者_如何学Cht response? Type should be returning CV_32F, which qualifies to the integer 5.


type is the matrix signature which stores more than the function type. You're getting the "strange" number because it's the result of the following bitwise OR operations.

CV_MAT_MAGIC_VAL|5|CV_MAT_CONT_FLAG

So, that's how you can use type to check if your matrix belongs to a particular type, or is continuous, etc.

Note that if you use the C++ version (cv::Mat) then type would return 5.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜