Ask Your Question
0

Assertion failed running bof.load(.../.../cbdata.txt)

asked 2012-08-24 04:51:24 -0500

anonymous user

Anonymous

updated 2012-08-24 09:12:46 -0500

Have Windows Vista and latest SimpleCV. I am running successfully some extractors, when starting BOF-extractor I get problem. I downloaded the cbdata.txt and the codebook.png from github and now I get the error while running BOFFeature extractor:

from SimpleCV import Image, HueHistogramFeatureExtractor, EdgeHistogramFeatureExtractor, BOFFeatureExtractor
from numpy import*

# images
bea1 = Image('/Users/Arenzky/Desktop/img_dirs/supervised/beach/beach01.jpg')
bea2 = Image('/Users/Arenzky/Desktop/img_dirs/supervised/beach/beach02.jpg')
bea3 = Image('/Users/Arenzky/Desktop/img_dirs/supervised/beach/beach03.jpg')

    hue = HueHistogramFeatureExtractor(mNBins=16)
    edge = EdgeHistogramFeatureExtractor()
    bof = BOFFeatureExtractor()
    bof.load('../Arenzky/cbdata.txt')

then I get the ERROR

OpenCV Error: Assertion failed (src.depth() == dst.depth() && src.size == dst.si
ze) in unknown function, file C:\slave\WinInstallerMegaPack\src\opencv\modules\c
ore\src\copy.cpp, line 493
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
C:\Python27\lib\site-packages\SimpleCV\Shell\Shell.pyc in <module>()
----> 1 bof.load('../Arenzky/cbdata.txt')

C:\Python27\lib\site-packages\SimpleCV\Features\BOFFeatureExtractor.pyc in load(
self, datafile)
    213                                             self.mNumCodes,
    214                                             self.mLayout,
--> 215                                             self.mPadding)
    216         #print(self.mCodebook)
    217         return

C:\Python27\lib\site-packages\SimpleCV\Features\BOFFeatureExtractor.pyc in _img2
Codebook(self, img, patchsize, count, patch_arrangement, spacersz)
    125                 y = (hidx*patchsize[1])+((hidx+1)*spacersz)
    126                 cv.SetImageROI(lmat,(x,y,w,h))
--> 127                 cv.Copy(lmat,patch)
    128                 cv.ResetImageROI(lmat)
    129                 retVal = np.vstack((retVal,np.array(patch[:,:]).reshape(
length)))

error: src.depth() == dst.depth() && src.size == dst.size

What I am doing wrong? Thanks...

Here are three example image: beach1: http://images2.layoutsparks.com/1/206203/beach-request-blue-sea.jpg
beach2: http://3.bp.blogspot.com/-JSwv_cKSiF4/TWBgWjMEsxI/AAAAAAAACy4/It1i-bIxLuc/s1600/The-best-top-desktop-beach-wallpapers-hd-beach-wallpaper-18.jpg
beach3: http://blog.travelandleisureasia.com/wp-content/uploads/2010/02/Baishawei-Beach.jpg

edit retag flag offensive close merge delete

Comments

This Assertion Error is generally related to the type of the image. In python bindings of OpenCV >= 2.3, it accepts only numpy.ndarray as an image. If you could post more code and exact error, it would be better.

jayrambhia gravatar imagejayrambhia ( 2012-08-24 06:55:55 -0500 )edit

here is the extended part of the code. As you can see images a .jpg.

Arenzky gravatar imageArenzky ( 2012-08-24 07:52:43 -0500 )edit

Could you upload image, and other data somewhere? I'd try it and see what the error is.

jayrambhia gravatar imagejayrambhia ( 2012-08-24 08:52:20 -0500 )edit

see sample images...

Arenzky gravatar imageArenzky ( 2012-08-24 09:13:51 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-08-24 09:25:21 -0500

kscottz gravatar image

This has nothing to do with the images. The problem is probably because the BOFFeature extractor doesn't have the necessary configuration files. I used to have a default one in the repo but I know xamox deleted it at one point. You should be feeding the function a path to your SimpleCV/Features/ directory. Alternatively you can train the bag of features yourself from your data set using the BOFFeatureExtractor.generate method. This should yield better results.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-08-24 04:51:24 -0500

Seen: 563 times

Last updated: Aug 24 '12