<s> """<STR_LIT>""" <EOL> from . library import * <EOL> from . array import * <EOL> from . features import * <EOL> def fast ( image , threshold = <NUM_LIT> , arc_length = <NUM_LIT:9> , non_max = True , feature_ratio = <NUM_LIT> , edge = <NUM_LIT:3> ) : <EOL> """<STR_LIT>""" <EOL> out = Features ( ) <EOL> safe_call ( backend . get ( ) . af_fast ( ct . pointer ( out . feat ) , <EOL> image . arr , ct . c_float ( threshold ) , ct . c_uint ( arc_length ) , non_max , <EOL> ct . c_float ( feature_ratio ) , ct . c_uint ( edge ) ) ) <EOL> return out <EOL> def harris ( image , max_corners = <NUM_LIT> , min_response = <NUM_LIT> , sigma = <NUM_LIT:1.0> , block_size = <NUM_LIT:0> , k_thr = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> out = Features ( ) <EOL> safe_call ( backend . get ( ) . af_harris ( ct . pointer ( out . feat ) , <EOL> image . arr , ct . c_uint ( max_corners ) , ct . c_float ( min_response ) , <EOL> ct . c_float ( sigma ) , ct . c_uint ( block_size ) , ct . c_float ( k_thr ) ) ) <EOL> return out <EOL> def orb ( image , threshold = <NUM_LIT> , max_features = <NUM_LIT> , scale = <NUM_LIT> , num_levels = <NUM_LIT:4> , blur_image = False ) : <EOL> """<STR_LIT>""" <EOL> feat = Features ( ) <EOL> desc = Array ( ) <EOL> safe_call ( backend . get ( ) . af_orb ( ct . pointer ( feat . feat ) , ct . pointer ( desc . arr ) , <EOL> ct . c_float ( threshold ) , ct . c_uint ( max_features ) , <EOL> ct . c_float ( scale ) , ct . c_uint ( num_levels ) , blur_image ) ) <EOL> return feat , desc <EOL> def hamming_matcher ( query , database , dim = <NUM_LIT:0> , num_nearest = <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> index = Array ( ) <EOL> dist = Array ( ) <EOL> safe_call ( backend . get ( ) . af_hamming_matcher ( ct . pointer ( idx . arr ) , ct . pointer ( dist . arr ) , <EOL> query . arr , database . arr , <EOL> c_dim_t ( dim ) , c_dim_t ( num_nearest ) ) ) <EOL> return index , dist <EOL> def nearest_neighbour ( query , database , dim = <NUM_LIT:0> , num_nearest = <NUM_LIT:1> , match_type = MATCH . SSD ) : <EOL> """<STR_LIT>""" <EOL> index = Array ( ) <EOL> dist = Array ( ) <EOL> safe_call ( backend . get ( ) . af_nearest_neighbour ( ct . pointer ( idx . arr ) , ct . pointer ( dist . arr ) , <EOL> query . arr , database . arr , <EOL> c_dim_t ( dim ) , c_dim_t ( num_nearest ) , <EOL> match_type . value ) ) <EOL> return index , dist <EOL> def match_template ( image , template , match_type = MATCH . SAD ) : <EOL> """<STR_LIT>""" <EOL> out = Array ( ) <EOL> safe_call ( backend . get ( ) . af_match_template ( ct . pointer ( out . arr ) , <EOL> image . arr , template . arr , <EOL> match_type . value ) ) <EOL> return out <EOL> def susan ( image , radius = <NUM_LIT:3> , diff_thr = <NUM_LIT:32> , geom_thr = <NUM_LIT:10> , feature_ratio = <NUM_LIT> , edge = <NUM_LIT:3> ) : <EOL> """<STR_LIT>""" <EOL> out = Features ( ) <EOL> safe_call ( backend . get ( ) . af_susan ( ct . pointer ( out . feat ) , <EOL> image . arr , ct . c_uint ( radius ) , ct . c_float ( diff_thr ) , <EOL> ct . c_float ( geom_thr ) , ct . c_float ( feature_ratio ) , <EOL> ct . c_uint ( edge ) ) ) <EOL> return out <EOL> def dog ( image , radius1 , radius2 ) : <EOL> """<STR_LIT>""" <EOL> out = Array ( ) <EOL> safe_call ( backend . get ( ) . af_dog ( ct . pointer ( out . arr ) , <EOL> image . arr , radius1 , radius2 ) ) <EOL> return out <EOL> def sift ( image , num_layers = <NUM_LIT:3> , contrast_threshold = <NUM_LIT> , edge_threshold = <NUM_LIT> , initial_sigma = <NUM_LIT> , <EOL> double_input = True , intensity_scale = <NUM_LIT> , feature_ratio = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> feat = Features ( ) <EOL> desc = Array ( ) <EOL> safe_call ( af_sift ( ct . pointer ( feat ) , ct . pointer ( desc ) , <EOL> image . arr , num_layers , contrast_threshold , edge_threshold , <EOL> initial_sigma , double_input , intensity_scale , feature_ratio ) ) <EOL> return ( feat , desc ) <EOL> def gloh ( image , num_layers = <NUM_LIT:3> , contrast_threshold = <NUM_LIT> , edge_threshold = <NUM_LIT> , initial_sigma = <NUM_LIT> , <EOL> double_input = True , intensity_scale = <NUM_LIT> , feature_ratio = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> feat = Features ( ) <EOL> desc = Array ( ) <EOL> safe_call ( af_gloh ( ct . pointer ( feat ) , ct . pointer ( desc ) , <EOL> image . arr , num_layers , contrast_threshold , edge_threshold , <EOL> initial_sigma , double_input , intensity_scale , feature_ratio ) ) <EOL> return ( feat , desc ) <EOL> def homography ( x_src , y_src , x_dst , y_dst , htype = HOMOGRAPHY . RANSAC , <EOL> ransac_threshold = <NUM_LIT> , iters = <NUM_LIT:1000> , out_type = Dtype . f32 ) : <EOL> """<STR_LIT>""" <EOL> H = Array ( ) <EOL> inliers = ct . c_int ( <NUM_LIT:0> ) <EOL> safe_call ( backend . get ( ) . af_homography ( ct . pointer ( H ) , ct . pointer ( inliers ) , <EOL> x_src . arr , y_src . arr , x_dst . arr , y_dst . arr , <EOL> htype . value , ransac_threshold , iters , out_type . value ) ) <EOL> return ( H , inliers ) </s>
