https://github.com/mitmul/pybing
A Python wrapper of OpenCV implementation of BING Objectness
https://github.com/mitmul/pybing
Last synced: about 1 year ago
JSON representation
A Python wrapper of OpenCV implementation of BING Objectness
- Host: GitHub
- URL: https://github.com/mitmul/pybing
- Owner: mitmul
- License: mit
- Created: 2015-05-27T18:41:50.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2017-08-18T15:21:29.000Z (almost 9 years ago)
- Last Synced: 2025-03-25T03:41:38.353Z (about 1 year ago)
- Language: C++
- Homepage:
- Size: 10.7 KB
- Stars: 15
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pybing
A Python wrapper of BING-Objectness in OpenCV (3.0.0-dev) implementation
## Requirement
- CMake (>=2.8)
- TBB
- OpenCV (>=3.0.0-dev with opencv_contrib)
- Boost
- Boost.Numpy
## Build bing.so
Modify some parameters to detect TBB, OpenCV, Boost, and Boost.NumPy, and then
$ bash build.sh
It will make `bing.so` in `build` directory.
## Usage
- BING class requires the path of trained model dir and some parameters
- The output of `objectness` method is 2D-array of bounding boxes
- `[[min_x, min_y, max_x, max_y, score],...]`
- Smaller `score` means it has much objectness
- Resulting bounding boxes is already sorted in ascending order of `score`, so it's descending order of objectness
- try `$ 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)
```