A Python wrapper of OpenCV implementation of BING Objectness
MIT License
A Python wrapper of BING-Objectness in OpenCV (3.0.0-dev) implementation
Modify some parameters to detect TBB, OpenCV, Boost, and Boost.NumPy, and then
$ bash build.sh
It will make bing.so
in build
directory.
objectness
method is 2D-array of bounding boxes
[[min_x, min_y, max_x, max_y, score],...]
score
means it has much objectnessscore
, so it's descending order of objectness$ python scripts/test_bing.py
import cv2 as cv
import bing
b = 2 # base_window_size_quantization
w = 8 # window_size
n = 2 # non_maximal_supress_size
binger = bing.BING('build/ObjectnessTrainedModel', b, w, n)
img = cv.imread('sample.jpg')
canvas = np.zeros((img.shape[0], img.shape[1]), dtype=np.float32)
bbox = binger.objectness(img)
for b in bbox:
x1, y1, x2, y2 = [int(a) for a in b[:4]]
s = b[-1]
canvas[y1:y2, x1:x2] += s
canvas /= np.max(canvas)
cv.imwrite('sample_result.jpg', canvas * 255)