#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(non_fmt_panics)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
#![allow(rustdoc::missing_crate_level_docs)]
#![allow(unsafe_code)]
#![allow(clippy::undocumented_unsafe_blocks)]
#![allow(unused_must_use)]
#![allow(non_snake_case)]
#![allow(clippy::upper_case_acronyms)]
use smallvec::SmallVec;
use thiserror::Error;
use serde::{
Deserialize, Serialize
};
use serde_yml::Error;
use std::num::ParseIntError;
pub mod vocabulary;
pub mod adaptor;
pub mod keypoint;
pub mod database;
pub type Desc = [u8; 32];
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BoW(pub Vec<f32>);
pub type DirectIdx = Vec<IdPath>;
pub type IdPath = SmallVec<[usize; 5]>;
impl BoW {
pub fn l1(&self, other: &Self) -> f32 {
let values = self.0.iter().zip(&other.0);
1. - 0.5 * (values.fold(0., |a, (b, c)| a + (b - c).abs()))
}
}
type BowResult<T> = std::result::Result<T, BowErr>;
#[derive(Error, Debug)]
pub enum BowErr {
#[error("No Features Provided")]
NoFeatures,
#[error("Io Error")]
Io(#[from] std::io::Error),
#[error("Vocabulary Serialization Error")]
Bincode(#[from] bincode::Error),
#[error("YAML Serialization Error")]
Yaml(#[from] serde_yml::Error),
#[error("Parse Error: {0}")]
ParseError(String),
#[error("Parse Int Error: {0}")]
ParseInt(#[from] ParseIntError),
}