Skip to content

Commit

Permalink
Getting path to mid point, didn't do a lot
Browse files Browse the repository at this point in the history
  • Loading branch information
arongeo committed Apr 27, 2023
1 parent 194b158 commit 270dd31
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,16 @@ pub fn spawn_video_thread(vrx: std::sync::mpsc::Receiver<crate::ThreadMsg>) -> s

// These points form a rectangle between which it is okay for the
// middle point of the detected face to take place.
let screen_boundaries = [
(screen_middle.0 - MOVEMENT_TOLERANCE, screen_middle.1 - MOVEMENT_TOLERANCE),
(screen_middle.0 + MOVEMENT_TOLERANCE, screen_middle.1 - MOVEMENT_TOLERANCE),
(screen_middle.0 - MOVEMENT_TOLERANCE, screen_middle.1 + MOVEMENT_TOLERANCE),
(screen_middle.0 + MOVEMENT_TOLERANCE, screen_middle.1 + MOVEMENT_TOLERANCE),
];
let screen_boundaries = cv::core::Rect::new(
screen_middle.0 + MOVEMENT_TOLERANCE,
screen_middle.1 - MOVEMENT_TOLERANCE,
2*MOVEMENT_TOLERANCE,
2*MOVEMENT_TOLERANCE
);

rectangle(
&mut bgra_frame,
cv::core::Rect::new(
screen_boundaries[0].0,
screen_boundaries[0].1,
2*MOVEMENT_TOLERANCE,
2*MOVEMENT_TOLERANCE
),
screen_boundaries,
cv::core::Scalar::new(0.0, 0.0, 255.0, 0.0),
2,
cv::imgproc::LINE_8,
Expand All @@ -177,7 +172,11 @@ pub fn spawn_video_thread(vrx: std::sync::mpsc::Receiver<crate::ThreadMsg>) -> s
// quite impossible to notice changes in that little amount of time.
if last_face != None {
let lface = last_face.unwrap();
let face_mid_point = (lface.x + (lface.width / 2), lface.y + (lface.height / 2));
let face_mid_point = cv::core::Point::new(lface.x + (lface.width / 2), lface.y + (lface.height / 2));

if !screen_boundaries.contains(face_mid_point) {
todo!();
}

rectangle(
&mut bgra_frame,
Expand All @@ -190,7 +189,7 @@ pub fn spawn_video_thread(vrx: std::sync::mpsc::Receiver<crate::ThreadMsg>) -> s

circle(
&mut bgra_frame,
cv::core::Point::new(face_mid_point.0, face_mid_point.1),
face_mid_point,
10,
cv::core::Scalar::new(0.0, 0.0, 255.0, 0.0),
2,
Expand Down

0 comments on commit 270dd31

Please sign in to comment.