Ask Your Question

how to run BING(salience detection) by python

asked 2017-10-15 20:46:52 -0500

Hello All, I would like to run BING to detect the object proposal in python. Here is my sample code.

import cv2
bing = cv2.saliency.ObjectnessBING_create()
img = cv2.imread('1.jpg')
ret = bing.computeSaliency(img.astype(np.float32))

However, I meet the following erros:

cv2.error: D:\Build\OpenCV\opencv_contrib-3.3.0\modules\saliency\src\BING\FilterTIG.cpp:74: error: (-215) w1f.cols * w1f.rows == D && w1f.type() == CV_32F && w1f.isContinuous() in function cv::saliency::ObjectnessBING::FilterTIG::update

I guess the last condition is not met. (w1f.isContinuous())

How to make the image in opencv to continuous? thanks in advance.

best, xueliang

edit retag flag offensive close merge delete


are you 250% sure, your image was read at all... ? please check again.

berak gravatar imageberak ( 2017-10-15 23:43:07 -0500 )edit

OF course, I can show the image by cv2.imshow(), and everything looks fine.

liuxueliang gravatar imageliuxueliang ( 2017-10-16 05:39:08 -0500 )edit

oh, wait, imho it expects a single channel (w1f.type() == CV_32F), while you have 3 ! try:

img = cv2.imread('1.jpg', 0)

i was wrong about this. the error is not connected to the input image, but about pretrained model data

berak gravatar imageberak ( 2017-10-16 07:20:39 -0500 )edit

Thanks for your attention on this question. There is nothing about the channel. After reading the source code, I find D is constant and is 64. But I don not know what is FilterTIG. void ObjectnessBING::FilterTIG::update( Mat &w1f ) {

liuxueliang gravatar imageliuxueliang ( 2017-10-17 06:35:44 -0500 )edit

exception is from here called from here

are you sure, your 'modelpath' is correct ? it should point here

berak gravatar imageberak ( 2017-10-17 07:00:30 -0500 )edit

can you do me a favour, and try with a wrong modelpath ? you should get the same exception. (which imho is a bug, that should have been caught earlier on)

so, if you could reproduce it, i'd be happy. ;)

berak gravatar imageberak ( 2017-10-17 07:34:44 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-10-17 07:05:26 -0500

updated 2017-10-17 07:06:18 -0500

I know what is the problem, I just set maxbgr and hsv, but forget g,(the color space). Thank you very much.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-10-15 20:46:52 -0500

Seen: 661 times

Last updated: Oct 15 '17