fix: opencv compatiable
This commit is contained in:
parent
d2fe6a6fc6
commit
1bfe180153
@ -1,7 +1,6 @@
|
||||
use anyhow::{Context, Result};
|
||||
use log::{debug, error, info, warn};
|
||||
use opencv::{core, imgproc, prelude::*};
|
||||
use opencv::core::AlgorithmHint::ALGO_HINT_APPROX;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
@ -88,7 +87,7 @@ impl BrightnessDetector {
|
||||
fn update_background(&mut self, frame: &core::Mat) -> Result<()> {
|
||||
// Convert frame to grayscale
|
||||
let mut gray = core::Mat::default();
|
||||
imgproc::cvt_color(frame, &mut gray, imgproc::COLOR_BGR2GRAY, 0,ALGO_HINT_APPROX)?;
|
||||
imgproc::cvt_color(frame, &mut gray, imgproc::COLOR_BGR2GRAY, 0)?;
|
||||
match &mut self.background {
|
||||
Some(bg) => {
|
||||
// Gradually update background model (running average)
|
||||
@ -112,7 +111,7 @@ impl BrightnessDetector {
|
||||
fn compute_difference(&mut self, frame: &core::Mat) -> Result<core::Mat> {
|
||||
// Convert frame to grayscale
|
||||
let mut gray = core::Mat::default();
|
||||
imgproc::cvt_color(frame, &mut gray, imgproc::COLOR_BGR2GRAY, 0,ALGO_HINT_APPROX)?;
|
||||
imgproc::cvt_color(frame, &mut gray, imgproc::COLOR_BGR2GRAY, 0)?;
|
||||
|
||||
// Calculate absolute difference from background
|
||||
let mut diff = core::Mat::default();
|
||||
@ -161,7 +160,7 @@ impl BrightnessDetector {
|
||||
fn calculate_brightness(&self, frame: &core::Mat) -> Result<f32> {
|
||||
// Convert to grayscale
|
||||
let mut gray = core::Mat::default();
|
||||
imgproc::cvt_color(frame, &mut gray, imgproc::COLOR_BGR2GRAY, 0,ALGO_HINT_APPROX)?;
|
||||
imgproc::cvt_color(frame, &mut gray, imgproc::COLOR_BGR2GRAY, 0)?;
|
||||
|
||||
// Calculate mean brightness
|
||||
let mean = core::mean(&gray, &core::no_array())?;
|
||||
|
||||
@ -3,7 +3,6 @@ use chrono::{DateTime, Utc};
|
||||
use log::{debug, info};
|
||||
use opencv::{core, imgcodecs, prelude::*};
|
||||
use std::path::Path;
|
||||
use opencv::core::AlgorithmHint::ALGO_HINT_APPROX;
|
||||
|
||||
/// CAMS FTP format feature images
|
||||
/// Used for meteor detection analysis
|
||||
@ -148,10 +147,10 @@ impl FeatureImages {
|
||||
let mut stdpixel_color = core::Mat::default();
|
||||
let mut maxframe_color = core::Mat::default();
|
||||
|
||||
opencv::imgproc::cvt_color(&self.maxpixel, &mut maxpixel_color, opencv::imgproc::COLOR_GRAY2BGR, 0,ALGO_HINT_APPROX)?;
|
||||
opencv::imgproc::cvt_color(&self.avepixel, &mut avepixel_color, opencv::imgproc::COLOR_GRAY2BGR, 0,ALGO_HINT_APPROX)?;
|
||||
opencv::imgproc::cvt_color(&self.stdpixel, &mut stdpixel_color, opencv::imgproc::COLOR_GRAY2BGR, 0,ALGO_HINT_APPROX)?;
|
||||
opencv::imgproc::cvt_color(&self.maxframe, &mut maxframe_color, opencv::imgproc::COLOR_GRAY2BGR, 0,ALGO_HINT_APPROX)?;
|
||||
opencv::imgproc::cvt_color(&self.maxpixel, &mut maxpixel_color, opencv::imgproc::COLOR_GRAY2BGR, 0)?;
|
||||
opencv::imgproc::cvt_color(&self.avepixel, &mut avepixel_color, opencv::imgproc::COLOR_GRAY2BGR, 0)?;
|
||||
opencv::imgproc::cvt_color(&self.stdpixel, &mut stdpixel_color, opencv::imgproc::COLOR_GRAY2BGR, 0)?;
|
||||
opencv::imgproc::cvt_color(&self.maxframe, &mut maxframe_color, opencv::imgproc::COLOR_GRAY2BGR, 0)?;
|
||||
|
||||
// Create a region of interest for each quadrant
|
||||
let roi_top_left = core::Rect::new(0, 0, width, height);
|
||||
|
||||
@ -11,7 +11,6 @@ use serde::{Deserialize, Serialize};
|
||||
use std::collections::VecDeque;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use opencv::core::AlgorithmHint::ALGO_HINT_APPROX;
|
||||
use crate::camera::Frame;
|
||||
use crate::detection::feature_images::FeatureImages;
|
||||
|
||||
@ -288,7 +287,7 @@ impl FrameStacker {
|
||||
// Convert to grayscale if needed
|
||||
let gray_frame = if frame.mat.channels() != 1 {
|
||||
let mut gray = core::Mat::default();
|
||||
imgproc::cvt_color(&frame.mat, &mut gray, imgproc::COLOR_BGR2GRAY, 0,ALGO_HINT_APPROX)?;
|
||||
imgproc::cvt_color(&frame.mat, &mut gray, imgproc::COLOR_BGR2GRAY, 0)?;
|
||||
gray
|
||||
} else {
|
||||
frame.mat.clone()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user