- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用 SURF 算法进行对象识别。我正在使用 Google 的 OpenCV 2.4.11 和 Camera2BasicExample。正在构造函数中提取特征,但它会导致 detectNotes 函数中出现段错误。
我尝试在互联网上搜索,但没有找到任何相关的解决方案。
我在下面附加了 SURFDetector 类:
public class SURFDetector {
private FeatureDetector featureDetector;
private DescriptorExtractor descriptorExtractor;
private DescriptorMatcher descriptorMatcher;
private HashMap<String, Mat> notes;
private HashMap<String, MatOfKeyPoint> notesKeyPoints;
private HashMap<String, KeyPoint[]> keyPoints;
private HashMap<String, MatOfKeyPoint> notesDescriptors;
public SURFDetector() { }
public SURFDetector(AssetManager assets) {
featureDetector = FeatureDetector.create(FeatureDetector.SURF);
descriptorExtractor = DescriptorExtractor.create(DescriptorExtractor.SURF);
descriptorMatcher = DescriptorMatcher.create(DescriptorMatcher.FLANNBASED);
notes = new HashMap<String, Mat>();
notesKeyPoints = new HashMap<String, MatOfKeyPoint>();
keyPoints = new HashMap<String, KeyPoint[]>();
notesDescriptors = new HashMap<String, MatOfKeyPoint>();
try {
String[] names = assets.list("");
for(String name:names) {
if (name.contains("India")) {
Mat note = Highgui.imread(name, Highgui.CV_LOAD_IMAGE_COLOR);
notes.put(name, note);
MatOfKeyPoint kp = new MatOfKeyPoint();
featureDetector.detect(note, kp);
notesKeyPoints.put(name, kp);
keyPoints.put(name, kp.toArray());
MatOfKeyPoint d = new MatOfKeyPoint();
descriptorExtractor.compute(note, kp, d);
notesDescriptors.put(name, new MatOfKeyPoint());
Log.i("SURF", name +
"\nImage: " + notes.get(name).toString() +
"\nkeyPoints: " + keyPoints.get(name).toString() +
"\nMat: " + note.toString());
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
public String detectNotes(Image image) {
featureDetector = FeatureDetector.create(FeatureDetector.SURF);
descriptorExtractor = DescriptorExtractor.create(DescriptorExtractor.SURF);
descriptorMatcher = DescriptorMatcher.create(DescriptorMatcher.FLANNBASED);
Log.v("SIGSEGV", "Converting image to Mat");
Mat buf = new Mat(image.getHeight(), image.getWidth(), CvType.CV_8UC1);
ByteBuffer buffer = image.getPlanes()[0].getBuffer();
byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes);
buf.put(0, 0, bytes);
Log.v("SIGSEGV", "Image -> Mat done");
Mat scene = Highgui.imdecode(buf, Highgui.IMREAD_COLOR);
MatOfKeyPoint sceneKeyPoints = new MatOfKeyPoint();
MatOfKeyPoint sceneDescriptors = new MatOfKeyPoint();
Mat grayScene = new Mat();
Imgproc.cvtColor(scene, grayScene, Imgproc.COLOR_BGR2GRAY);
Log.v("SIGSEGV", scene.toString());
Log.v("SIGSEGV", sceneKeyPoints.toString());
Log.v("SIGSEGV", sceneDescriptors.toString());
Log.v("SIGSEGV", "Feature detection");
featureDetector.detect(grayScene, sceneKeyPoints);
Log.v("SIGSEGV", "SceneKeyPoints detected");
descriptorExtractor.compute(grayScene, sceneKeyPoints, sceneDescriptors);
Log.v("SIGSEGV", "Feature detection done");
float nndrRatio = 0.7f;
Log.v("SIGSEGV", "Loop over all the images");
for(String key : notesDescriptors.keySet()) {
List<MatOfDMatch> matches = new LinkedList<MatOfDMatch>();
LinkedList<DMatch> goodMatchesList = new LinkedList<DMatch>();
descriptorMatcher.knnMatch(notesDescriptors.get(key), sceneDescriptors, matches, 2);
for(int i = 0; i < matches.size(); i++) {
MatOfDMatch matOfDMatch = matches.get(i);
DMatch[] dmatchArray = matOfDMatch.toArray();
DMatch m1 = dmatchArray[0];
DMatch m2 = dmatchArray[1];
if(m1.distance <= m2.distance * nndrRatio) {
goodMatchesList.add(m1);
}
if(goodMatchesList.size() >= 7) {
Log.i("SURF", "Match Found: " + key);
return key;
}
}
}
Log.v("SIGSEGV", "Loop done");
Log.i("SURF", "Match Not Found!");
return null;
}
}
确切的错误:
04-13 19:46:37.903 4314-4375/com.example.android.camera2basic A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 4375 (CameraBackgroun)
04-13 19:46:37.968 2205-2205/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/o5ltedd/o5lte:6.0.1/MMB29K/G550FYDDU1BRD1:user/release-keys'
Revision: '0'
ABI: 'arm'
pid: 4314, tid: 4375, name: CameraBackgroun >>> com.example.android.camera2basic <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
请帮帮我。
最佳答案
我在您的代码中没有看到以下内容,因此您可能需要添加以下内容:static { System.loadLibrary("opencv_java");}
这也是 Android 上 OpenCV 的重要资源: https://opencv.org/platforms/android/
关于android - 如何修复 FeatureDetector.detect (OpenCV-2.4.11 Android) 中的段错误 (SIGSEGV)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55666475/
这个问题是针对 Linux 提出的。使用 GCC 编译器。 如果 SIGSEGV(我的意思是通常会导致 SIGSEGV 的违规行为)发生在旨在捕获 SIGSEGV 的信号处理程序中,可以预期会有什么行
我正在构建一个 C++ 程序,我需要在其中处理 SIGSEGV 并且信号处理程序应该能够打印回溯。任何人都可以帮忙吗。 问候 最佳答案 获得 SIGSEV 回溯的最好方法是生成核心文件而不是打印回溯。
我有一个屏幕A,在执行了一些POST API任务后,我启用了一个按钮,然后单击按钮导航到屏幕B。当Reaction Native应用程序冻结并崩溃时,崩溃会随机发生。从其他屏幕导航到屏幕B也不是问题,
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
我正在编写这个方法(C 语言),它应该为链表创建一个新节点。它在第一个 if (SIGSEGV 信号)之后的行崩溃 我正在调试该方法,因此后续行中可能会有更多错误,但目前我将感谢有关此特定行的任何观察
这是我的比较函数: int compareInts(const void *a, const void *b) { const int *pa = (const int*)a; con
我一直在研究一些有缺陷的代码,并想安装一个 SIGSEGV 处理程序来获取有关崩溃的更多信息。但是,我注意到我的处理程序没有被调用。 我一直在寻找原因,它似乎与损坏的堆栈指针值有关(它肯定没有被屏蔽)
我是编码新手。当我在 codecheff 中提交代码时,它给出“运行时错误(SIGSEGV)”。我不知道有什么问题请帮忙。提前致谢。 int call(int *x, int m) { int
CodeChef 问题: Shivam 是世界上最年轻的程序员,他只有 12 岁。 Shivam 正在学习编程,今天他正在编写他的第一个程序。 程序很简单,给定两个整数A和B,编写一个程序将这两个数字
我正在编写一个编程问题的解决方案。问题如下: Your program is to use the brute-force approach in order to find the Answer t
好吧,只是为了好玩,我正在研究埃拉托色尼筛。它最初运行良好,因此我寻求提高其运行时复杂性。现在,我不知道为什么,但我遇到了段错误。代码如下: #include #include int main(
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我正在创建一个简单的链表程序来插入和查看 LL 的元素。当我尝试插入第二个元素时,它给出 SIGSEV,但我不明白为什么?!! 请帮我指出问题: main.c: #include #includ
我试图提交此代码以解决 hackerearth 上的问题,但我得到了此 SIGSEGV 运行时错误。我读到了这个错误,但我无法让我的代码工作。有人说这是由于无效的内存引用、数组的动态初始化或数组索引超
我正在思考 leetcode 问题 167,但我的代码遇到了段错误 (SIGSEGV) 问题。下面是我的c代码,预期的答案是[1,3]。 #include #include /** * Return
我有一个在ARM平台上运行的多线程程序。在其中一个线程中,我将调用 system() 来运行某些 shell 命令。最近,我发现有时候,由system() fork 的子进程会以SIGSEGV终止。
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
我很高兴知道为什么我遇到此错误 http://www.codechef.com/problems/AXR1P2在 codechef.com 中,我的代码是... #include #include i
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我正在使用 POSIX 套接字在 Android 上编写一些网络代码,但是当我调用 Sento 时,我收到了一个奇怪的 SIGSEGV(信号 11,代码 1)。我已经使用墓碑跟踪来确定它是哪一行,但坦
我是一名优秀的程序员,十分优秀!