From 9a8992d64fdad517f96ba58ca334ff6332e2bc8b Mon Sep 17 00:00:00 2001 From: Michael Belyaev Date: Mon, 7 Oct 2024 19:35:00 +0100 Subject: [PATCH] optical flow code --- .../preprocessing/src/preprocess_optical.rs | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/localisation/preprocessing/src/preprocess_optical.rs b/lib/localisation/preprocessing/src/preprocess_optical.rs index f7d8f6b..d544508 100644 --- a/lib/localisation/preprocessing/src/preprocess_optical.rs +++ b/lib/localisation/preprocessing/src/preprocess_optical.rs @@ -1,5 +1,25 @@ -pub fn process_optical(){ - println!("hello!"); +//TODO: Implement properly! +fn main() { + let raw_optical_data = vec![vec1[1.0, 2.0], vec![3.0, 4.0], vec![5.0, 6.0]]; + let optical_data = process_optical(&raw_optical_data); + println!("{:?}", optical_data); +} + +pub fn process_optical(raw_optical_data: &Vec) -> Vec { + + let mut optical_data = Vec::with_capacity(raw_optical_data.len()); + + for i in 0..raw_optical_data.len() { + + let mut magnitude = 0.0; + + for j in 0..raw_optical_data[i].len() { + magnitude += raw_optical_data[i][j].powi(2); + } + + } + + optical_data } \ No newline at end of file