@@ -14,6 +14,9 @@ void testVideo(std::string video_path, std::string gt_path, OpenCVArmorDetector
14
14
void testImgs(std::string folder_path, std::string gt_path, OpenCVArmorDetector *detector, float min_detection_rate, float max_loss_pix);
15
15
16
16
/* DETECTOR REQUIREMENTS */
17
+ // Performance requirements
18
+ #define MIN_FPS 144 // Minimum FPS required
19
+
17
20
// Pre-selected images (tighter requirements since we know an armor is present)
18
21
#define MIN_DETECTION_RATE_EASY 0.95 // 95% detection rate required
19
22
#define MIN_DETECTION_RATE_FAR_BACK 0.90 // 90% detection rate required
@@ -346,6 +349,9 @@ void testImgs(std::string folder_path, std::string gt_path, OpenCVArmorDetector
346
349
347
350
void testVideo(std::string video_path, std::string gt_path, OpenCVArmorDetector *detector, float min_detection_rate, float max_loss_pix)
348
351
{
352
+ // Start a stopwatch for performance testing
353
+ auto start = std::chrono::high_resolution_clock::now();
354
+
349
355
// Read ground truths
350
356
std::vector<std::vector<cv::Point2f>> gt;
351
357
readGT(gt_path, gt);
@@ -391,13 +397,21 @@ void testVideo(std::string video_path, std::string gt_path, OpenCVArmorDetector
391
397
frame_idx++;
392
398
}
393
399
400
+ // Stop the stopwatch
401
+ auto stop = std::chrono::high_resolution_clock::now();
402
+
394
403
// Calculate the average loss across all frames
395
404
double loss = total_loss / detector->_frame_count;
396
405
397
406
// Check detection rate and loss
398
407
double detection_rate = static_cast<double>(detector->_detected_frame) / static_cast<double>(detector->_frame_count);
399
408
EXPECT_GE(detection_rate, min_detection_rate);
400
409
EXPECT_LT(loss / detector->_frame_count, max_loss_pix);
410
+
411
+ // Check the FPS
412
+ double elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(stop - start).count();
413
+ double fps = static_cast<double>(detector->_frame_count) / (elapsed_time / 1000.0);
414
+ EXPECT_GE(fps, MIN_FPS);
401
415
}
402
416
403
417
void readGT(std::string file_path, std::vector<std::vector<cv::Point2f>> >)
0 commit comments