how to run BING(salience detection) by python
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()
bing.setTrainingPath(r'modelpath')
bing.setBase(2)
bing.setW(8)
bing.setNSS(2)
bing.setTrainingPath(r'modelpath')
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
are you 250% sure, your image was read at all... ? please check again.
OF course, I can show the image by cv2.imshow(), and everything looks fine.
oh, wait, imho it expects a single channel (w1f.type() == CV_32F), while you have 3 ! try:i was wrong about this. the error is not connected to the input image, but about pretrained model data
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 ) {
exception is from here called from here
are you sure, your 'modelpath' is correct ? it should point here
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. ;)