Skip to content

Commit 5082e00

Browse files
committed
FEAT: Adding vision functions
1 parent 9d1380f commit 5082e00

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

arrayfire/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
from .signal import *
2020
from .image import *
2121
from .features import *
22+
from .vision import *

arrayfire/vision.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#######################################################
2+
# Copyright (c) 2015, ArrayFire
3+
# All rights reserved.
4+
#
5+
# This file is distributed under 3-clause BSD license.
6+
# The complete license agreement can be obtained at:
7+
# http://arrayfire.com/licenses/BSD-3-Clause
8+
########################################################
9+
from .library import *
10+
from .array import *
11+
from .features import *
12+
13+
def fast(image, threshold=20.0, arc_length=9, non_max=True, feature_ratio=0.05, edge=3):
14+
out = features()
15+
safe_call(clib.af_fast(pointer(out.feat),\
16+
image.arr, c_float(threshold), c_uint(arc_length), non_max, \
17+
c_float(feature_ratio), c_uint(edge)))
18+
return out
19+
20+
def orb(image, threshold=20.0, max_features=400, scale = 1.5, num_levels = 4, blur_image = False):
21+
feat = features()
22+
desc = array()
23+
safe_call(clib.af_orb(pointer(feat.feat), pointer(desc.arr),\
24+
c_float(threshold), c_uint(max_features),\
25+
c_float(scale), c_uint(num_levels), blur_image))
26+
return feat, desc
27+
28+
def hamming_matcher(query, database, dim = 0, num_nearest = 1):
29+
index = array()
30+
dist = array()
31+
safe_call(clib.af_hamming_matcher(pointer(idx.arr), pointer(dist.arr),\
32+
query.arr, database.arr, \
33+
c_longlong(dim), c_longlong(num_nearest)))
34+
return index, dist
35+
36+
def match_template(image, template, match_type = AF_SAD):
37+
out = array()
38+
safe_call(clib.af_match_template(pointer(out.arr), image.arr, template.arr, match_type))
39+
return out

0 commit comments

Comments
 (0)