Skip to content

Commit dc5f695

Browse files
gfgafntwistedfall
authored andcommitted
Refactor
1 parent 95ccdd5 commit dc5f695

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

examples/create_mask.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::{
1919

2020
const SOURCE_WINDOW: &str = "Source image";
2121

22-
#[derive(Debug, Clone, Copy)]
22+
#[derive(Debug)]
2323
enum DrawingState {
2424
Init,
2525
DrawingMarkerPoint,
@@ -143,10 +143,9 @@ fn main() {
143143
if !marker_points.is_empty() {
144144
next_frame = src.clone();
145145

146-
let pts_mat = Mat::from_slice(marker_points.as_slice()).unwrap();
147146
imgproc::polylines(
148147
&mut next_frame,
149-
&pts_mat,
148+
&Mat::from_slice(marker_points.as_slice()).unwrap(),
150149
true,
151150
Scalar::new(0., 0., 0., 0.),
152151
2,
@@ -198,8 +197,8 @@ fn main() {
198197
///
199198
/// Panics if the argument less than 0 or greater than 11.
200199
fn mouse_event_from_i32(value: i32) -> opencv::highgui::MouseEventTypes {
201-
(value.gt(&(opencv::highgui::MouseEventTypes::EVENT_MOUSEHWHEEL as i32) /* 11 */)
202-
|| (value.lt(&(opencv::highgui::MouseEventTypes::EVENT_MOUSEMOVE as i32) /* 0 */)))
200+
(value.gt(&(opencv::highgui::MouseEventTypes::EVENT_MOUSEHWHEEL as i32/* 11 */))
201+
|| (value.lt(&(opencv::highgui::MouseEventTypes::EVENT_MOUSEMOVE as i32/* 0 */))))
203202
.then(|| panic!("Invalid cv::highgui::MouseEventTypes value: {}", value));
204203

205204
// Safe because of the previous check
@@ -210,7 +209,7 @@ fn state_transform(drawing_state: DrawingState, mouse_event: highgui::MouseEvent
210209
use self::DrawingState::*;
211210
use opencv::highgui::MouseEventTypes::*;
212211

213-
match (drawing_state, mouse_event) {
212+
match (&drawing_state, mouse_event) {
214213
(Init, EVENT_LBUTTONDOWN) => DrawingMarkerPoint,
215214
(DrawingMarkerPoint, EVENT_LBUTTONUP) => DrawingMarkerPointFinished,
216215
(DrawingMarkerPointFinished, EVENT_LBUTTONDOWN) => DrawingMarkerPoint,
@@ -221,7 +220,7 @@ fn state_transform(drawing_state: DrawingState, mouse_event: highgui::MouseEvent
221220
_ => {
222221
println!(
223222
"Invalid state transition from {:?} with event {:?}",
224-
drawing_state, mouse_event
223+
&drawing_state, mouse_event
225224
);
226225
drawing_state
227226
}

0 commit comments

Comments
 (0)