Skip to content

Commit

Permalink
fix: extract Mats from boxed refs
Browse files Browse the repository at this point in the history
  • Loading branch information
bortyr committed Aug 9, 2024
1 parent 7bf12b0 commit 62515e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions cv-convert/src/with_opencv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ where

fn try_from_cv(from: &core_cv::Point_<T>) -> Result<Self> {
let core_cv::Point_ { x, y, .. } = *from;
let mat = core_cv::Mat::from_slice(&[x, y])?;
Ok(mat)
let boxed_mat = core_cv::Mat::from_slice(&[x, y])?;
Ok(boxed_mat.into_owned())
}
}

Expand All @@ -210,8 +210,8 @@ where

fn try_from_cv(from: &core_cv::Point3_<T>) -> Result<Self> {
let core_cv::Point3_ { x, y, z, .. } = *from;
let mat = core_cv::Mat::from_slice(&[x, y, z])?;
Ok(mat)
let boxed_mat = core_cv::Mat::from_slice(&[x, y, z])?;
Ok(boxed_mat.into_owned())
}
}

Expand Down
6 changes: 3 additions & 3 deletions cv-convert/src/with_opencv_nalgebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl TryFromCv<&OpenCvPose<&core_cv::Point3d>> for geo::Isometry3<f64> {
type Error = Error;

fn try_from_cv(pose: &OpenCvPose<&core_cv::Point3d>) -> Result<Self> {
let OpenCvPose { rvec, tvec } = *pose;
let OpenCvPose { rvec, tvec.into_owned() } = *pose; // tvec is boxed_mat so .into_owned() to get mat inside
let rotation = {
let rvec_mat = {
let core_cv::Point3_ { x, y, z, .. } = *rvec;
Expand Down Expand Up @@ -273,9 +273,9 @@ where

fn try_from_cv(from: &na::Matrix<N, R, C, S>) -> Result<Self> {
let nrows = from.nrows();
let mat =
let boxed_mat =
core_cv::Mat::from_slice(from.transpose().as_slice())?.reshape(1, nrows as i32)?;
Ok(mat)
Ok(boxed_mat.into_owned())
}
}

Expand Down

0 comments on commit 62515e9

Please sign in to comment.