Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

indeed, your Mat constructor:

cv::Mat rgbCV(rgb->height,rgb->width,CV_8UC4,rgb->data);

is not suitable for the dnn input, which requires CV_8UC3 (bgr vs bgra).

you have to cconvert it:

Mat img;
cvtColor(rgbCV, img, COLOR_BGRA2BGR);

before you can feed it into the dnn

indeed, your Mat constructor:

cv::Mat rgbCV(rgb->height,rgb->width,CV_8UC4,rgb->data);

is not suitable for the dnn input, which requires CV_8UC3 (bgr vs bgra).

you have to cconvert convert it:

Mat img;
cvtColor(rgbCV, img, COLOR_BGRA2BGR);

before you can feed it into the dnn

indeed, your Mat constructor:

cv::Mat rgbCV(rgb->height,rgb->width,CV_8UC4,rgb->data);

is not suitable for the dnn input, which requires CV_8UC3 (bgr vs bgra).

you have to convert it:

Mat img;
cvtColor(rgbCV, img, COLOR_BGRA2BGR);

before you can feed it into the dnn

also, the rows and cols you see in your debugger are bogus. a 2d Size cannot hold the 4 dimensions used for the dnn blobs, therefore you have to inspect the size member, like this:

mat.size[0]  // num images in the blob
mat.size[1]  // num channels (or planes)
mat.size[2]  // height
mat.size[3]  // width

indeed, your Mat constructor:

cv::Mat rgbCV(rgb->height,rgb->width,CV_8UC4,rgb->data);

is not suitable for the dnn input, which requires CV_8UC3 (bgr vs bgra).

you have to convert it:

Mat img;
cvtColor(rgbCV, img, COLOR_BGRA2BGR);

before you can feed it into the dnn

also, the rows and cols you see in your debugger are bogus. a 2d Size cannot hold the 4 dimensions used for the dnn blobs, blobs (and thus they're set to set to -1), therefore you have to inspect the size member, like this:

mat.size[0]  // num images in the blob
mat.size[1]  // num channels (or planes)
mat.size[2]  // height
mat.size[3]  // width