Skip to content

Commit f11b3ac

Browse files
kornelskijjhbw
authored andcommitted
Pass fewer args to feature map
1 parent c7b6ba0 commit f11b3ac

5 files changed

+17
-10
lines changed

src/classifier/lab_boosted_classifier.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ impl LabBoostedClassifier {
7878
}
7979

8080
pub fn compute(&mut self, image: &ImageData) {
81-
self.feature_map
82-
.borrow_mut()
83-
.compute(image.data(), image.width(), image.height());
81+
self.feature_map.borrow_mut().compute(image);
8482
}
8583

8684
pub fn set_roi(&mut self, roi: Rectangle) {

src/classifier/surf_mlp_classifier.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,10 @@ impl SurfMlpClassifier {
233233
}
234234

235235
pub fn compute(&mut self, image: &ImageData) {
236-
(*self.feature_map)
237-
.borrow_mut()
238-
.compute(image.data(), image.width(), image.height());
236+
self.feature_map.borrow_mut().compute(image);
239237
}
240238

241239
pub fn set_roi(&mut self, roi: Rectangle) {
242-
(*self.feature_map).borrow_mut().set_roi(roi);
240+
self.feature_map.borrow_mut().set_roi(roi);
243241
}
244242
}

src/feat/lab_boosted_featmap.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// You should have received a copy of the BSD 2-Clause License along with the software.
1717
// If not, see < https://opensource.org/licenses/BSD-2-Clause>.
1818

19+
use crate::ImageData;
1920
use num;
2021
use num::integer::Integer;
2122
use num::traits::WrappingAdd;
@@ -39,7 +40,11 @@ pub struct LabBoostedFeatureMap {
3940
}
4041

4142
impl FeatureMap for LabBoostedFeatureMap {
42-
fn compute(&mut self, input: &[u8], width: u32, height: u32) {
43+
fn compute(&mut self, image: &ImageData) {
44+
let input = image.data();
45+
let width = image.width();
46+
let height = image.height();
47+
4348
if width == 0 || height == 0 {
4449
panic!(format!(
4550
"Illegal arguments: width ({}), height ({})",

src/feat/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
mod lab_boosted_featmap;
2020
mod surf_mlp_featmap;
2121

22+
use crate::ImageData;
2223
pub use self::lab_boosted_featmap::LabBoostedFeatureMap;
2324
pub use self::surf_mlp_featmap::SurfMlpFeatureMap;
2425

2526
use crate::common::Rectangle;
2627

2728
pub trait FeatureMap {
2829
fn set_roi(&mut self, roi: Rectangle);
29-
fn compute(&mut self, input: &[u8], width: u32, height: u32);
30+
fn compute(&mut self, image: &ImageData);
3031
}

src/feat/surf_mlp_featmap.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// You should have received a copy of the BSD 2-Clause License along with the software.
1717
// If not, see < https://opensource.org/licenses/BSD-2-Clause>.
1818

19+
use crate::ImageData;
1920
use crate::common::{Rectangle, Seq};
2021
use crate::feat::FeatureMap;
2122
use crate::math;
@@ -39,7 +40,11 @@ pub struct SurfMlpFeatureMap {
3940
}
4041

4142
impl FeatureMap for SurfMlpFeatureMap {
42-
fn compute(&mut self, input: &[u8], width: u32, height: u32) {
43+
fn compute(&mut self, image: &ImageData) {
44+
let input = image.data();
45+
let width = image.width();
46+
let height = image.height();
47+
4348
if width == 0 || height == 0 {
4449
panic!(format!(
4550
"Illegal arguments: width ({}), height ({})",

0 commit comments

Comments
 (0)