skubalj / convolve2d

Easy and extensible pure Rust image convolutions. https://crates.io/crates/convolve2d
MIT License
0 stars 0 forks source link

Tests fail with the newest version of image #1

Closed paperclipstudio closed 2 months ago

paperclipstudio commented 2 months ago
>cargo t
   Compiling convolve2d v0.1.0 (/home/pcm/git/convolve2d)
error[E0277]: the trait bound `convolve2d::DynamicMatrix<convolve2d::SubPixels<u8, 3>>: From<ImageBuffer<Rgb<u8>, Vec<u8>>>` is not satisfied
  --> examples/blur.rs:30:10
   |
30 |         .into();
   |          ^^^^ the trait `From<ImageBuffer<Rgb<u8>, Vec<u8>>>` is not implemented for `convolve2d::DynamicMatrix<convolve2d::SubPixels<u8, 3>>`, which is required by `ImageBuffer<Rgb<u8>, Vec<u8>>: Into<_>`
   |
   = note: required for `ImageBuffer<Rgb<u8>, Vec<u8>>` to implement `Into<convolve2d::DynamicMatrix<convolve2d::SubPixels<u8, 3>>>`

error[E0277]: the trait bound `convolve2d::DynamicMatrix<convolve2d::SubPixels<u8, 1>>: From<ImageBuffer<Luma<u8>, Vec<u8>>>` is not satisfied
  --> examples/edge_detection.rs:26:10
   |
26 |         .into();
   |          ^^^^ the trait `From<ImageBuffer<Luma<u8>, Vec<u8>>>` is not implemented for `convolve2d::DynamicMatrix<convolve2d::SubPixels<u8, 1>>`, which is required by `ImageBuffer<Luma<u8>, Vec<u8>>: Into<_>`
   |
   = note: required for `ImageBuffer<Luma<u8>, Vec<u8>>` to implement `Into<convolve2d::DynamicMatrix<convolve2d::SubPixels<u8, 1>>>`

error[E0308]: mismatched types
   --> examples/edge_detection.rs:42:21
    |
42  |     GrayImage::from(convolution)
    |     --------------- ^^^^^^^^^^^ expected `ImageBuffer<Luma<...>, ...>`, found `DynamicMatrix<SubPixels<..., 1>>`
    |     |
    |     arguments to this function are incorrect
    |
    = note: expected struct `ImageBuffer<Luma<u8>, Vec<u8>>`
               found struct `convolve2d::DynamicMatrix<convolve2d::SubPixels<u8, 1>>`
note: associated function defined here
   --> /home/pcm/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:585:8
    |
585 |     fn from(value: T) -> Self;
    |        ^^^^

error[E0308]: mismatched types
   --> examples/blur.rs:42:20
    |
42  |     RgbImage::from(convolution)
    |     -------------- ^^^^^^^^^^^ expected `ImageBuffer<Rgb<...>, ...>`, found `DynamicMatrix<SubPixels<..., 3>>`
    |     |
    |     arguments to this function are incorrect
    |
    = note: expected struct `ImageBuffer<Rgb<u8>, Vec<u8>>`
               found struct `convolve2d::DynamicMatrix<convolve2d::SubPixels<u8, 3>>`
note: associated function defined here
   --> /home/pcm/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/convert/mod.rs:585:8
    |
585 |     fn from(value: T) -> Self;
    |        ^^^^

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `convolve2d` (example "edge_detection") due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `convolve2d` (example "blur") due to 2 previous errors
skubalj commented 2 months ago

Thanks for the ticket here! I'll try to take a look at this when I have time over the next week.

paperclipstudio commented 2 months ago

If I have some time I'll take a look.

skubalj commented 2 months ago

Hey, I finally had a sec to look at this. It looks like the problem was coming in because the image library dropped BGR support in v0.24. (I wrote this during v0.23, and the current version is v0.25)

I've updated the dependencies for a patch release and removed the pieces that are no longer supported (removing API in a patch doesn't feel good with semver, but I'm not sure what else to do; if it's broken, it should be fixed.).

If you get a chance, can you try using the main branch of this repo as your dependency and double check that these updates fix things for you?

Thanks

paperclipstudio commented 2 months ago

Thanks for that! Sadly I don't have a good codebase to check it with but I can say that all the tests work on my side with the new version of image.