1

I'm using dlib for development of head pose estimation android app. The problem appears only when I'm trying to run my app on samsung nexus (Android 4.4.4). Even on samsung gt-p3110 (with android 4.1.2) it works.

This is my logs:

I/native: jni_head_pose_det.cpp:183 Initializing new HeadPoseEstimation, landmarkPath /storage/emulated/0/Selfear2/data/shape_predictor_68_face_landmarks.dat and mode 0and some params...

A/libc: Fatal signal 6 (SIGABRT) at 0x0000081b (code=-6), thread 2075

While researching on error code I tried this - https://stackoverflow.com/a/34218851/5582959 - (known issue with GetStringUTFChars), but change encoding of landmarkPath didn't help.

Would appreciate any help.

Edit: Code for jniInit method:

jint JNIEXPORT JNICALL DLIB_JNI_METHOD(jniInit)(JNIEnv* env, jobject thiz,
        jstring landmarkPath,
        jint mode,
        jfloat fx,
        jfloat fy,
        jfloat cx,
        jfloat cy,
        jfloat k1,
        jfloat k2,
        jfloat p1,
        jfloat p2,
        jfloat k3) {
// Initialize a new estimator if it's not already there
if (!gHeadPoseEstimationPtr) {
const char* landmarkmodel_path = env->GetStringUTFChars(landmarkPath, 0);
LOG(INFO) << "Initializing new HeadPoseEstimation, landmarkPath " << landmarkmodel_path << " and mode "<< mode << "and some params...";
gHeadPoseEstimationPtr = std::make_shared<HeadPoseEstimation>(landmarkmodel_path, mode, fx, fy, cx, cy, k1, k2, p1, p2, k3);
env->ReleaseStringUTFChars(landmarkPath, landmarkmodel_path);
}
  • landmarkPath = /storage/emulated/0/Selfear2/data/shape_predictor_68_face_landmarks.dat
  • jint mode = 0
  • as jfloat parameters I'm passing zeroes

Constructor for HeadPoseEstimation

HeadPoseEstimation::HeadPoseEstimation(const string& face_detection_model, int mod, 
float fx, float fy, float cx, float cy, 
float k1, float k2, float p1, float p2, float k3) {
// Load face detection and pose estimation models.
detector = get_frontal_face_detector();
deserialize(face_detection_model) >> pose_model;
mode = mod; // Set correct mode

// Set cameraMatrix
cv::Mat m = cv::Mat::zeros(3,3,CV_32F);
cameraMatrix = m;
cameraMatrix(0,0) = fx; // focalLengthX
cameraMatrix(1,1) = fy; // focalLengthY
cameraMatrix(0,2) = cx; // opticalCenterX
cameraMatrix(1,2) = cy; // opticalCenterY
cameraMatrix(2,2) = 1;
LOG(INFO) << "Initialized Camera Matrix with:\n{fx} = " << fx << " {0}" << " {cx} = " << cx 
        << "\n{0}" << " {fy} = " << fy << " {cy} = " << cy <<
        "\n{0} {0} {1}";

distCoeffs = (Mat1d(1, 5) << k1, k2, p1, p2, k3);
LOG(INFO) << "Initialized Default Camera Distortion Matrix with:\n{k1} = " << k1 << " {k2} = " << k2 << " {p1} = " << p1  << " {p2} = " << p2<< " {k3} = " << k3;
 }

Edit 2 After debugging constructor I found that exception was thrown while deserializing:

Error deserializing object of type short
                                                            while 
deserializing a floating point number.
                                                            while 
deserializing a dlib::matrix
                                                            while 
deserializing object of type std::vector
                                                            while 
deserializing object of type std::vector
                                                            while 
deserializing object of type std::vector
Community
  • 1
  • 1
dmtr
  • 214
  • 3
  • 9
  • This question has been partially answeres, maybe you can't understand your error better here http://stackoverflow.com/questions/36693887/what-is-fatal-signal-6-in-android-logcat – Luís Gonçalves Apr 06 '17 at 13:47
  • Based on the logs I'd say your next step is to debug the `HeadPoseEstimation` constructor. – Michael Apr 06 '17 at 13:49
  • @LuísGonçalves as I understood from link there was a problem in blocking ui. Dlib initialization takes about ~15 sec, but I'm handling it from another thread, so ui is not blocked. – dmtr Apr 06 '17 at 14:20
  • 1
    @dmtr this issue happens everytime? Because SIGABRT happens when an internal error happens. Otherwise, you should definitely check your `HeadPoseEstimation` class, since it apparently happens during it's constructor. – Luís Gonçalves Apr 06 '17 at 14:55
  • I would expect more stack trace in your crash report. Who called **libc**? If the crash is in HeadPoseEstimation constructor, check all parameters. One caveat could be that access to the file path landmarmodel_path is rejected. – Alex Cohn Apr 06 '17 at 14:56
  • @LuísGonçalves crash happens every time method has been called. I debugged jniInit method and found out that landmarkModelPath has 7 '\u0000' symbols at the end. Could this chars putted in GetStringUTFChars method cause crash? – dmtr Apr 06 '17 at 15:08
  • @AlexCohn As I wrote in comment above, I've found '\u0000' symbols at the end of landmarkModelPath, so could they cause crash? – dmtr Apr 06 '17 at 15:10
  • I cannot find the constructor for `HeadPoseEstimation` class that you use, with 11 parameters; I guess it's your wrapper around **dlib**. Please share your code, it could help here. – Alex Cohn Apr 06 '17 at 16:18
  • @AlexCohn I added code for constructor. Most confusing thing for me is that app is not crashing on other devices, even with lower cpu and andoird api level. – dmtr Apr 06 '17 at 20:41
  • so now we are missing the code of `deserialize(const string&)` where the crash happens – Alex Cohn Apr 24 '17 at 18:18

0 Answers0