1

I want to extract BOVW from an image using OpenImaj Library.

I have met the error when I am implementing extractFeatureFromQuantised method of BagOfVisualWords class

    Exception in thread "main" java.lang.IllegalArgumentException: length must be > 0
    at org.openimaj.util.array.SparseBinSearchIntArray.<init> 
    (SparseBinSearchIntArray.java:94)
    at org.openimaj.util.array.SparseBinSearchIntArray.<init>
    (SparseBinSearchIntArray.java:85)
    at org.openimaj.feature.SparseIntFV.<init>(SparseIntFV.java:64)
at org.openimaj.image.feature.local.aggregate.BagOfVisualWords.
    extractFeatureFromQuantised (BagOfVisualWords.java:106)

Below entites used in the method

(BagOfVisualWords.java:106)

     public static <L extends Location>
SparseIntFV
extractFeatureFromQuantised(Collection<QuantisedLocalFeature<L>> qfeatures)
{
    final SparseIntFV fv = new SparseIntFV();

    for (final QuantisedLocalFeature<L> qf : qfeatures) {
        fv.values.increment(qf.id, 1);
    }

    return fv;
}

(SparseIntFV.java:64)

    public SparseIntFV() {
    values = new SparseBinSearchIntArray(0);
}

/**
 * Construct empty FV with given number of bins
 * @param nbins the number of bins in each dimension
 */
public SparseIntFV(int nbins) {
    values = new SparseBinSearchIntArray(nbins);
}

at org.openimaj.util.array.SparseBinSearchIntArray.

    /**
     * Construct the array with the given length
     * @param length the length
     */
    public SparseBinSearchIntArray(int length) {
            this(length, DEFAULT_CAPACITY);
    }

    /**
     * Construct the array with the given length and capacity for non-zero elements
     * @param length the length
     * @param capacity the capacity
     */
    public SparseBinSearchIntArray(int length, int capacity) {
            if (length <= 0) throw new IllegalArgumentException("length must be > 0");
            if (capacity <= 0) throw new IllegalArgumentException
    ("capacity must be > 0");

            this.length = length;
            this.keys = new int[capacity];
            this.values = new int[capacity];
    }
longhua
  • 4,142
  • 21
  • 28
nawara
  • 1,157
  • 3
  • 24
  • 49
  • 1
    From code logic, it will always throw IllegalArgumentException if you use SparseIntFV(). Can you use another constructor, SparseIntFV(int nbins)? – longhua Mar 13 '13 at 12:11
  • SparseIntFV() is used by the Library authors so i can't modify it – nawara Mar 13 '13 at 12:45

0 Answers0