Skip to content

Commit e738502

Browse files
authored
Updating Libs (#732)
* updated getrandom library to latest version * rand update to 0.9.2 ref and rand_distr to 0.5.1 * updated nalgebra to 0.34.1 * fixed broken bench * fixed fmt issues * updated to msrv to 1.85.0 * clippy reccomendations * getrandom 0.3.0
1 parent 9f1d317 commit e738502

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

Cargo.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "imageproc"
33
version = "0.26.0"
44
authors = ["theotherphil"]
5-
rust-version = "1.81.0"
5+
rust-version = "1.85.0"
66
edition = "2021"
77
license = "MIT"
88
description = "Image processing operations"
@@ -24,12 +24,13 @@ itertools = { version = "0.14.0", default-features = false, features = [
2424
"use_std",
2525
] }
2626
nalgebra = { version = "0.33.0", default-features = false, features = ["std"] }
27-
num = { version = "0.4.1", default-features = false }
28-
rand = { version = "0.8.0", default-features = false, features = [
29-
"std",
30-
"std_rng",
27+
num = { version = "0.4.0", default-features = false }
28+
rand = { version = "0.9.0", default-features = false, features = [
29+
30+
"thread_rng"
31+
3132
] }
32-
rand_distr = { version = "0.4.0", default-features = false }
33+
rand_distr = { version = "0.5.0", default-features = false }
3334
rayon = { version = "1.8.0", optional = true, default-features = false }
3435
sdl2 = { version = "0.38.0", optional = true, default-features = false, features = [
3536
"bundled",
@@ -38,7 +39,7 @@ katexit = { version = "0.1.4", optional = true, default-features = false }
3839
rustdct = "0.7.1"
3940

4041
[target.'cfg(target_arch = "wasm32")'.dependencies]
41-
getrandom = { version = "0.2.0", default-features = false, features = ["js"] }
42+
getrandom = { version = "0.3.0", default-features = false, features = ["wasm_js"] }
4243

4344
[dev-dependencies]
4445
assert_approx_eq = "1.1.0"

src/binary_descriptors/brief.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ pub fn brief(
231231
} else {
232232
// generate a set of test pairs within a 31x31 grid with a Gaussian bias (sigma = 6.6)
233233
let test_pair_distribution = Normal::new(BRIEF_PATCH_RADIUS as f32 + 1.0, 6.6).unwrap();
234-
let mut rng = rand::thread_rng();
234+
let mut rng = rand::rng();
235235
let mut test_pairs: Vec<TestPair> = Vec::with_capacity(length);
236236
while test_pairs.len() < length {
237237
let (x0, y0, x1, y1) = (
@@ -330,12 +330,12 @@ mod benches {
330330
#[ignore]
331331
fn bench_brief_random_test_pairs_1000_keypoints(b: &mut Bencher) {
332332
let image = gray_bench_image(640, 480);
333-
let mut rng = rand::thread_rng();
333+
let mut rng = rand::rng();
334334
let keypoints = (0..1000)
335335
.map(|_| {
336336
Point::new(
337-
rng.gen_range(24..image.width() - 24),
338-
rng.gen_range(24..image.height() - 24),
337+
rng.random_range(24..image.width() - 24),
338+
rng.random_range(24..image.height() - 24),
339339
)
340340
})
341341
.collect::<Vec<Point<u32>>>();
@@ -348,12 +348,12 @@ mod benches {
348348
#[ignore]
349349
fn bench_brief_fixed_test_pairs_1000_keypoints(b: &mut Bencher) {
350350
let image = gray_bench_image(640, 480);
351-
let mut rng = rand::thread_rng();
351+
let mut rng = rand::rng();
352352
let keypoints = (0..1000)
353353
.map(|_| {
354354
Point::new(
355-
rng.gen_range(24..image.width() - 24),
356-
rng.gen_range(24..image.height() - 24),
355+
rng.random_range(24..image.width() - 24),
356+
rng.random_range(24..image.height() - 24),
357357
)
358358
})
359359
.collect::<Vec<Point<u32>>>();

src/binary_descriptors/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn match_binary_descriptors<'a, T: BinaryDescriptor>(
5959
let mut rng = if let Some(s) = seed {
6060
StdRng::seed_from_u64(s)
6161
} else {
62-
StdRng::from_entropy()
62+
SeedableRng::from_os_rng()
6363
};
6464

6565
// locality-sensitive hashing (LSH)
@@ -79,7 +79,7 @@ pub fn match_binary_descriptors<'a, T: BinaryDescriptor>(
7979
for _ in 0..l {
8080
// choose k random bits (not necessarily unique)
8181
let bits = (0..k)
82-
.map(|_| rng.gen_range(0..queries[0].get_size()))
82+
.map(|_| rng.random_range(0..queries[0].get_size()))
8383
.collect::<Vec<u32>>();
8484

8585
let mut new_hashmap = HashMap::<u128, Vec<&T>>::with_capacity(database.len());
@@ -144,12 +144,12 @@ mod benches {
144144
#[ignore]
145145
fn bench_matcher_1000_keypoints_each(b: &mut Bencher) {
146146
let image = gray_bench_image(640, 480);
147-
let mut rng = rand::thread_rng();
147+
let mut rng = rand::rng();
148148
let keypoints = (0..1000)
149149
.map(|_| {
150150
Point::new(
151-
rng.gen_range(20..image.width() - 20),
152-
rng.gen_range(20..image.height() - 20),
151+
rng.random_range(20..image.width() - 20),
152+
rng.random_range(20..image.height() - 20),
153153
)
154154
})
155155
.collect::<Vec<Point<u32>>>();

src/corners.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ use crate::{
55
point::Point,
66
};
77
use image::{GenericImageView, GrayImage};
8-
use rand::{rngs::StdRng, SeedableRng};
9-
use rand_distr::Distribution;
8+
use rand::{distr::Distribution, rngs::StdRng, SeedableRng};
109

1110
/// A location and score for a detected corner.
1211
/// The scores need not be comparable between different
@@ -191,10 +190,10 @@ pub fn oriented_fast(
191190
let mut rng = if let Some(s) = seed {
192191
StdRng::seed_from_u64(s)
193192
} else {
194-
StdRng::from_entropy()
193+
SeedableRng::from_os_rng()
195194
};
196-
let dist_x = rand::distributions::Uniform::new(min_x, max_x);
197-
let dist_y = rand::distributions::Uniform::new(min_y, max_y);
195+
let dist_x = rand::distr::Uniform::new(min_x, max_x).unwrap();
196+
let dist_y = rand::distr::Uniform::new(min_y, max_y).unwrap();
198197
let sample_size = NUM_SAMPLE_POINTS.min((width * height) as usize);
199198
let sample_coords: Vec<Point<u32>> = (0..sample_size)
200199
.map(|_| Point::new(dist_x.sample(&mut rng), dist_y.sample(&mut rng)))

src/noise.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ where
4949
P: Pixel + HasBlack + HasWhite,
5050
{
5151
let mut rng: StdRng = SeedableRng::seed_from_u64(seed);
52-
let uniform = Uniform::new(0.0, 1.0);
52+
let uniform = Uniform::new(0.0, 1.0).unwrap();
5353

5454
for p in image.pixels_mut() {
5555
if uniform.sample(&mut rng) > rate {

src/stats.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ where
5555
for (i, c) in pix.channels().iter().enumerate() {
5656
let (current_min, current_max) = &mut ranges[i];
5757

58-
if current_min.map_or(true, |x| c < x) {
58+
if current_min.is_none_or(|x| c < x) {
5959
*current_min = Some(c);
6060
}
61-
if current_max.map_or(true, |x| c > x) {
61+
if current_max.is_none_or(|x| c > x) {
6262
*current_max = Some(c);
6363
}
6464
}

src/union_find.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ mod benches {
189189
let num_edges = 20 * num_nodes;
190190

191191
let mut rng: StdRng = SeedableRng::seed_from_u64(1);
192-
let uniform = Uniform::new(0, num_nodes);
192+
let uniform = Uniform::new(0, num_nodes).unwrap();
193193

194194
let mut forest = DisjointSetForest::new(num_nodes);
195195
b.iter(|| {

0 commit comments

Comments
 (0)