-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fully implemented fish segmentation
- Loading branch information
Showing
2 changed files
with
67 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
use std::ffi::c_void; | ||
// use std::ffi::c_void; | ||
|
||
use opencv::core::{Mat, CV_8UC1}; | ||
use ndarray::Array2; | ||
// use opencv::core::{Mat, CV_8UC1}; | ||
// use ndarray::Array2; | ||
|
||
pub fn as_mat_u8c1_mut(array: &Array2<u8>) -> Result<Mat, opencv::Error> { | ||
// Array must be contiguous and in the standard row-major layout, or the | ||
// conversion to a `Mat` will produce a corrupted result | ||
assert!(array.is_standard_layout()); | ||
// pub fn as_mat_u8c1_mut(array: &Array2<u8>) -> Result<Mat, opencv::Error> { | ||
// // Array must be contiguous and in the standard row-major layout, or the | ||
// // conversion to a `Mat` will produce a corrupted result | ||
// assert!(array.is_standard_layout()); | ||
|
||
let (height, width) = array.dim(); | ||
let array_clone = array.clone(); | ||
unsafe { Mat::new_rows_cols_with_data_unsafe_def( | ||
height as i32, | ||
width as i32, | ||
CV_8UC1, | ||
array_clone.into_raw_vec().as_ptr() as *mut c_void, | ||
) } | ||
} | ||
// let (height, width) = array.dim(); | ||
// let array_clone = array.clone(); | ||
// unsafe { Mat::new_rows_cols_with_data_unsafe_def( | ||
// height as i32, | ||
// width as i32, | ||
// CV_8UC1, | ||
// array_clone.into_raw_vec().as_ptr() as *mut c_void, | ||
// ) } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters