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