Skip to content

Commit

Permalink
0.8.0 drafted
Browse files Browse the repository at this point in the history
  • Loading branch information
bwsw committed Jul 14, 2022
1 parent 2edb1fd commit 4a15ad8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ once_cell = "1.12.0"
num_cpus = "1.13.1"
ultraviolet = "0.9.0"
crossbeam = "0.8.1"
rand = "0.8.5"

[dev-dependencies]
rand = "0.8.5"
wide = "0.7.4"

[profile.dev]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ Take a look at [benchmarks](benches) for numbers.

Take a look at
* [examples/simple.rs](examples/simple.rs) for an idea of simple usage.
* [examples/tracking.rs](examples/track_merge.rs) for an idea of intra-cam track merging.
* [examples/tracking.rs](examples/track_merging) for an idea of intra-cam track merging.

37 changes: 2 additions & 35 deletions examples/track_merge.rs → examples/track_merging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ use crate::Gender::{Female, Male};
use anyhow::Result;
use itertools::Itertools;
use once_cell::sync::OnceCell;
use rand::distributions::Uniform;
use rand::rngs::ThreadRng;
use rand::Rng;
use similari::current_time_ms;
use similari::distance::euclidean;
use similari::store::TrackStore;
use similari::test_stuff::vec2;
use similari::test_stuff::FeatGen2;
use similari::track::notify::NoopNotifier;
use similari::track::{
Metric, ObservationSpec, ObservationsDb, TrackAttributes, TrackAttributesUpdate, TrackStatus,
Expand Down Expand Up @@ -186,39 +183,9 @@ fn cam_tracking_attributes_update_test() {
assert!(update.apply(&mut attrs).is_err());
}

struct FeatGen2 {
x: f32,
y: f32,
gen: ThreadRng,
dist: Uniform<f32>,
}

impl FeatGen2 {
pub fn new(x: f32, y: f32, drift: f32) -> Self {
Self {
x,
y,
gen: rand::thread_rng(),
dist: Uniform::new(-drift, drift),
}
}
}

impl Iterator for FeatGen2 {
type Item = ObservationSpec<f32>;

fn next(&mut self) -> Option<Self::Item> {
self.x += self.gen.sample(&self.dist);
self.y += self.gen.sample(&self.dist);
Some(ObservationSpec(
self.gen.sample(&self.dist) + 0.7,
vec2(self.x, self.y),
))
}
}

#[test]
fn feat_gen() {
use similari::test_stuff::FeatGen2;
use std::ops::Sub;
use ultraviolet::f32x8;

Expand Down
34 changes: 34 additions & 0 deletions src/test_stuff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use crate::track::{
TrackAttributesUpdate, TrackStatus,
};
use anyhow::Result;
use rand::distributions::Uniform;
use rand::prelude::ThreadRng;
use rand::Rng;
use thiserror::Error;

#[derive(Debug, Error)]
Expand Down Expand Up @@ -133,3 +136,34 @@ pub fn vec2(x: f32, y: f32) -> Observation {

impl ObservationAttributes for f32 {}
impl ObservationAttributes for () {}

pub struct FeatGen2 {
x: f32,
y: f32,
gen: ThreadRng,
dist: Uniform<f32>,
}

impl FeatGen2 {
pub fn new(x: f32, y: f32, drift: f32) -> Self {
Self {
x,
y,
gen: rand::thread_rng(),
dist: Uniform::new(-drift, drift),
}
}
}

impl Iterator for FeatGen2 {
type Item = ObservationSpec<f32>;

fn next(&mut self) -> Option<Self::Item> {
self.x += self.gen.sample(&self.dist);
self.y += self.gen.sample(&self.dist);
Some(ObservationSpec(
self.gen.sample(&self.dist) + 0.7,
vec2(self.x, self.y),
))
}
}

0 comments on commit 4a15ad8

Please sign in to comment.