I'm trying to detect a barcode and I would like to know if its detected with basic statistics, so I have a barcode that is detected every frame, I would like to know if its detected in 30FPS and how much is the failure in one second that is passed for example.
I wrote a simple counter and I was waiting for one second, but it seems its incorrect way of determining how much in percent is the barcode is detected for a certain distance in one second for example.
so I have 30 frames per second, and I want to determine at which frame is failed at detecting and how much is the percent for detection in one second.
while(1){
frames++;
MDetector.setDictionary(aruco::Dictionary::ARUCO);
iThresParam1 = MDetector.getParams()._thresParam1;
iThresParam2 = MDetector.getParams()._thresParam2;
MDetector.setThresholdParams(7, 7);
MDetector.setThresholdParamRange(2, 0);
if(frames >15)
{
frames = 0;
//Ok, let's detect
MDetector.detect(input,Markers,CamParam,-1);
//for each marker, draw info and its boundaries in the image
for (unsigned int i=0;i<Markers.size();i++) {
Markers[i].draw(input,cv::Scalar(0,0,255),2);
}
cv::imshow("thres", MDetector.getThresholdedImage());
}
cv::imshow("in",input);
sleep(1);
}
EDITED CODE:
clock_t this_time;
clock_t last_time;
int count = 1;
double time_counter = 0;
ArucoLib(){
this_time = clock();
last_time = this_time;
}
cv::Mat operator()(cv::Mat input)
{
this_time = clock();
time_counter += (double)(this_time - last_time);
last_time = this_time;
// 1 second
if(time_counter > (double)(1 * CLOCKS_PER_SEC))
{
time_counter -= (double)(1 * CLOCKS_PER_SEC);
count++;
if(count >15)
count = 0;
MDetector.setDictionary(aruco::Dictionary::ARUCO);
iThresParam1 = MDetector.getParams()._thresParam1;
iThresParam2 = MDetector.getParams()._thresParam2;
MDetector.setThresholdParams(7, 7);
MDetector.setThresholdParamRange(2, 0);
//Ok, let's detect
MDetector.detect(input,Markers,CamParam,-1);
//for each marker, draw info and its boundaries in the image
for (unsigned int i=0;i<Markers.size();i++) {
Markers[i].draw(input,cv::Scalar(0,0,255),2);
}
cv::imshow("thres", MDetector.getThresholdedImage());
}
cv::imshow("in",input);
return input;
}