我一直在編寫Java版本的FaceRecognizer庫。我可以在我的Java OpenCV項目中成功初始化一個新的FaceRecognizer(Fisherface作爲默認設置)。我用JNA來完成這個任務。但最近,我發現「火車」方法有錯誤,所以我決定在DLL文件中完成整個識別並最終返回一個double值。但是,當我做了一個新的FaceRecognizer這樣的:Opencv JNA和C++ FaceRecognizer導致JVM崩潰
Ptr<FaceRecognizer> model = Algorithm::create<FaceRecognizer>("FaceRecognizer.Fisherfaces");
或
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
它編譯併成功打造!但是,當我用它們來培養這樣的:
model->train(libList,idList);
(libList爲載體,IDLIST是矢量)
的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
什麼是:Ptr?如果它持有指向某個分配的指針,並在函數返回時被銷燬(如'std :: unique_ptr'),那就是您的訪問衝突的地方。你能顯示'整個'日誌文件嗎?也很高興看到JNI代碼(代碼將數據傳遞給java端)。 –
Brandon
是的,請顯示jni包裝方法。 – berak
我完成我的項目後,我會在我的博客上分享它,但我需要幫助。我發現內存地址被創建,但內存地址的值是NULL。另外,當我要求算法爲「getList」時,它也會崩潰。任何調用指針或引用的東西都會讓我覺得這是「createFisherFaceRecognizer()」問題。我認爲這是與我可能錯過的圖書館進口。你的想法? –