我一直在编程FaceRecognizer库的Java版本。我可以在Java OpenCV项目中成功初始化一个新的FaceRecognizer(默认情况下为Fisherface)。我使用JNA来完成此任务。但是最近,我发现“train”方法存在错误,因此我决定在DLL文件中进行整个识别,最后返回一个 double 值。但是当我像这样制作一个新的FaceRecognizer时:

Ptr<FaceRecognizer> model = Algorithm::create<FaceRecognizer>("FaceRecognizer.Fisherfaces");

要么
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();

它确实可以编译并成功构建!但是当我用它们像这样训练时:
model->train(libList,idList);

(libList是 vector ,idList是 vector )

JVM(通过JNA到我的Java OpenCV项目)。

它说 :
A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x60b2510b, pid=31264, tid=13256

Problematic frame:
C  [opencv_core248.dll+0x510b]

我猜想这与引用或指针有关,因为即使我运行
model->name();

它也会崩溃。似乎是“模型”存在问题。
非常感谢您的帮助!非常感谢你!

这是记录的文件:
---------------  T H R E A D  ---------------

Current thread (0x0008bc00):  JavaThread "main" [_thread_in_native, id=13256,     stack(0x01070000,0x010c0000)]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:
EAX=0x010bf098, EBX=0x00000000, ECX=0x00000000, EDX=0x08da0174
ESP=0x010bf08c, EBP=0x010bf0a4, ESI=0x010bf0b0, EDI=0x010bf3e4
EIP=0x60b2510b, EFLAGS=0x00010286

Top of Stack: (sp=0x010bf08c)
0x010bf08c:   bdaf0099 010bf0b0 00000000 010bf3e4
0x010bf09c:   60c941e9 ffffffff 010bf3f0 61e42598
0x010bf0ac:   010bf198 bdac87d8 010bf490 00000000
0x010bf0bc:   00000000 010bf148 010bf148 010bf120
0x010bf0cc:   010bf120 cccccccc 00000000 cccccccc
0x010bf0dc:   cccccccc 42ff0000 00000000 00000000
0x010bf0ec:   00000000 00000000 00000000 00000000
0x010bf0fc:   00000000 00000000 00000000 010bf0e8

Instructions: (pc=0x60b2510b)
0x60b250eb:   a1 00 00 00 00 50 51 56 a1 e0 37 d1 60 33 c5 50
0x60b250fb:   8d 45 f4 64 a3 00 00 00 00 c7 45 f0 00 00 00 00
0x60b2510b:   8b 01 8b 75 08 8b 50 0c 56 ff d2 8b c8 e8 e3 f7
0x60b2511b:   ff ff c7 45 fc 00 00 00 00 c7 45 f0 01 00 00 00


Register to memory mapping:

EAX=0x010bf098 is pointing into the stack for thread: 0x0008bc00
EBX=0x00000000 is an unknown value
ECX=0x00000000 is an unknown value
EDX=0x08da0174 is an unknown value
ESP=0x010bf08c is pointing into the stack for thread: 0x0008bc00
EBP=0x010bf0a4 is pointing into the stack for thread: 0x0008bc00
ESI=0x010bf0b0 is pointing into the stack for thread: 0x0008bc00
EDI=0x010bf3e4 is pointing into the stack for thread: 0x0008bc00

最佳答案

我搞定了!是的,“createFisherFaceRecognizer()”存在问题,因为它源自“cv.hpp”。它显示在Visual Studio的IntelliSnse中,因为它来自类Cv,但是我没有导入正确的库。我在每个opencv.lib文件的末尾添加了“d”,并且还导入了cvcore和cvcorex。现在可以了。如果您遇到像我这样的问题,可能就是这样。完成后,我将很高兴分享我的代码。

关于java - Opencv JNA&C++ FaceRecognizer导致JVM崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22117353/

10-12 05:46