@@ -695,6 +695,54 @@ impl VisualDatabase {
695695 pub fn keyframe ( & self , id : usize ) -> Option < & Keyframe > {
696696 self . keyframes . get ( & id)
697697 }
698+
699+ // ── Facade-parity convenience accessors (#148, Group A) ──────────────
700+ // Thin getters mirroring `VisualDatabaseFacade`, so callers don't have to
701+ // reach through `keyframe(id).store` and loop element-by-element.
702+
703+ /// Feature points of the reference keyframe stored under `id`.
704+ ///
705+ /// C equivalent: `getFeaturePoints(id)`.
706+ pub fn get_feature_points ( & self , id : usize ) -> Option < & [ FeaturePoint ] > {
707+ self . keyframes . get ( & id) . map ( |kf| kf. store . points ( ) )
708+ }
709+
710+ /// Flat descriptor buffer of the reference keyframe stored under `id`.
711+ ///
712+ /// C equivalent: `getDescriptors(id)`.
713+ pub fn get_descriptors ( & self , id : usize ) -> Option < & [ u8 ] > {
714+ self . keyframes . get ( & id) . map ( |kf| kf. store . descriptors ( ) )
715+ }
716+
717+ /// Feature points of the most recent query frame (see [`query`](Self::query)).
718+ ///
719+ /// C equivalent: `getQueryFeaturePoints()`.
720+ pub fn get_query_feature_points ( & self ) -> Option < & [ FeaturePoint ] > {
721+ self . query_keyframe . as_ref ( ) . map ( |kf| kf. store . points ( ) )
722+ }
723+
724+ /// Flat descriptor buffer of the most recent query frame.
725+ ///
726+ /// C equivalent: `getQueryDescriptors()`.
727+ pub fn get_query_descriptors ( & self ) -> Option < & [ u8 ] > {
728+ self . query_keyframe
729+ . as_ref ( )
730+ . map ( |kf| kf. store . descriptors ( ) )
731+ }
732+
733+ /// Width of the reference image stored under `id`.
734+ ///
735+ /// C equivalent: `getWidth(id)`.
736+ pub fn get_width ( & self , id : usize ) -> Option < i32 > {
737+ self . keyframes . get ( & id) . map ( |kf| kf. width )
738+ }
739+
740+ /// Height of the reference image stored under `id`.
741+ ///
742+ /// C equivalent: `getHeight(id)`.
743+ pub fn get_height ( & self , id : usize ) -> Option < i32 > {
744+ self . keyframes . get ( & id) . map ( |kf| kf. height )
745+ }
698746}
699747
700748impl Default for VisualDatabase {
@@ -1113,6 +1161,49 @@ mod tests {
11131161 assert ! ( db. inliers( ) . is_empty( ) ) ;
11141162 }
11151163
1164+ #[ test]
1165+ fn test_facade_parity_accessors ( ) {
1166+ // Build a tiny keyframe directly (no image pipeline) so the getters are
1167+ // exercised deterministically and fast (#148, Group A).
1168+ let mut kf = Keyframe :: new ( 640 , 480 ) . unwrap ( ) ;
1169+ let p0 = FeaturePoint {
1170+ x : 1.0 ,
1171+ y : 2.0 ,
1172+ angle : 0.0 ,
1173+ scale : 1.0 ,
1174+ maxima : true ,
1175+ } ;
1176+ let p1 = FeaturePoint {
1177+ x : 3.0 ,
1178+ y : 4.0 ,
1179+ angle : 0.0 ,
1180+ scale : 1.0 ,
1181+ maxima : false ,
1182+ } ;
1183+ kf. store . add ( p0, & [ 7u8 ; 96 ] ) . unwrap ( ) ;
1184+ kf. store . add ( p1, & [ 9u8 ; 96 ] ) . unwrap ( ) ;
1185+
1186+ let mut db = VisualDatabase :: new ( ) . expect ( "new" ) ;
1187+ db. add_keyframe ( kf, 0 ) . expect ( "add_keyframe" ) ;
1188+
1189+ // Reference accessors for the stored id.
1190+ assert_eq ! ( db. get_width( 0 ) , Some ( 640 ) ) ;
1191+ assert_eq ! ( db. get_height( 0 ) , Some ( 480 ) ) ;
1192+ assert_eq ! ( db. get_feature_points( 0 ) . unwrap( ) . len( ) , 2 ) ;
1193+ assert_eq ! ( db. get_feature_points( 0 ) . unwrap( ) [ 0 ] . x, 1.0 ) ;
1194+ let descs = db. get_descriptors ( 0 ) . unwrap ( ) ;
1195+ assert_eq ! ( descs. len( ) , 2 * 96 ) ;
1196+ assert_eq ! ( & descs[ 0 ..96 ] , & [ 7u8 ; 96 ] ) ;
1197+
1198+ // Missing id → None.
1199+ assert ! ( db. get_feature_points( 99 ) . is_none( ) ) ;
1200+ assert ! ( db. get_width( 99 ) . is_none( ) ) ;
1201+
1202+ // No query run yet → query accessors are None.
1203+ assert ! ( db. get_query_feature_points( ) . is_none( ) ) ;
1204+ assert ! ( db. get_query_descriptors( ) . is_none( ) ) ;
1205+ }
1206+
11161207 // -----------------------------------------------------------------
11171208 // Dual-mode parity test (M9-1 gate per #140, closed by M9 #146)
11181209 // -----------------------------------------------------------------
0 commit comments