Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Its simple. The conversion from Mat depth 7 to 5 does not exist in opencv.

BinaryFunc func = noScale ? getConvertFunc(sdepth, ddepth) : getConvertScaleFunc(sdepth, ddepth);

This is the the function func that you see in cv_assert.

BinaryFunc getConvertFunc(int sdepth, int ddepth)
{
     return cvtTab[CV_MAT_DEPTH(ddepth)][CV_MAT_DEPTH(sdepth)];
}

This is the function that determines the function which is used for conversion. It checks the array cvtTab. (ddepth is 5, sdepth is 7)

static BinaryFunc cvtTab[][8] =
{
{
    (BinaryFunc)cvt8u, (BinaryFunc)cvt8s8u, (BinaryFunc)cvt16u8u,
    (BinaryFunc)cvt16s8u, (BinaryFunc)cvt32s8u, (BinaryFunc)cvt32f8u,
    (BinaryFunc)cvt64f8u, 0
},
{
    (BinaryFunc)cvt8u8s, (BinaryFunc)cvt8u, (BinaryFunc)cvt16u8s,
    (BinaryFunc)cvt16s8s, (BinaryFunc)cvt32s8s, (BinaryFunc)cvt32f8s,
    (BinaryFunc)cvt64f8s, 0
},
{
    (BinaryFunc)cvt8u16u, (BinaryFunc)cvt8s16u, (BinaryFunc)cvt16u,
    (BinaryFunc)cvt16s16u, (BinaryFunc)cvt32s16u, (BinaryFunc)cvt32f16u,
    (BinaryFunc)cvt64f16u, 0
},
{
    (BinaryFunc)cvt8u16s, (BinaryFunc)cvt8s16s, (BinaryFunc)cvt16u16s,
    (BinaryFunc)cvt16u, (BinaryFunc)cvt32s16s, (BinaryFunc)cvt32f16s,
    (BinaryFunc)cvt64f16s, 0
},
{
    (BinaryFunc)cvt8u32s, (BinaryFunc)cvt8s32s, (BinaryFunc)cvt16u32s,
    (BinaryFunc)cvt16s32s, (BinaryFunc)cvt32s, (BinaryFunc)cvt32f32s,
    (BinaryFunc)cvt64f32s, 0
},
{
    (BinaryFunc)cvt8u32f, (BinaryFunc)cvt8s32f, (BinaryFunc)cvt16u32f,
    (BinaryFunc)cvt16s32f, (BinaryFunc)cvt32s32f, (BinaryFunc)cvt32s,
    (BinaryFunc)cvt64f32f, 0
},
{
    (BinaryFunc)cvt8u64f, (BinaryFunc)cvt8s64f, (BinaryFunc)cvt16u64f,
    (BinaryFunc)cvt16s64f, (BinaryFunc)cvt32s64f, (BinaryFunc)cvt32f64f,
    (BinaryFunc)cvt64s, 0
},
{
    0, 0, 0, 0, 0, 0, 0, 0
}
};

So, as you can see cvtTab[5][7] is 0, so cv_assert will fail. Depth 7 is CV_USRTYPE1. I dont exactly know what usrtype1 is, but I guess it means a custom Mat type. So opencv cant handle the conversion since it does not exactly know the type.

Its simple. The conversion from Mat depth 7 to 5 does not exist in opencv.

BinaryFunc func = noScale ? getConvertFunc(sdepth, ddepth) : getConvertScaleFunc(sdepth, ddepth);

This is the the function func that you see in cv_assert.

BinaryFunc getConvertFunc(int sdepth, int ddepth)
{
     return cvtTab[CV_MAT_DEPTH(ddepth)][CV_MAT_DEPTH(sdepth)];
}

This is the function that determines the function which is used for conversion. It checks the array cvtTab. (ddepth is 5, sdepth is 7)

static BinaryFunc cvtTab[][8] =
{
{
    (BinaryFunc)cvt8u, (BinaryFunc)cvt8s8u, (BinaryFunc)cvt16u8u,
    (BinaryFunc)cvt16s8u, (BinaryFunc)cvt32s8u, (BinaryFunc)cvt32f8u,
    (BinaryFunc)cvt64f8u, 0
},
{
    (BinaryFunc)cvt8u8s, (BinaryFunc)cvt8u, (BinaryFunc)cvt16u8s,
    (BinaryFunc)cvt16s8s, (BinaryFunc)cvt32s8s, (BinaryFunc)cvt32f8s,
    (BinaryFunc)cvt64f8s, 0
},
{
    (BinaryFunc)cvt8u16u, (BinaryFunc)cvt8s16u, (BinaryFunc)cvt16u,
    (BinaryFunc)cvt16s16u, (BinaryFunc)cvt32s16u, (BinaryFunc)cvt32f16u,
    (BinaryFunc)cvt64f16u, 0
},
{
    (BinaryFunc)cvt8u16s, (BinaryFunc)cvt8s16s, (BinaryFunc)cvt16u16s,
    (BinaryFunc)cvt16u, (BinaryFunc)cvt32s16s, (BinaryFunc)cvt32f16s,
    (BinaryFunc)cvt64f16s, 0
},
{
    (BinaryFunc)cvt8u32s, (BinaryFunc)cvt8s32s, (BinaryFunc)cvt16u32s,
    (BinaryFunc)cvt16s32s, (BinaryFunc)cvt32s, (BinaryFunc)cvt32f32s,
    (BinaryFunc)cvt64f32s, 0
},
{
    (BinaryFunc)cvt8u32f, (BinaryFunc)cvt8s32f, (BinaryFunc)cvt16u32f,
    (BinaryFunc)cvt16s32f, (BinaryFunc)cvt32s32f, (BinaryFunc)cvt32s,
    (BinaryFunc)cvt64f32f, 0
},
{
    (BinaryFunc)cvt8u64f, (BinaryFunc)cvt8s64f, (BinaryFunc)cvt16u64f,
    (BinaryFunc)cvt16s64f, (BinaryFunc)cvt32s64f, (BinaryFunc)cvt32f64f,
    (BinaryFunc)cvt64s, 0
},
{
    0, 0, 0, 0, 0, 0, 0, 0
}
};

So, as As you can see cvtTab[5][7] is 0, so cv_assert will fail. Depth 7 is CV_USRTYPE1. I dont exactly know what usrtype1 is, but I guess it means a custom Mat type. So opencv cant handle the conversion since it does not exactly know the type.