-
Notifications
You must be signed in to change notification settings - Fork 5
/
gSLICrPy.py
85 lines (79 loc) · 2.52 KB
/
gSLICrPy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import ctypes
from ctypes import POINTER
def __get_CUDA_gSLICr__(path_to_shared='./build/libDEMO.so'):
"""
:return: Callable
"""
dll = ctypes.CDLL(path_to_shared, mode=ctypes.RTLD_GLOBAL)
func = dll.CUDA_gSLICr
"""
int* CUDA_gSLICr(unsigned char* image,
int img_size_x,
int img_size_y,
int n_segs,
int spixel_size,
float coh_weight,
int n_iters,
int color_space,
int segment_color_space,
bool segment_by_size,
bool enforce_connectivity,
char* out_name)
"""
func.argtypes = [POINTER(ctypes.c_uint8),
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_float,
ctypes.c_int,
ctypes.c_int,
ctypes.c_int,
ctypes.c_bool,
ctypes.c_bool,
ctypes.c_char_p]
# POINTER(c_char) or ctypes.c_char_p ?
return func
def CUDA_gSLICr(__get_CUDA_gSLICr__,
image,
img_size_x,
img_size_y,
n_segs,
spixel_size,
coh_weight,
n_iters,
color_space,
segment_color_space,
segment_by_size,
enforce_connectivity,
out_name):
"""
:param __get_CUDA_gSLICrm__:
:param image:
:param img_size_x:
:param img_size_y:
:param n_segs:
:param spixel_size:
:param coh_weight:
:param n_iters:
:param color_space:
:param segment_color_space:
:param segment_by_size:
:param enforce_connectivity:
:param out_name:
:return:
"""
image = image.ctypes.data_as(POINTER(ctypes.c_uint8))
out_name = out_name.encode('utf-8')
return __get_CUDA_gSLICr__(image,
img_size_x,
img_size_y,
n_segs,
spixel_size,
coh_weight,
n_iters,
color_space,
segment_color_space,
segment_by_size,
enforce_connectivity,
out_name)