Compare commits
No commits in common. "dee7199b09cbd5acaa0b339df1f1cb9ac5534d60" and "e991fffdb14af8aaf9a9a957c16d2a7a267bfb90" have entirely different histories.
dee7199b09
...
e991fffdb1
@ -90,9 +90,9 @@ fn run_all() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
//let _t = framerate_handler.handle_time()?;
|
//let _t = framerate_handler.handle_time()?;
|
||||||
/////////////////
|
/////////////////
|
||||||
let key = highgui::wait_key(1)?;
|
let key = highgui::wait_key(1)?;
|
||||||
//if key != -1 {
|
if key != -1 {
|
||||||
qualibration.key = key;
|
qualibration.key = key;
|
||||||
//}
|
}
|
||||||
if key == 27 {
|
if key == 27 {
|
||||||
// esc in my case
|
// esc in my case
|
||||||
break;
|
break;
|
||||||
@ -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(300); // TODO: find solution to know when change has been done
|
let millis = std::time::Duration::from_millis(1000); // TODO: find solution to know when change has been done
|
||||||
std::thread::sleep(millis);
|
std::thread::sleep(millis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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;
|
||||||
@ -46,7 +45,6 @@ const DEBUG: bool = true;
|
|||||||
pub enum Sequence {
|
pub enum Sequence {
|
||||||
//TODO: avoir le meme nombre d'image en mode capture ET en mode replay
|
//TODO: avoir le meme nombre d'image en mode capture ET en mode replay
|
||||||
FirstState,
|
FirstState,
|
||||||
WaitSpace,
|
|
||||||
BackGround,
|
BackGround,
|
||||||
UpBorder,
|
UpBorder,
|
||||||
LeftBorder,
|
LeftBorder,
|
||||||
@ -54,9 +52,10 @@ pub enum Sequence {
|
|||||||
RightBorder,
|
RightBorder,
|
||||||
ReadDir,
|
ReadDir,
|
||||||
ComputeArea,
|
ComputeArea,
|
||||||
PlayLineDotted,
|
|
||||||
Finish,
|
Finish,
|
||||||
|
WaitSpace,
|
||||||
|
|
||||||
|
WaitQ,
|
||||||
|
|
||||||
|
|
||||||
LinearConstSpeed, // [multiple test]
|
LinearConstSpeed, // [multiple test]
|
||||||
@ -75,7 +74,6 @@ 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,
|
||||||
@ -97,7 +95,6 @@ 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 {
|
||||||
@ -116,9 +113,7 @@ 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,
|
||||||
@ -146,7 +141,6 @@ 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],
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,13 +151,20 @@ 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());
|
||||||
@ -247,29 +248,9 @@ 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)?);
|
||||||
@ -339,11 +320,11 @@ 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,
|
||||||
Sequence::SelectNbAll(n) => {
|
Sequence::SelectNbAll(mut n) => {
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
Some(Sequence::SelectNbAll(2 - 1))
|
Some(Sequence::SelectNbAll(2 - 1))
|
||||||
} else if (2 * n) > line_max as u16 {
|
} else if (2 * n) > line_max as u16 {
|
||||||
@ -354,18 +335,18 @@ impl Qualibration {
|
|||||||
}
|
}
|
||||||
Sequence::WaitSpace => {
|
Sequence::WaitSpace => {
|
||||||
//println!("key: {}", self.key);
|
//println!("key: {}", self.key);
|
||||||
if self.key == 32 || !self.capture_mode{
|
if self.key == 32 {
|
||||||
next(&Sequence::WaitSpace)
|
next(&Sequence::WaitSpace)
|
||||||
} else {
|
} else {
|
||||||
Some(Sequence::WaitSpace)
|
Some(Sequence::WaitSpace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Sequence::PlayLineDotted => {
|
Sequence::WaitQ => {
|
||||||
//println!("key: {}", self.key);
|
//println!("key: {}", self.key);
|
||||||
if self.key == 32 {
|
if self.key == 113 {
|
||||||
next(&Sequence::PlayLineDotted)
|
next(&Sequence::WaitQ)
|
||||||
} else {
|
} else {
|
||||||
Some(Sequence::PlayLineDotted)
|
Some(Sequence::WaitQ)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Sequence::Vertical(n) => {
|
Sequence::Vertical(n) => {
|
||||||
@ -499,10 +480,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 = self.begin;
|
let now = std::time::Instant::now();
|
||||||
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_secs(), now.elapsed().as_nanos());
|
let name = format!("image/{:0>6?}_{:0>9?}/", now.elapsed().as_millis(), 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:?}/");
|
||||||
@ -529,10 +510,6 @@ impl Qualibration {
|
|||||||
let d: Vec<_> = c[c.len()-1].chars().collect();
|
let d: Vec<_> = c[c.len()-1].chars().collect();
|
||||||
let e: String = d[4..d.len()-4].iter().collect();
|
let e: String = d[4..d.len()-4].iter().collect();
|
||||||
let img_id: i32 = e.parse()?;
|
let img_id: i32 = e.parse()?;
|
||||||
//println!("c: {c:?}");
|
|
||||||
//let a: Vec<_> = path.to_str().unwrap().to_string().chars().collect();
|
|
||||||
//let b: String = a[27..(a.len() - 4)].iter().collect();
|
|
||||||
//let img_id: i32 = b.parse()?;
|
|
||||||
let path = format!("{path:?}");
|
let path = format!("{path:?}");
|
||||||
let path = path[1..(path.len() - 1)].to_owned();
|
let path = path[1..(path.len() - 1)].to_owned();
|
||||||
let img: Mat = imread(&find_file(&path, false, false)?, IMREAD_COLOR)?;
|
let img: Mat = imread(&find_file(&path, false, false)?, IMREAD_COLOR)?;
|
||||||
|
@ -411,29 +411,8 @@ pub fn trackbar_line_segment(mem: &mut Qualibration, winname: &str) -> Result<()
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn line_pos(mem: &mut Qualibration, winname: &str) -> Result<()> {
|
pub fn adding_trackbar(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