java.lang.IllegalArgumentException异常

时间:2013-03-13 11:42:21

标签: java exception openimaj

我想使用OpenImaj Library从图像中提取BOVW。

我在实现BagOfVisualWords类的extractFeatureFromQuantised方法时遇到了错误

    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)

方法中使用的entites

(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];
    }

0 个答案:

没有答案