Skip to content

Commit 4637295

Browse files
authored
build fix (#75)
1 parent 1fd5c42 commit 4637295

29 files changed

+67
-147
lines changed

examples/calc_hist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
extern crate cv;
22

3-
use cv::*;
43
use cv::highgui::*;
54
use cv::imgcodecs::ImageReadMode;
5+
use cv::*;
66

77
fn main() {
88
////////////////////////////////

examples/camshift.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
extern crate cv;
2-
use cv::*;
32
use cv::highgui::*;
43
use cv::imgproc::*;
54
use cv::video::tracking::*;
65
use cv::videoio::*;
6+
use cv::*;
77

88
struct SelectionStatus {
99
selection: Rect,

examples/display_image.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// This resembles the OpenCV read image example code:
22
// http://docs.opencv.org/3.1.0/db/deb/tutorial_display_image.html
33
extern crate cv;
4-
use cv::*;
54
use cv::highgui::*;
65
use cv::imgcodecs::ImageReadMode;
6+
use cv::*;
77

88
fn main() {
99
let args: Vec<_> = std::env::args().collect();

examples/face_detect.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
extern crate cv;
22

3-
use cv::*;
43
use cv::highgui::*;
54
use cv::imgcodecs::*;
65
use cv::objdetect::CascadeClassifier;
6+
use cv::*;
77
use std::fs::File;
88
use std::io::Read;
99
use std::path::PathBuf;
@@ -29,14 +29,7 @@ fn main() {
2929
// we draw each of them on the image
3030
result
3131
.iter()
32-
.map(|&r| {
33-
mat.rectangle_custom(
34-
r.scale(1.2),
35-
Scalar::new(255, 255, 0, 255),
36-
10,
37-
LineType::Line8,
38-
)
39-
})
32+
.map(|&r| mat.rectangle_custom(r.scale(1.2), Scalar::new(255, 255, 0, 255), 10, LineType::Line8))
4033
.count();
4134
mat.show("window", 0).unwrap();
4235
}

examples/hog.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
extern crate cv;
22
extern crate getopts;
33

4-
use cv::*;
54
use cv::highgui::*;
65
use cv::imgcodecs::*;
76
use cv::objdetect::*;
7+
use cv::*;
88

99
#[cfg(feature = "cuda")]
1010
use cv::cuda::GpuHog as Hog;
@@ -46,9 +46,7 @@ fn run() -> Result<()> {
4646
let show = matches.opt_present("s");
4747
let measure = matches.opt_present("m");
4848

49-
let dir = matches
50-
.opt_str("d")
51-
.expect("You need to provide the directory");
49+
let dir = matches.opt_str("d").expect("You need to provide the directory");
5250

5351
if show {
5452
highgui_named_window("window", WindowFlag::Autosize).unwrap();
@@ -70,11 +68,7 @@ fn run() -> Result<()> {
7068

7169
fn run_detect_for_image<P: AsRef<Path>, OD: ObjectDetect>(detector: &mut OD, path: P, show: bool, measure: bool) {
7270
let mut buf = Vec::new();
73-
let filename = path.as_ref()
74-
.file_stem()
75-
.unwrap()
76-
.to_string_lossy()
77-
.into_owned();
71+
let filename = path.as_ref().file_stem().unwrap().to_string_lossy().into_owned();
7872
let frame_num = filename.parse::<usize>().unwrap();
7973
File::open(path).unwrap().read_to_end(&mut buf).unwrap();
8074
let mat = Mat::image_decode(&buf, ImageReadMode::Grayscale);
@@ -92,10 +86,7 @@ fn run_detect_for_image<P: AsRef<Path>, OD: ObjectDetect>(detector: &mut OD, pat
9286
}
9387

9488
if show {
95-
results
96-
.iter()
97-
.map(|&(r, _w)| mat.rectangle(r.scale(0.6)))
98-
.count();
89+
results.iter().map(|&(r, _w)| mat.rectangle(r.scale(0.6))).count();
9990
mat.show("window", 0).unwrap();
10091
}
10192
}

examples/hs_hist.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
extern crate cv;
22

3-
use cv::*;
43
use cv::highgui::*;
54
use cv::imgcodecs::ImageReadMode;
65
use cv::imgproc::ColorConversion;
6+
use cv::*;
77

88
fn main() {
99
////////////////////////////////
@@ -64,12 +64,7 @@ fn main() {
6464
let intensity = (bin_val * 255.0 / max_val) as i32;
6565
let rect = Rect::new(h * scale + 1, s * scale + 1, scale - 1, scale - 1);
6666

67-
hist_image.rectangle_custom(
68-
rect,
69-
Scalar::all(intensity),
70-
LineType::Filled as i32,
71-
LineType::Line8,
72-
);
67+
hist_image.rectangle_custom(rect, Scalar::all(intensity), LineType::Filled as i32, LineType::Line8);
7368
}
7469
}
7570

src/cuda.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
use super::core::*;
55
use super::errors::*;
66
use super::objdetect::{CSvmDetector, HogParams, ObjectDetect, SvmDetector};
7-
use ::*;
87
use failure::Error;
98
use std::ffi::CString;
109
use std::os::raw::{c_char, c_double, c_int};
1110
use std::path::Path;
11+
use *;
1212

1313
/// Opaque data struct for C/C++ cv::cuda::GpuMat bindings
1414
#[derive(Clone, Copy, Debug)]
@@ -239,11 +239,7 @@ impl GpuHog {
239239
unsafe {
240240
cv_cuda_hog_detect(self.inner, mat.inner, &mut found);
241241
}
242-
found
243-
.unpack()
244-
.into_iter()
245-
.map(|r| (r, 0f64))
246-
.collect::<Vec<_>>()
242+
found.unpack().into_iter().map(|r| (r, 0f64)).collect::<Vec<_>>()
247243
}
248244

249245
/// Detects and returns the results with confidence (scores)
@@ -409,10 +405,7 @@ impl ObjectDetect for GpuCascade {
409405
fn detect(&self, image: &Mat) -> Vec<(Rect, f64)> {
410406
let mut gpu_mat = GpuMat::default();
411407
gpu_mat.upload(image);
412-
self.detect_multiscale(&gpu_mat)
413-
.into_iter()
414-
.map(|r| (r, 0.0))
415-
.collect()
408+
self.detect_multiscale(&gpu_mat).into_iter().map(|r| (r, 0.0)).collect()
416409
}
417410
}
418411

src/features2d/descriptor_matcher.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Provide types for matching keypoint descriptors
2-
use ::*;
32
use std::os::raw::{c_char, c_int};
3+
use *;
44

55
enum CDescriptorMatcher {}
66

@@ -131,12 +131,7 @@ impl DescriptorMatcher {
131131
pub fn knn_match(&self, query_descriptors: &Mat, k: usize) -> Vec<Vec<DMatch>> {
132132
let mut matches = CVec::<CVec<DMatch>>::default();
133133
unsafe {
134-
cv_matcher_knn_match(
135-
self.value,
136-
query_descriptors.inner,
137-
k as c_int,
138-
&mut matches,
139-
);
134+
cv_matcher_knn_match(self.value, query_descriptors.inner, k as c_int, &mut matches);
140135
}
141136
matches.unpack()
142137
}

src/features2d/mser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Provide the type that encapsulates all the parameters of the MSER extraction algorithm
2-
use ::*;
32
use core::*;
43
use std::os::raw::*;
4+
use *;
55

66
enum CMSER {}
77

src/features2d/sift.rs

+3-18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Provide the type that encapsulates all the parameters of the SIFT extraction algorithm
22
use super::*;
3-
use ::*;
43
use core::*;
54
use std::os::raw::*;
5+
use *;
66

77
enum CSIFT {}
88

@@ -40,15 +40,7 @@ impl SIFT {
4040
edge_threshold: f64,
4141
sigma: f64,
4242
) -> Self {
43-
let sift = unsafe {
44-
cv_sift_new(
45-
features,
46-
octave_layers,
47-
contrast_threshold,
48-
edge_threshold,
49-
sigma,
50-
)
51-
};
43+
let sift = unsafe { cv_sift_new(features, octave_layers, contrast_threshold, edge_threshold, sigma) };
5244
SIFT { value: sift }
5345
}
5446
}
@@ -120,14 +112,7 @@ impl Feature2D for SIFT {
120112
let mut keypoints = CVec::<KeyPoint>::default();
121113
let descriptors = CMat::new();
122114
unsafe {
123-
cv_sift_detect_and_compute(
124-
self.value,
125-
image.inner,
126-
mask.inner,
127-
&mut keypoints,
128-
descriptors,
129-
false,
130-
);
115+
cv_sift_detect_and_compute(self.value, image.inner, mask.inner, &mut keypoints, descriptors, false);
131116
}
132117
(keypoints.unpack(), Mat::from_raw(descriptors))
133118
}

src/features2d/surf.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Provide the type that encapsulates all the parameters of the SURF extraction algorithm
22
use super::*;
3-
use ::*;
43
use core::*;
54
use std::os::raw::*;
5+
use *;
66

77
enum CSURF {}
88

@@ -106,14 +106,7 @@ impl Feature2D for SURF {
106106
let mut keypoints = CVec::<KeyPoint>::default();
107107
let descriptors = CMat::new();
108108
unsafe {
109-
cv_surf_detect_and_compute(
110-
self.value,
111-
image.inner,
112-
mask.inner,
113-
&mut keypoints,
114-
descriptors,
115-
false,
116-
);
109+
cv_surf_detect_and_compute(self.value, image.inner, mask.inner, &mut keypoints, descriptors, false);
117110
}
118111
(keypoints.unpack(), Mat::from_raw(descriptors))
119112
}

src/highgui.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! highgui: high-level GUI
22
use failure::Error;
3+
use mat::*;
34
use std::ffi::CString;
45
use std::mem;
56
use std::os::raw::{c_char, c_int, c_void};
67
use std::ptr;
7-
use mat::*;
88

99
extern "C" {
1010
fn cv_named_window(name: *const c_char, flags: WindowFlag);

src/imgcodecs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//! Image file reading and writing, see [OpenCV
22
//! imgcodecs](http://docs.opencv.org/3.1.0/d4/da8/group__imgcodecs.html).
33
4-
use ::*;
54
use errors::*;
5+
use failure::Error;
66
use mat::*;
77
use std::ffi::CString;
88
use std::os::raw::c_char;
99
use std::path::Path;
10-
use failure::Error;
10+
use *;
1111

1212
extern "C" {
1313
fn cv_imread(input: *const c_char, flags: ImageReadMode) -> *mut CMat;

src/imgproc.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Image processing, see [OpenCV
22
//! imgproc](http://docs.opencv.org/3.1.0/d7/dbd/group__imgproc.html).
33
4-
use super::*;
54
use super::core::*;
5+
use super::*;
66
use std::os::raw::{c_double, c_float, c_int};
77

88
// =============================================================================
@@ -120,7 +120,7 @@ pub enum HistogramComparisionMethod {
120120
/// [threshold](../struct.Mat.html#method.threshold).
121121
#[repr(C)]
122122
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
123-
#[allow(non_camel_case_types, missing_docs)]
123+
#[allow(missing_docs)]
124124
pub enum ThresholdType {
125125
Binary = 0,
126126
BinaryInv = 1,
@@ -549,10 +549,6 @@ impl Mat {
549549
}
550550

551551
fn matrix_to_vec<T, MElem: AsRef<[T]>, M: AsRef<[MElem]>>(value: M) -> Vec<*const T> {
552-
value
553-
.as_ref()
554-
.iter()
555-
.map(|x| x.as_ref().as_ptr())
556-
.collect::<Vec<_>>()
552+
value.as_ref().iter().map(|x| x.as_ref().as_ptr()).collect::<Vec<_>>()
557553
}
558554
}

src/lib.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ extern crate bytes;
2020
extern crate failure;
2121

2222
pub mod core;
23+
#[cfg(feature = "cuda")]
24+
pub mod cuda;
2325
pub mod errors;
24-
pub mod imgproc;
26+
pub mod features2d;
27+
pub mod highgui;
2528
pub mod imgcodecs;
29+
pub mod imgproc;
2630
pub mod mat;
27-
pub mod videoio;
28-
pub mod highgui;
29-
pub mod video;
3031
pub mod objdetect;
31-
pub mod features2d;
3232
pub mod text;
33-
#[cfg(feature = "cuda")]
34-
pub mod cuda;
33+
pub mod video;
34+
pub mod videoio;
3535

3636
pub use core::*;
3737
pub use mat::*;
3838

39+
use errors::*;
40+
use failure::Error;
3941
use std::ffi::{CStr, CString};
4042
use std::mem;
4143
use std::os::raw::{c_char, c_void};
4244
use std::path::Path;
43-
use failure::Error;
44-
use errors::*;
4545

4646
extern "C" {
4747
fn c_drop(value: *mut c_void);
@@ -159,9 +159,7 @@ unsafe fn unpack<T: NestedVec, U, F>(v: &CVec<T>, mut f: F) -> Vec<U>
159159
where
160160
F: FnMut(&T) -> U,
161161
{
162-
(0..v.size)
163-
.map(|i| f(&*v.array.offset(i as isize)))
164-
.collect()
162+
(0..v.size).map(|i| f(&*v.array.offset(i as isize))).collect()
165163
}
166164

167165
pub(crate) trait Unpack {
@@ -226,9 +224,7 @@ impl Unpack for CDisposableString {
226224
type Out = String;
227225

228226
fn unpack(&self) -> Self::Out {
229-
unsafe { CStr::from_ptr(self.value) }
230-
.to_string_lossy()
231-
.into_owned()
227+
unsafe { CStr::from_ptr(self.value) }.to_string_lossy().into_owned()
232228
}
233229
}
234230

0 commit comments

Comments
 (0)