fix: some stuf about image file name
This commit is contained in:
parent
f74c7caf10
commit
dee7199b09
@ -113,7 +113,7 @@ fn run_all() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
qualibration.run_step()?;
|
qualibration.run_step()?;
|
||||||
|
|
||||||
if qualibration.capture_mode {
|
if qualibration.capture_mode {
|
||||||
let millis = std::time::Duration::from_millis(1000); // TODO: find solution to know when change has been done
|
let millis = std::time::Duration::from_millis(300); // TODO: find solution to know when change has been done
|
||||||
std::thread::sleep(millis);
|
std::thread::sleep(millis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
pub mod annalyse;
|
pub mod annalyse;
|
||||||
pub mod borders;
|
pub mod borders;
|
||||||
|
|
||||||
|
use std::time::Instant;
|
||||||
use annalyse::{image_diff, is_same_frame};
|
use annalyse::{image_diff, is_same_frame};
|
||||||
use borders::{bord_mult, get_extermities, get_intersection, mix_borders, probabilistic_hough};
|
use borders::{bord_mult, get_extermities, get_intersection, mix_borders, probabilistic_hough};
|
||||||
use std::env::args;
|
use std::env::args;
|
||||||
@ -53,9 +54,9 @@ pub enum Sequence {
|
|||||||
RightBorder,
|
RightBorder,
|
||||||
ReadDir,
|
ReadDir,
|
||||||
ComputeArea,
|
ComputeArea,
|
||||||
|
PlayLineDotted,
|
||||||
Finish,
|
Finish,
|
||||||
|
|
||||||
WaitQ,
|
|
||||||
|
|
||||||
|
|
||||||
LinearConstSpeed, // [multiple test]
|
LinearConstSpeed, // [multiple test]
|
||||||
@ -74,6 +75,7 @@ pub enum Sequence {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Qualibration {
|
pub struct Qualibration {
|
||||||
|
pub begin: Instant,
|
||||||
pub cam: VideoCapture,
|
pub cam: VideoCapture,
|
||||||
pub r: i32,
|
pub r: i32,
|
||||||
pub g: i32,
|
pub g: i32,
|
||||||
@ -95,6 +97,7 @@ pub struct Qualibration {
|
|||||||
pub border_pt: Vec<(f64, f64)>,
|
pub border_pt: Vec<(f64, f64)>,
|
||||||
pub homography: Mat,
|
pub homography: Mat,
|
||||||
pub h_size: Size_<i32>,
|
pub h_size: Size_<i32>,
|
||||||
|
pub line_pos: Vec<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Qualibration {
|
impl Qualibration {
|
||||||
@ -113,7 +116,9 @@ impl Qualibration {
|
|||||||
let mut frame = Mat::default();
|
let mut frame = Mat::default();
|
||||||
cam.read(&mut frame)?;
|
cam.read(&mut frame)?;
|
||||||
|
|
||||||
|
//let now = std::time::Instant::now();
|
||||||
Ok(Qualibration {
|
Ok(Qualibration {
|
||||||
|
begin: std::time::Instant::now(),
|
||||||
cam,
|
cam,
|
||||||
r: 150,
|
r: 150,
|
||||||
g: 0,
|
g: 0,
|
||||||
@ -141,6 +146,7 @@ impl Qualibration {
|
|||||||
border_pt: vec![],
|
border_pt: vec![],
|
||||||
homography: Mat::default(),
|
homography: Mat::default(),
|
||||||
h_size: Size::default(),
|
h_size: Size::default(),
|
||||||
|
line_pos: vec![4095; 100],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,20 +157,13 @@ impl Qualibration {
|
|||||||
highgui::imshow("camera", &self.frame)?;
|
highgui::imshow("camera", &self.frame)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//println!(
|
|
||||||
// "frame.size:{} \tframe_prev.size:{}",
|
|
||||||
// self.frame.size()?.width,
|
|
||||||
// self.frame_prev.size()?.width
|
|
||||||
//);
|
|
||||||
if self.frame.size()?.width > 0 && self.frame_prev.size()?.width > 0 || !self.capture_mode {
|
if self.frame.size()?.width > 0 && self.frame_prev.size()?.width > 0 || !self.capture_mode {
|
||||||
//println!("plif: {}", line!());
|
|
||||||
if self.id.is_some() {
|
if self.id.is_some() {
|
||||||
// println!("plif: {}", line!());
|
|
||||||
self.id = if true {
|
self.id = if true {
|
||||||
//self.capture_mode || self.id == Some(Sequence::WaitSpace) || is_same_frame(&self.frame, &self.frame_prev)? {
|
//self.capture_mode || self.id == Some(Sequence::WaitSpace) || is_same_frame(&self.frame, &self.frame_prev)? {
|
||||||
if self.id != Some(Sequence::WaitSpace)
|
if self.id != Some(Sequence::WaitSpace)
|
||||||
&& self.id != Some(Sequence::FirstState)
|
&& self.id != Some(Sequence::FirstState)
|
||||||
|
&& self.id != Some(Sequence::PlayLineDotted)
|
||||||
&& self.capture_mode
|
&& self.capture_mode
|
||||||
{
|
{
|
||||||
self.img.push(self.frame.clone());
|
self.img.push(self.frame.clone());
|
||||||
@ -248,9 +247,29 @@ impl Qualibration {
|
|||||||
};
|
};
|
||||||
let nb_all = self.nb_all as usize;
|
let nb_all = self.nb_all as usize;
|
||||||
let nb_visible = self.nb_visible as usize;
|
let nb_visible = self.nb_visible as usize;
|
||||||
|
let nb_wait = 20;
|
||||||
|
|
||||||
if seq.is_some() {
|
if seq.is_some() {
|
||||||
match seq.unwrap() {
|
match seq.unwrap() {
|
||||||
|
Sequence::PlayLineDotted => {
|
||||||
|
// la on va faire une ligne qu'on peut observer
|
||||||
|
pl = vec![];
|
||||||
|
let black = Color{r: 0, g: 0, b: 0};
|
||||||
|
for _ in 0..nb_all {
|
||||||
|
pl.push(Point{x: 0., y: 0., color: black});
|
||||||
|
}
|
||||||
|
let len = (self.line_pos.len() + nb_wait) as f32;
|
||||||
|
for i in 0..nb_wait {
|
||||||
|
let y = i as f32 * 4095. / len;
|
||||||
|
pl.push(Point{x: 0., y, color: black});
|
||||||
|
}
|
||||||
|
for i in 0..(self.line_pos.len()) {
|
||||||
|
let y = (i + nb_wait) as f32 * 4095. / len;
|
||||||
|
let c = if (i + nb_wait) % 2 == 0 {color} else {black};
|
||||||
|
pl.push(Point{x: self.line_pos[i] as f32, y, color: c});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Sequence::WaitSpace => {
|
Sequence::WaitSpace => {
|
||||||
pl = draw::draw_line(&p0, &p1, nb_all, nb_visible)?;
|
pl = draw::draw_line(&p0, &p1, nb_all, nb_visible)?;
|
||||||
pl.extend(draw::draw_line(&p1, &p2, nb_all, nb_visible)?);
|
pl.extend(draw::draw_line(&p1, &p2, nb_all, nb_visible)?);
|
||||||
@ -320,7 +339,7 @@ impl Qualibration {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Hey");
|
//println!("Hey");
|
||||||
match self.id.unwrap() {
|
match self.id.unwrap() {
|
||||||
//Sequence::Finish => Some(Sequence::Finish),
|
//Sequence::Finish => Some(Sequence::Finish),
|
||||||
Sequence::Finish => None,
|
Sequence::Finish => None,
|
||||||
@ -341,12 +360,12 @@ impl Qualibration {
|
|||||||
Some(Sequence::WaitSpace)
|
Some(Sequence::WaitSpace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Sequence::WaitQ => {
|
Sequence::PlayLineDotted => {
|
||||||
//println!("key: {}", self.key);
|
//println!("key: {}", self.key);
|
||||||
if self.key == 113 {
|
if self.key == 32 {
|
||||||
next(&Sequence::WaitQ)
|
next(&Sequence::PlayLineDotted)
|
||||||
} else {
|
} else {
|
||||||
Some(Sequence::WaitQ)
|
Some(Sequence::PlayLineDotted)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Sequence::Vertical(n) => {
|
Sequence::Vertical(n) => {
|
||||||
@ -480,10 +499,10 @@ impl Qualibration {
|
|||||||
// on fait le nom de dossier general au cas ou
|
// on fait le nom de dossier general au cas ou
|
||||||
// on fait un nom de dossier avec le temps
|
// on fait un nom de dossier avec le temps
|
||||||
// on sauvgarde toutes les image
|
// on sauvgarde toutes les image
|
||||||
let now = std::time::Instant::now();
|
let now = self.begin;
|
||||||
let name = format!("image/");
|
let name = format!("image/");
|
||||||
create_dir(&name).unwrap_or(());
|
create_dir(&name).unwrap_or(());
|
||||||
let name = format!("image/{:0>6?}_{:0>9?}/", now.elapsed().as_millis(), now.elapsed().as_nanos());
|
let name = format!("image/{:0>6?}_{:0>9?}/", now.elapsed().as_secs(), now.elapsed().as_nanos());
|
||||||
create_dir(&name).unwrap_or(());
|
create_dir(&name).unwrap_or(());
|
||||||
//name.push_str(format!("image/{}_{}/", now.elapsed().as_secs(), now.elapsed().as_nanos()).as_str());
|
//name.push_str(format!("image/{}_{}/", now.elapsed().as_secs(), now.elapsed().as_nanos()).as_str());
|
||||||
//let name = format!("image/{now:?}/");
|
//let name = format!("image/{now:?}/");
|
||||||
|
@ -411,8 +411,29 @@ pub fn trackbar_line_segment(mem: &mut Qualibration, winname: &str) -> Result<()
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn adding_trackbar(mem: &mut Qualibration, winname: &str) -> Result<()> {
|
pub fn line_pos(mem: &mut Qualibration, winname: &str) -> Result<()> {
|
||||||
|
named_window(winname, WINDOW_AUTOSIZE)?;
|
||||||
|
highgui::move_window(winname, 20, 20)?;
|
||||||
|
let v: VecN<f64, 4> = VecN::new(0., 0., 0., 255.);
|
||||||
|
let m = Mat::new_rows_cols_with_default(1, 1024, CV_8UC3, v)?;
|
||||||
|
highgui::imshow(winname, &m)?;
|
||||||
|
|
||||||
|
for i in 0..mem.line_pos.len() {
|
||||||
|
create_trackbar(
|
||||||
|
format!("pt[{i}]:\t").as_str(),
|
||||||
|
winname,
|
||||||
|
Some(&mut mem.line_pos[i]),
|
||||||
|
4095,
|
||||||
|
None,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn adding_trackbar(mut mem: &mut Qualibration, winname: &str) -> Result<()> {
|
||||||
//println!("winname: {winname}");
|
//println!("winname: {winname}");
|
||||||
|
line_pos(&mut mem , "Play Line")?;
|
||||||
trackbar_init_param(mem, "init_param")?;
|
trackbar_init_param(mem, "init_param")?;
|
||||||
//named_window(winname, WINDOW_AUTOSIZE)?;
|
//named_window(winname, WINDOW_AUTOSIZE)?;
|
||||||
//associate_trackbar(winname, &mut mem.tresh)?;
|
//associate_trackbar(winname, &mut mem.tresh)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user