Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

those 4d Mat's are [nimages, nchannels, H,W]

if your blob is a 3 channel image (with seperate color planes), [1,3,24,24] you would access e.g. the 2nd channel like:

Mat green(24,24,CV_32F, blob.ptr<float>(0,1)); // image 0, channel 1

in the case of this prob blob, you can simply reshape it :

Mat flat = prob.reshape(1,1); //a single row, with nDetections columns.
Point maxLoc;
minMaxLoc(flat, 0,0,0,&maxLoc);
int predicted = maxLoc.x;

those 4d Mat's are used in cv::dnn are: [nimages, nchannels, H,W]H, W]

if your blob is a 3 channel image (with seperate color planes), [1,3,24,24] you would access e.g. the 2nd channel like:

Mat green(24,24,CV_32F, blob.ptr<float>(0,1)); // image 0, channel 1

in the case of this prob blob, you can simply reshape it :

Mat flat = prob.reshape(1,1); //a single row, with nDetections columns.
Point maxLoc;
minMaxLoc(flat, 0,0,0,&maxLoc);
int predicted = maxLoc.x;

those 4d Mat's used in cv::dnn are: [nimages, nchannels, H, W]

if your blob is a 3 channel image (with seperate color planes), [1,3,24,24] you would access e.g. the 2nd channel like:

Mat green(24,24,CV_32F, blob.ptr<float>(0,1)); // image 0, channel 1

in the case if your prob blob came from a prediction (1 of this prob blob, N classes), you can simply reshape it :

Mat flat = prob.reshape(1,1); //a single row, with nDetections columns.
Point maxLoc;
minMaxLoc(flat, 0,0,0,&maxLoc);
int predicted = maxLoc.x;

if it was from a detection,

// from the ssd_mobilenet_object_detection sample    
Mat detectionMat(detection.size[2], detection.size[3], CV_32F, detection.ptr<float>());

those 4d Mat's used in cv::dnn are: [nimages, nchannels, H, W]

if your blob is a 3 channel image (with seperate color planes), [1,3,24,24] you would access e.g. the 2nd channel like:

Mat green(24,24,CV_32F, blob.ptr<float>(0,1)); // image 0, channel 1

if your prob blob came from a prediction (1 of N classes), you can simply reshape it :

Mat flat = prob.reshape(1,1); //a single row, with nDetections columns.
Point maxLoc;
minMaxLoc(flat, 0,0,0,&maxLoc);
int predicted = maxLoc.x;

if it was from a detection,

// from the ssd_mobilenet_object_detection sample    
Mat detectionMat(detection.size[2], detection.size[3], detectionMat(prob.size[2], prob.size[3], CV_32F, detection.ptr<float>());
prob.ptr<float>());

those 4d Mat's used in cv::dnn are: [nimages, nchannels, H, W]

if your blob is a 3 channel image (with seperate color planes), [1,3,24,24] you would access e.g. the 2nd channel like:

Mat green(24,24,CV_32F, blob.ptr<float>(0,1)); // image 0, channel 1

if your prob blob came from a prediction (1 of N classes), you can simply reshape it :

Mat flat = prob.reshape(1,1); //a single row, with nDetections columns.
Point maxLoc;
minMaxLoc(flat, 0,0,0,&maxLoc);
int predicted = maxLoc.x;

if it was from a detection, (N detections a 7 numbers)

// from the ssd_mobilenet_object_detection sample    
Mat detectionMat(prob.size[2], prob.size[3], CV_32F, prob.ptr<float>());