twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4
MIT License
1.96k stars 157 forks source link

from_slice_rows_cols deprecated? #564

Closed sjbeskur closed 5 months ago

sjbeskur commented 5 months ago

the following method on Mat seems to have been deprecated in the latest update: from_slice_rows_cols

The suggested workarounds are unclear? Any guidance would be appreciated.

        let img: [u16; 81] = [
            10, 10, 10,  10, 10, 10, 10, 10, 10, //
            10, 10, 10,  10, 10, 10, 10, 10, 10, //
            10, 10, 200, 110, 10, 10, 10, 10, 10, //
            10, 10, 110, 245, 10, 10, 10, 10, 10, //
            10, 10, 10, 245, 10, 10, 10, 10, 10, //
            10, 10, 10, 200, 10, 10, 10, 10, 10, //
            10, 10, 10, 10, 10, 10, 10, 10, 10, //
            10, 10, 10, 10, 10, 10, 10, 10, 10, //
            10, 10, 10, 10, 10, 10, 10, 10, 10, //
        ];
        let image_mat = opencv::core::Mat::from_slice_rows_cols(&img, 9,9).unwrap();  // no worky :(
        assert_eq!(image_mat.depth(), opencv::core::CV_16U);
        assert_eq!(image_mat.dims(), 2);
        assert_eq!(image_mat.channels(), 1);
    } 
twistedfall commented 5 months ago

I think I forgot to mention this in the changelog, sorry! Yes, it's now been replaced by Mat::new_rows_cols_with_data with slightly different semantics:

sjbeskur commented 5 months ago

Thanks, I'll give it a try.

twistedfall commented 5 months ago

I hope it worked!