Skip to main content

qualia_vision/
lib.rs

1//! Qualia Vision — product surface for visual intelligence + biosense.
2//!
3//! # Library home (MIG-V2)
4//! Pure algorithms live in
5//! `qualia_core_db::specialized_libs::computer_vision` (`cv`, `ops`, `sr`,
6//! `bio`, `embeddings`, `spatial` kernels, `gpu` dispatch). This crate
7//! **re-exports** those kernels and owns product layers: biosense consent,
8//! recipes, weights, capability registry, semantic quins, media store.
9//!
10//! Plans: `native-visual-intelligence-and-generative-3d.md`,
11//! `vision-10d-browser-excellence-programme-2026.md` §9-B.
12//!
13//! # Design rules
14//! - Hot path is caller-buffered, no hidden heap in `infer`.
15//! - Model outputs are **epistemic observations**, not ground truth.
16//! - Dense pixels / biometric templates never in NQuins.
17//! - **No Python**; no OpenCV product link.
18
19#![cfg_attr(not(test), deny(clippy::unwrap_used))]
20
21pub mod bio;
22pub mod biosense;
23pub mod capability;
24pub mod classifier;
25pub mod cv;
26pub mod detector;
27pub mod embeddings;
28pub mod generator;
29pub mod gpu;
30pub mod media_store;
31pub mod metrics;
32pub mod ops;
33pub mod overlay;
34pub mod preprocess;
35pub mod recipes;
36pub mod semantic;
37pub mod spatial;
38pub mod sr;
39pub mod synthetic;
40pub mod tracker;
41pub mod types;
42pub mod weights;
43
44pub mod ade20k_taxonomy;
45pub mod cifar_taxonomy;
46pub mod cityscapes_taxonomy;
47pub mod coco_taxonomy;
48#[cfg(feature = "cpu-reference")]
49pub mod cpu_reference;
50pub mod kitti_taxonomy;
51pub mod openimages_taxonomy;
52pub mod pascal_voc_taxonomy;
53pub mod vggface2_taxonomy;
54
55pub use ade20k_taxonomy::{
56    ade20k_category_count, lookup_ade20k_class_by_hash, lookup_ade20k_class_by_id,
57    q_hash_ade20k_class, ADE20K_150_CLASSES,
58};
59pub use cifar_taxonomy::{
60    lookup_cifar100_class_by_id, lookup_cifar10_class_by_id, lookup_cifar_class_by_hash,
61    q_hash_cifar_class, CIFAR_100_CLASSES, CIFAR_10_CLASSES,
62};
63pub use cityscapes_taxonomy::{
64    cityscapes_category_count, lookup_cityscapes_class_by_hash, lookup_cityscapes_class_by_id,
65    q_hash_cityscapes_class, CITYSCAPES_CLASSES,
66};
67pub use coco_taxonomy::{
68    coco_category_count, lookup_coco_class_by_hash, lookup_coco_class_by_id, q_hash_coco_class,
69    COCO_80_CLASSES,
70};
71pub use kitti_taxonomy::{
72    kitti_category_count, lookup_kitti_class_by_hash, lookup_kitti_class_by_id, q_hash_kitti_class,
73    KITTI_8_CLASSES,
74};
75pub use openimages_taxonomy::{
76    lookup_openimages_class_by_hash, lookup_openimages_class_by_mid, openimages_category_count,
77    q_hash_openimages_class, OpenImagesClassEntry, OPENIMAGES_600_CLASSES,
78};
79pub use pascal_voc_taxonomy::{
80    lookup_pascal_voc_class_by_hash, lookup_pascal_voc_class_by_id, pascal_voc_category_count,
81    q_hash_pascal_voc_class, PASCAL_VOC_20_CLASSES,
82};
83pub use vggface2_taxonomy::{
84    format_vggface2_subject_id, lookup_vggface2_subject_hash, q_hash_vggface2_subject,
85    vggface2_identity_count, VGGFace2Pose, VGGFACE2_IDENTITY_COUNT,
86};
87
88pub use bio::{
89    anonymize_tag_map, apply_background_correct, apply_hu_window_i16, background_intensity_sample,
90    centroid_from_bbox, centroids_from_binary, centroids_from_labels, crocker_grier_link,
91    extended_minima, first_order_stats, glcm_features, glcm_features_d1, hu_window_i16,
92    intensity_to_od_u8, isotropic_resample_2d_nn, isotropic_resample_nn_2d, lab_to_rgb,
93    link_particles, macenko_deconvolution, mip_project_axis, mip_project_z, morphological_tophat,
94    nucleus_features, optical_density_rgb, otsu_threshold_from_hist, positive_od_threshold,
95    reinhard_normalize, rgb_to_lab, shape_2d_features, shape_2d_from_mask, shape_3d_from_voxels,
96    snmf_unmix_lite, spectral_unmix_nnls, suv_from_activity, voronoi_otsu_label, watershed_markers,
97    CrockerGrierLinker, CrockerGrierParams, Detection2, FirstOrderStats, GlcmFeatures, HistoError,
98    LabStats, LinkedParticle, MacenkoResult, NucleusFeature, OdPositiveIndex, ParticleCentroid,
99    RadiomicsError, RgbBg, Shape2d, Shape2dFeatures, Shape3dFeatures, StainBasis, TopHatKind,
100    TrackLink, DEFAULT_HE_TARGET_MEAN, DEFAULT_HE_TARGET_STD, GLCM_LEVELS_16, GLCM_LEVELS_32,
101    MAX_FRAME_DETS, MAX_NUCLEUS_LABELS, MAX_OD_LABELS, MAX_PARTICLES_PER_FRAME,
102    MAX_PARTICLE_TRACKS, NO_TRACK_ID,
103};
104pub use biosense::{
105    blendshape_affect_proposal, cctv_stages_allowed, colour_evm_yiq, design_bandpass_iir,
106    energy_ms, ensemble_hr, ensemble_respiration, eulerian_color_magnify,
107    eulerian_color_magnify_consented, eulerian_color_magnify_ex, eulerian_motion_magnify,
108    eulerian_motion_magnify_consented, eulerian_motion_magnify_ex, evaluate_challenge_pad,
109    evaluate_landmark_pad, evaluate_pad_from_mediapipe_trace, evaluate_processing_act,
110    evaluate_profile_asymmetry, evm_snr_gate, face_roi_center, frame_blur_score,
111    gaussian_pyramid_build, issue_challenge, issue_rotation_challenge, landmarks_from_normalized,
112    laplacian_pyramid_build, motion_energy, pack_landmark_frame, profile_asymmetry_ratio,
113    pyramid_reconstruct, reject_low_quality, respiration_from_motion,
114    respiration_from_rppg_harmonic, respiration_rate_from_motion_trace, roi_mean_rgb,
115    spectral_hr_peak, template_hash_from_roi, templates_match, temporal_bandpass_iir,
116    temporal_bandpass_series, valence_arousal_proposal, AffectProposal, BandpassIir, BandpassState,
117    BiometricTemplate, BiosenseConsent, BiosensePurpose, BlendshapeProxy, CameraStreamAttestation,
118    ChallengeKind, ColourEvmParams, EvmRefuse, EvmSnrVerdict, FaceRoi, HeadPose, HrEstimate,
119    Landmark2, LandmarkBufferLayout, LandmarkFrame, MeshBlendProxies, MeshFrameSignals,
120    MotionEvmParams, PadLandmarkId, PadReason, PadResult, PadThresholds, ParSample, ParVerdict,
121    PolicyDecision, ProcessingAct, PyramidLevelMeta, QualityReject, RrEstimate, TemporalWindow,
122    DEFAULT_EVM_MIN_SNR, DEFAULT_PAR_TAU, MAX_PYRAMID_LEVELS, MEDIAPIPE_FACE_MESH_COUNT,
123    RR_F_HI_HZ, RR_F_LO_HZ, RR_MIN_SNR_DEFAULT,
124};
125pub use capability::{all_capabilities, by_id, count_by_status, CapabilityEntry, CapabilityStatus};
126pub use classifier::{fit_two_class_centroids, LinearHead, LinearProbeVision};
127pub use cv::{
128    bicubic_u8, bilateral_denoise_u8, bilinear_u8, box_blur_u8, brief_desc_u8, canny_u8, dilate_u8,
129    draw_rect_u8, equalize_hist_u8, erode_u8, fast_corners_u8, find_external_blobs,
130    gaussian_blur_u8, hamming_match, histogram_u8, lanczos3_u8, lucas_kanade_step, median_blur_u8,
131    rgb_to_gray_u8, sobel_mag_u8, synthetic_pulse_sequence, warp_affine_u8, warp_perspective_u8,
132    BlobBox, CvError, FrameSequence, GrayView, Keypoint, Match, RgbView, DESC_LEN, MAX_SEQ_FRAMES,
133}; // GrayView + RgbView for embeddings / recipes
134pub use detector::{sample_frame_indices, GridMultiObjectDetector, MAX_GRID};
135pub use embeddings::{
136    ahash_u64, color_hist_embed_rgb, cosine_distance, cosine_similarity, dhash_u64,
137    hamming_distance_u64, AHASH_SIDE, COLOR_HIST_BINS, COLOR_HIST_EMBED_DIM, DHASH_HEIGHT,
138    DHASH_WIDTH,
139};
140pub use generator::{
141    compile_generation_receipt_quins, CancelFlag, GenerationReceipt, NativeImageGenerator,
142    CTX_GENERATION, GENERATOR_MODEL_ID, P_GENERATED_IMAGE, P_GEN_PROMPT, P_GEN_SEED,
143};
144pub use gpu::{
145    avg_pool2d_dispatch, conv2d_nchw_dispatch, max_pool2d_dispatch, resize_nearest_nchw_dispatch,
146    thermal_allows_gpu_tiles, ThermalHint, VisionComputeDevice, VisionComputeReport,
147    VisionVramBudget,
148};
149pub use media_store::{MediaRecord, MediaStore, RetentionClass};
150pub use metrics::{evaluate_real_held_out, evaluate_synthetic, mean_best_iou, MetricsReport};
151pub use ops::{avg_pool2d_nchw_f32, conv2d_nchw_f32, max_pool2d_nchw_f32, resize_nearest_nchw_f32};
152pub use overlay::{
153    box_css_percent, box_pixel_bounds, compose_rgb_overlay_rgba8, draw_boxes_rgba8,
154    encode_bmp_rgba8,
155};
156pub use preprocess::{
157    iou_u16, letterbox_rgb8, letterbox_workspace_bytes, nms_class_agnostic,
158    normalize_rgb8_to_f32_chw, resize_nearest_rgb8,
159};
160pub use recipes::{
161    challenge_pad_from_landmark_frames, challenge_pad_from_mesh_trace,
162    compile_hr_observation_quins, respiration_monitor, respiration_monitor_motion_only,
163    self_monitor_pulse, self_monitor_pulse_evm, PulseAbstain, PulseEvmResult,
164};
165pub use semantic::{
166    bbox_quin, class_proposal_quin, compile_observation_quins, compile_observation_quins_full,
167    human_correct_quin, human_reject_quin, media_digest, model_digest_quin, observation_quin,
168    pack_bbox_u64, q_hash, query_by_frame_range, query_by_model, query_instances_in_region,
169    track_quin, unpack_bbox_u64, MediaDigest, VisionQuin, CTX_HUMAN_ATTESTATION, CTX_VISION,
170    MAX_OBS_QUINS, P_HAS_BBOX, P_HAS_TRACK, P_HUMAN_CORRECTS, P_HUMAN_REJECTS, P_MODEL_DIGEST,
171    P_PROPOSES_CLASS, P_VISUAL_OBSERVATION,
172};
173pub use spatial::{
174    assess_twin_eligibility, class_hash_to_sigma_base, class_id_to_sigma_base,
175    class_score_to_sigma, cleanup_mesh_ir, detection_center_to_node_hint, detection_to_sigma,
176    detections_to_node_hints, image_to_heightfield_mesh, mesh_ir_to_export,
177    mesh_ir_to_export_validated, mesh_ir_to_obj, mesh_ir_to_stl_binary, mesh_ir_triangles,
178    pack_geometry_export_for_10d, print_readiness, refuse_fea_unless_eligible, validate_mesh_ir,
179    AnalysisDomain, GeometryFor10d, ImageTo3dReceipt, MeshCleanupOptions, MeshIR,
180    MeshQualityReport, MeshValidationReport, MeshValidationStatus, NodeHint, PrintReadiness,
181    RenderMeshExport, TwinEligibility, MAX_INDICES, MAX_VERTICES,
182};
183pub use sr::{
184    blend_tile_into_accum, estimate_tile_count, extract_tile_rgb8, finalize_blend, plan_tiles,
185    super_resolve, super_resolve_tiled, super_resolve_tiled_default,
186    super_resolve_tiled_with_policy, super_resolve_with_policy, ClassicalKernel, EnhancementMode,
187    SrBackend, SrReport, SrRequest, TilePolicy, TileRect, DEFAULT_OVERLAP, DEFAULT_TILE,
188};
189pub use synthetic::{
190    generate_scene_rgb8, match_accuracy, sample_id, train_test_disjoint, DatasetSplit,
191    SyntheticSampleId, TEST_SEED_BASE, TRAIN_SEED_BASE,
192};
193pub use tracker::{BoundedTracker, FLAG_TRACK_OVERFLOW, MAX_TRACKS};
194pub use types::{
195    Detection, ImageView, PixelFormat, VisionError, VisualCapabilities, VisualModel,
196    VisualOutputCounts, MAX_DETECTIONS, MAX_EMBED_DIM,
197};
198pub use weights::{
199    load_litert_file, probe_onnx_asset, resolve_vision_asset, sface_infer_rgb8,
200    validate_litert_bytes, yunet_infer_rgb8, AssetLicenceTag, LiteRtFileMeta, LiteRtLoadError,
201    OnnxSessionError, ProductionVision, ResolvedAsset, VisionAssetError, VisionAssetId,
202    VisionBackendKind, VisionWeightBundle, LITER_TFLITE_MAGIC, QVWT_MAGIC, QVWT_VERSION,
203};
204
205#[cfg(feature = "cpu-reference")]
206pub use cpu_reference::CpuReferenceVision;