EXCEPTION_ACCESS_VIOLATION JNI Windows on detect_all_faces() and detect_one_face() in vjfacedetect.cpp c0000374 c0000005 OpenCV 2.49

120 views
Skip to first unread message

shane harris

unread,
Jul 17, 2014, 8:01:26 AM7/17/14
to asmli...@googlegroups.com
Hi there!

Great library by the way I have been having a lot of fun with it over the last few days.

First of all I im using x86 OpenCV 2.49 with Visual Studio Express 2010 and ASMLibrary of coarse.

I have been using the library to extract facial points and for now just print them to the screen. I plan to write them to a CSV file later. 

I have successfully integrated the library into both android and windows applications. I first modified demo_fit to print the points to the console rather than display an image, I also modified the source to accept a CSV string of images rather than just one meaning it would only initialize the cascades once and then iterate over each image. This all worked fantastically!!

I then decided to write a JNI wrapper dll for windows almost identical to the JNI wrapper in the android demo. This was a relatively painless process except that the FastCascadeDetector had to be removed as this is only supported on *NIX platforms. Other than that I managed to integrate directly with Java and successfully load the required DLL files and get a working example. Below is a list of the DLL files in order of load. 


System.loadLibrary("opencv_java249");
System.loadLibrary("opencv_core249");
System.loadLibrary("opencv_imgproc249");
  System.loadLibrary("opencv_highgui249");
  System.loadLibrary("opencv_objdetect249");
  System.loadLibrary("asmlibrary"); 
  System.loadLibrary("Sensum-ASM"); // My JNI wrapper dll.

then i load the cascades with the following methods. I am using the included 'my68-1d.amf' and 'haarcascade_frontalface_alt2.xml'.

nativeReadModel
nativeInitCascadeDetector
    

/*
...

I then do some openCV VideoCapture stuff and get a frame in a Mat
*/

Here is where the problem occurs.

After about 10 loops on the native functions below the javaw.exe crashes with a native exception. I have attached the crash log to this post for your review. I have only invoked either of the below methods and not the actual 'nativeFitting' or 'nativeVideoFitting' methods so I guess the problem lies with the initial face detection. 

I have tested both running the code inside a loop and just timed interval iterations using Thread.sleep(1000) and the result is the same, about 10-11 loops and it fails.



/**
* This function can only be used after nativeInitCascadeDetector()
* @param imageGray original gray image 
* @param face all faces' feature points 
* @return true if found faces, false otherwise
*/
public boolean detectAll(Mat imageGray, Mat faces){
return nativeDetectAll(imageGray.getNativeObjAddr(), 
faces.getNativeObjAddr());
}
/**
* This function can only be used after nativeInitCascadeDetector()
* @param imageGray original gray image 
* @param faces only one face's feature points 
* @return true if found faces, false otherwise
*/
public boolean detectOne(Mat imageGray, Mat face){
return nativeDetectOne(imageGray.getNativeObjAddr(), 
face.getNativeObjAddr());
}


I would be most greatful if you had any insight into what could cause this issue. 

Thanks in advance,

Shane
hs_err_pid2924.log

Miroslav Glamuzina

unread,
Jul 17, 2014, 6:22:42 PM7/17/14
to asmli...@googlegroups.com
hey there, when i tried this library a couple months ago, i found that the only solution for me was to use OpenCv version 1.0... This seemed to have been the simplest fix (although others have made it work on other versions of opencv). I guess it totally depends on what you are going to be using it for. Good luck!



--

---
You received this message because you are subscribed to the Google Groups "ASMLibrary" group.
To unsubscribe from this group and stop receiving emails from it, send an email to asmlibrary+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

shane harris

unread,
Jul 18, 2014, 3:15:05 AM7/18/14
to asmli...@googlegroups.com
Hi there Miroslav!

Thanks for your interest! Did you experience a similar problem to the one i have described above? I am considering going back to opencv 1.0 but its just I've come so far and it seems like I am so close. If I can solve this issue I can then publish code alongside the ASMLibrary as a java binding for windows. I guess I could also do that with openCV 1.0.

In the source files (MSVC) it seems the asmlibrary was most recently built from OpenCV 2.20 ( according to the additional libraries attached to the solution in MSVC) so it apears that it does support OpenCV 2+.

Oh Great Yao! I can provide source code maybe we can look at this together and add a new platform to the support arsenal!

Thanks!

Shane

shane harris

unread,
Jul 22, 2014, 2:27:01 AM7/22/14
to asmli...@googlegroups.com
So i tried opencv 1.0,opencv 2.2 and also 2.49.

Error persists.

:(

Miroslav Glamuzina

unread,
Jul 22, 2014, 6:07:22 PM7/22/14
to asmli...@googlegroups.com
sorry for the late response, i've been out of town. What again was the exact error? (was it that it just would not run?).

nju...@gmail.com

unread,
Jul 29, 2014, 12:38:22 AM7/29/14
to asmlibrary, shakamone

You must implement nativeDetectAll/nativeDetectOne as I implemented in android/Demofit.cpp: 
1. call opencv objdetect function to get 2-points shape
2. call InitShapeFromDetBox function to get 68-points shape

--
Reply all
Reply to author
Forward
0 new messages