Open
Description
opencv version : 4.5.5
os : win10 x64
Using the detector of mcc module from this post, the network cannot detect the color checker reliable.
Codes
void test_detector_net()
{
string const model_path = "frozen_inference_graph.pb";
string const pbtxt_path = "graph.pbtxt";
cv::dnn::Net net = cv::dnn::readNetFromTensorflow(model_path, pbtxt_path);
auto image = cv::imread("rec/img-colorchecker.jpg");
int const rows = image.size[0];
int const cols = image.size[1];
net.setInput(cv::dnn::blobFromImage(image, 1.0, cv::Size(), cv::Scalar(), true));
cv::Mat output = net.forward();
Mat detectionMat(output.size[2], output.size[3], CV_32F, output.ptr<float>());
std::cout<<detectionMat.size()<<std::endl;
for(int i = 0; i < detectionMat.rows; i++){
float const confidence = detectionMat.at<float>(i, 2);
std::cout<<"confidence = "<<confidence<<std::endl;
if(confidence > 0.5f){
float xTopLeft = max(0.0f, detectionMat.at<float>(i, 3) * cols);
float yTopLeft = max(0.0f, detectionMat.at<float>(i, 4) * rows);
float xBottomRight = min((float)cols - 1, detectionMat.at<float>(i, 5) * cols);
float yBottomRight = min((float)rows - 1, detectionMat.at<float>(i, 6) * rows);
cv::Point2f const topLeft = {xTopLeft, yTopLeft};
cv::Point2f const bottomRight = {xBottomRight, yBottomRight};
cv::rectangle(image, topLeft, bottomRight, cv::Scalar(255, 0, 0), 3);
}
}
cv::resize(image, image, cv::Size(640, 1024));
imshow("image result | q or esc to quit", image);
waitKey();
}
I test with the images in the rec folder, only 000037.png work
000003.png--cannot detect anything
img-colorchecker.jpg--detect wrong object
If I lower the confidence threshold, there will have more false positive results. Do I doing something wrong?
Which dataset these models train on? Could you shared the links? I would like to train the models another detector, will shared if performance is better, thanks.