4

我正在OpenCV为我的项目使用,一切正常,除了DescriptorExtractor.java. 它每天都给我以下错误:

/opencv/src/org/opencv/features2d/DescriptorExtractor.java
Error:(26, 29) error: illegal forward reference
Error:(27, 29) error: illegal forward reference
Error:(28, 28) error: illegal forward reference
Error:(29, 30) error: illegal forward reference
Error:(30, 30) error: illegal forward reference
Error:(31, 30) error: illegal forward reference
Error:(32, 30) error: illegal forward reference

该文件最初如下所示:

public class DescriptorExtractor {

    public static final int
            SIFT = 1,
            SURF = 2,
            ORB = 3,
            BRIEF = 4,
            BRISK = 5,
            FREAK = 6,
            AKAZE = 7,
            OPPONENT_SIFT = OPPONENTEXTRACTOR + SIFT,
            OPPONENT_SURF = OPPONENTEXTRACTOR + SURF,
            OPPONENT_ORB = OPPONENTEXTRACTOR + ORB,
            OPPONENT_BRIEF = OPPONENTEXTRACTOR + BRIEF,
            OPPONENT_BRISK = OPPONENTEXTRACTOR + BRISK,
            OPPONENT_FREAK = OPPONENTEXTRACTOR + FREAK,
            OPPONENT_AKAZE = OPPONENTEXTRACTOR + AKAZE;
    private static final int
            OPPONENTEXTRACTOR = 1000;
    protected final long nativeObj;

每天我都将 declerationOPPONENTEXTRACTOR移到班级的顶部,问题就消失了。但是第二天课程又恢复到原来的样子。在类的顶部有一个评论

//
// This file is auto-generated. Please don't modify it!
//

我应该怎么办?我该如何防止这种情况?

更新:

我正在为 Android 3.0 和 Java 7.80 使用 OpenCV

4

1 回答 1

0

您的申报顺序错误。它应该是这样的:

private static final int OPPONENTEXTRACTOR = 1000;

public static final int
        SIFT = 1,
        SURF = 2,
        ORB = 3,
        BRIEF = 4,
        BRISK = 5,
        FREAK = 6,
        AKAZE = 7,
        OPPONENT_SIFT = OPPONENTEXTRACTOR + SIFT,
        OPPONENT_SURF = OPPONENTEXTRACTOR + SURF,
        OPPONENT_ORB = OPPONENTEXTRACTOR + ORB,
        OPPONENT_BRIEF = OPPONENTEXTRACTOR + BRIEF,
        OPPONENT_BRISK = OPPONENTEXTRACTOR + BRISK,
        OPPONENT_FREAK = OPPONENTEXTRACTOR + FREAK,
        OPPONENT_AKAZE = OPPONENTEXTRACTOR + AKAZE;
于 2021-06-08T11:38:55.203 回答