Skip to content

Commit

Permalink
feat(model): impl opencv cap device number constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
onkoe committed May 22, 2024
1 parent 9795053 commit 3f57b30
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ impl Model {
/// Given an OpenCV camera ID and model location, creates a new model
/// instance.
pub fn new_from_camera_number(
camera_number: u8,
camera_number: i32,
model_path: &str,
) -> Result<Model, ModelError> {
todo!()
let model = Self::create_yolo_instance(model_path)?;
let camera = VideoCapture::new_def(camera_number)
.map_err(|_| ModelError::NoCaptureDeviceNumber(camera_number))?;

Ok(Self { model, camera })
}

/// Captures a new image from the camera, then looks for
Expand Down Expand Up @@ -84,7 +88,7 @@ pub enum ModelError {
#[error("The given capture device (camera) path doesn't exist: `{0}`")]
NoCaptureDevicePath(String),
#[error("The specified OpenCV capture device number has no assigned camera: `{0}`")]
NoCaptureDeviceNumber(u16),
NoCaptureDeviceNumber(i32),
#[error("The given model path doesn't exist: `{0}`")]
ModelPathDoesntExist(String),
}
Expand Down

0 comments on commit 3f57b30

Please sign in to comment.