|
5 | 5 | #include <cmath> |
6 | 6 | #include <vector> |
7 | 7 |
|
| 8 | +const double MSE_THRESH = 20.0; |
| 9 | +const double SSIM_THRESH = 0.998; |
| 10 | +const double FLOW_THRESH = 0.5; |
| 11 | +const double OPTICAL_FLOW_ACTIVE_THRESH = 0.5; |
8 | 12 |
|
9 | 13 | GPUFrameChangeDetector::GPUFrameChangeDetector() |
10 | | - : mse_thresh(500.0), ssim_thresh(0.99), flow_thresh(2.0), initialized(true) {} |
| 14 | + : mse_thresh(MSE_THRESH), ssim_thresh(SSIM_THRESH), flow_thresh(FLOW_THRESH), initialized(true) {} |
11 | 15 |
|
12 | 16 | static cv::Scalar mean_gpu(const cv::cuda::GpuMat& mat) { |
13 | 17 | cv::Scalar sum_val = cv::cuda::sum(mat); |
@@ -80,7 +84,7 @@ double GPUFrameChangeDetector::optical_flow_gpu(const cv::cuda::GpuMat& imgA, co |
80 | 84 | cv::cuda::cartToPolar(flow_xy[0], flow_xy[1], mag, angle, true); |
81 | 85 |
|
82 | 86 | cv::cuda::GpuMat active_mask; |
83 | | - cv::cuda::threshold(mag, active_mask, 0.5, 1.0, cv::THRESH_BINARY); |
| 87 | + cv::cuda::threshold(mag, active_mask, OPTICAL_FLOW_ACTIVE_THRESH, 1.0, cv::THRESH_BINARY); |
84 | 88 |
|
85 | 89 | cv::cuda::GpuMat active_pixels; |
86 | 90 | mag.copyTo(active_pixels, active_mask); |
@@ -108,7 +112,7 @@ GPUFrameChangeDetector::should_process_gpu_direct(const cv::cuda::GpuMat& gpu_fr |
108 | 112 | double ssim_val = simple_ssim_gpu(prev_frame_gpu, processed_curr); |
109 | 113 | double flow_val = optical_flow_gpu(prev_frame_gpu, processed_curr); |
110 | 114 |
|
111 | | - bool is_static = (mse_val < 10.0 && ssim_val > 0.995 && flow_val < 0.05); |
| 115 | + bool is_static = (mse_val < mse_thresh && ssim_val > ssim_thresh && flow_val < flow_thresh); |
112 | 116 |
|
113 | 117 | bool should_proc = !is_static; |
114 | 118 | if (should_proc) { |
|
0 commit comments