l1npengtul / nokhwa

Cross Platform Rust Library for Powerful Webcam/Camera Capture
Apache License 2.0
509 stars 131 forks source link

Build fails on multiple versions on Pop_OS! #170

Open Remi-Godin opened 5 months ago

Remi-Godin commented 5 months ago

Trying to run the example from the README and getting these errors:

error[E0308]: mismatched types
   --> /home/regodin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nokhwa-core-0.1.2/src/traits.rs:230:32
    |
230 |                 bytes_per_row: width_nonzero,
    |                                ^^^^^^^^^^^^^ expected `Option<u32>`, found `u32`
    |
    = note: expected enum `Option<u32>`
               found type `u32`
help: try wrapping the expression in `Some`
    |
230 |                 bytes_per_row: Some(width_nonzero),
    |                                +++++             +

error[E0308]: mismatched types
   --> /home/regodin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nokhwa-core-0.1.2/src/traits.rs:231:33
    |
231 |                 rows_per_image: height_nonzero,
    |                                 ^^^^^^^^^^^^^^ expected `Option<u32>`, found `u32`
    |
    = note: expected enum `Option<u32>`
               found type `u32`
help: try wrapping the expression in `Some`
    |
231 |                 rows_per_image: Some(height_nonzero),
    |                                 +++++              +

Same things happens on version 0.10.3.

Tried using the repo as the source, get even more errors:

error[E0412]: cannot find type `NokhwaError` in this scope
   --> /home/regodin/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/1433938/nokhwa-core/src/buffer.rs:176:32
    |
176 |     ) -> Result<wgpu::Texture, NokhwaError> {
    |                                ^^^^^^^^^^^ not found in this scope
    |
help: consider importing this enum
    |
17  + use crate::error::NokhwaError;
    |

error[E0412]: cannot find type `RgbAFormat` in this scope
   --> /home/regodin/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/1433938/nokhwa-core/src/buffer.rs:177:50
    |
177 |         let frame = self.frame()?.decode_image::<RgbAFormat>()?;
    |                                                  ^^^^^^^^^^ not found in this scope
    |
help: you might be missing a type parameter
    |
166 | impl<RgbAFormat> Buffer {
    |     ++++++++++++

error[E0599]: no method named `frame` found for mutable reference `&mut buffer::Buffer` in the current scope
   --> /home/regodin/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/1433938/nokhwa-core/src/buffer.rs:177:26
    |
177 |         let frame = self.frame()?.decode_image::<RgbAFormat>()?;
    |                          ^^^^^ method not found in `&mut Buffer`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `CaptureTrait` defines an item `frame`, perhaps you need to implement it
   --> /home/regodin/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/1433938/nokhwa-core/src/traits.rs:40:1
    |
40  | pub trait CaptureTrait {
    | ^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> /home/regodin/.cargo/git/checkouts/nokhwa-66b597f0abb1b795/1433938/nokhwa-core/src/buffer.rs:209:32
    |
209 |                 bytes_per_row: width_nonzero,
    |                                ^^^^^^^^^^^^^ expected `Option<u32>`, found integer
    |
    = note: expected enum `Option<u32>`
               found type `{integer}`
help: try wrapping the expression in `Some`
    |
209 |                 bytes_per_row: Some(width_nonzero),
    |                                +++++             +

Cloned the repo, fixed the previously mentioned missing Option errors and this is what remains:

error[E0412]: cannot find type `RgbAFormat` in this scope
   --> /home/regodin/Programming/clones/nokhwa/nokhwa-core/src/buffer.rs:177:50
    |
177 |         let frame = self.frame()?.decode_image::<RgbAFormat>()?;
    |                                                  ^^^^^^^^^^ not found in this scope
    |
help: you might be missing a type parameter
    |
166 | impl<RgbAFormat> Buffer {
    |     ++++++++++++

error[E0599]: no method named `frame` found for mutable reference `&mut buffer::Buffer` in the current scope
   --> /home/regodin/Programming/clones/nokhwa/nokhwa-core/src/buffer.rs:177:26
    |
177 |         let frame = self.frame()?.decode_image::<RgbAFormat>()?;
    |                          ^^^^^ method not found in `&mut Buffer`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `CaptureTrait` defines an item `frame`, perhaps you need to implement it
   --> /home/regodin/Programming/clones/nokhwa/nokhwa-core/src/traits.rs:40:1
    |
40  | pub trait CaptureTrait {
    | ^^^^^^^^^^^^^^^^^^^^^^

Also tried to run the capture example but needless to say, it also did not work.

Here are my specs for my system:

OS: Pop!_OS 22.04 LTS x86_64 
CPU: Intel i5-9400H (8) @ 4.300GHz 
GPU: NVIDIA Quadro T1000 Mobile 
GPU: Intel CoffeeLake-H GT2 [UHD Graphics 630] 
Memory: 8GB 

As an additional troubleshooting step, I even reverted the main.rs file to a simple "Hello World!" and it still, the same errors appears. It simply won't compile.

Am I doing something wrong? Am I missing any dependencies?

benterova commented 4 months ago

Also getting this issue, would love to know if there's a workaround or solution

ajaypillay commented 4 months ago

I've had the same issue on Fedora 39. I got around it by just having a local copy of this commit as stated here: https://github.com/l1npengtul/nokhwa/issues/147#issuecomment-1964927366.