######################################################## Copyright (c) 2015, ArrayFire# All rights reserved.## This file is distributed under 3-clause BSD license.# The complete license agreement can be obtained at:# http://arrayfire.com/licenses/BSD-3-Clause########################################################"""Features class used for Computer Vision algorithms."""from.libraryimport*from.arrayimport*importnumbers[docs]classFeatures(object):""" A container class used for various feature detectors. Parameters ---------- num: optional: int. default: 0. Specifies the number of features. """def__init__(self,num=0):self.feat=c_void_ptr_t(0)ifnumisnotNone:assert(isinstance(num,numbers.Number))safe_call(backend.get().af_create_features(c_pointer(self.feat),c_dim_t(num)))def__del__(self):""" Release features' memory """ifself.feat:backend.get().af_release_features(self.feat)self.feat=None[docs]defnum_features(self):""" Returns the number of features detected. """num=c_dim_t(0)safe_call(backend.get().af_get_features_num(c_pointer(num),self.feat))returnnum [docs]defget_xpos(self):""" Returns the x-positions of the features detected. """out=Array()safe_call(backend.get().af_get_features_xpos(c_pointer(out.arr),self.feat))returnout [docs]defget_ypos(self):""" Returns the y-positions of the features detected. """out=Array()safe_call(backend.get().af_get_features_ypos(c_pointer(out.arr),self.feat))returnout [docs]defget_score(self):""" Returns the scores of the features detected. """out=Array()safe_call(backend.get().af_get_features_score(c_pointer(out.arr),self.feat))returnout [docs]defget_orientation(self):""" Returns the orientations of the features detected. """out=Array()safe_call(backend.get().af_get_features_orientation(c_pointer(out.arr),self.feat))returnout [docs]defget_size(self):""" Returns the sizes of the features detected. """out=Array()safe_call(backend.get().af_get_features_size(c_pointer(out.arr),self.feat))returnout