From c52c7f4bfb1133456b225e25a4ada94ad25e1e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 20 May 2015 07:38:47 -0700 Subject: [PATCH] Do not acquire GIL for ORB --- skimage/feature/orb_cy.pyx | 35 ++++++++++++++++--------------- skimage/feature/tests/test_orb.py | 2 ++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/skimage/feature/orb_cy.pyx b/skimage/feature/orb_cy.pyx index 49c4e650..b3140aa5 100644 --- a/skimage/feature/orb_cy.pyx +++ b/skimage/feature/orb_cy.pyx @@ -30,27 +30,28 @@ def _orb_loop(double[:, ::1] image, Py_ssize_t[:, ::1] keypoints, cdef signed char[:, ::1] cpos0 = POS0 cdef signed char[:, ::1] cpos1 = POS1 - for i in range(descriptors.shape[0]): + with nogil: + for i in range(descriptors.shape[0]): - angle = orientations[i] - sin_a = sin(angle) - cos_a = cos(angle) + angle = orientations[i] + sin_a = sin(angle) + cos_a = cos(angle) - kr = keypoints[i, 0] - kc = keypoints[i, 1] + kr = keypoints[i, 0] + kc = keypoints[i, 1] - for j in range(descriptors.shape[1]): - pr0 = cpos0[j, 0] - pc0 = cpos0[j, 1] - pr1 = cpos1[j, 0] - pc1 = cpos1[j, 1] + for j in range(descriptors.shape[1]): + pr0 = cpos0[j, 0] + pc0 = cpos0[j, 1] + pr1 = cpos1[j, 0] + pc1 = cpos1[j, 1] - spr0 = round(sin_a * pr0 + cos_a * pc0) - spc0 = round(cos_a * pr0 - sin_a * pc0) - spr1 = round(sin_a * pr1 + cos_a * pc1) - spc1 = round(cos_a * pr1 - sin_a * pc1) + spr0 = round(sin_a * pr0 + cos_a * pc0) + spc0 = round(cos_a * pr0 - sin_a * pc0) + spr1 = round(sin_a * pr1 + cos_a * pc1) + spc1 = round(cos_a * pr1 - sin_a * pc1) - if image[kr + spr0, kc + spc0] < image[kr + spr1, kc + spc1]: - descriptors[i, j] = True + if image[kr + spr0, kc + spc0] < image[kr + spr1, kc + spc1]: + descriptors[i, j] = True return np.asarray(descriptors) diff --git a/skimage/feature/tests/test_orb.py b/skimage/feature/tests/test_orb.py index 5bed2bf3..8895d857 100644 --- a/skimage/feature/tests/test_orb.py +++ b/skimage/feature/tests/test_orb.py @@ -3,11 +3,13 @@ from numpy.testing import assert_equal, assert_almost_equal, run_module_suite from skimage.feature import ORB from skimage import data from skimage.color import rgb2gray +from skimage._shared.testing import test_parallel img = rgb2gray(data.lena()) +@test_parallel() def test_keypoints_orb_desired_no_of_keypoints(): detector_extractor = ORB(n_keypoints=10, fast_n=12, fast_threshold=0.20) detector_extractor.detect(img)