Ask Your Question
1

Error while loading YAML model file using opencv in android

asked 2018-12-02 23:04:28 -0500

Sar gravatar image

updated 2018-12-03 04:20:39 -0500

berak gravatar image

I am using opencv for facial landmark detection in android. I am using JNI for interaction with library. I have saved "lbfmodel.yaml" file in assets and trying to load :

const char* jnamestr2 = jenv->GetStringUTFChars(jModelFileName, NULL);
cv::String stdFileName2(jnamestr2);
LOGD( "jModelFileName path : %s", jnamestr2);
FacemarkLBF::Params params;
params.model_filename = stdFileName2;
params.cascade_face = stdFileName;
Ptr<FacemarkLBF> facemark = FacemarkLBF::create(params);

But I am receiving error :

Invalid address 0x9b2d2e08 passed to free: value not allocated Fatal signal 6 (SIGABRT), code -6 in tid 27673

I have logged the filepath and it is :

jModelFileName path : /data/user/0/com.ds.openworld/app_model/lbfmodel.yaml

I don't know what is the issue because it is crashing in native part. The model file is also large. Is that an issue?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-12-03 00:41:52 -0500

berak gravatar image

your assets folder is inside a zipped filesystem. opencv can't read from there, you'll have to copy the lbfmodel to your sdcard, then the FacemarkLBF class can load it from there.

you probably already have smilar code in your app to copy / read a cascade xml file for the facedetection, see e.g. here

edit flag offensive delete link more

Comments

1

Hey berak, Thanks for the hint. I will try to load lbfmodel from sdcard.

Sar gravatar imageSar ( 2018-12-03 01:05:07 -0500 )edit
1

Hey berak, Thanks for the help. The model file is loaded but I am receiving a new error : Error: Bad argument (The LBF model is not trained yet. Please provide a trained model.) I am using this model It will be so helpful if you can provide any hint.

Sar gravatar imageSar ( 2018-12-03 04:12:06 -0500 )edit
  • please create the FacemarkLBF without any params (those are only for training)
  • make sure to actually call loadModel() (the constructor alone won't load anything ...)
  • you probably don't need any jni code for this at all
berak gravatar imageberak ( 2018-12-03 04:22:28 -0500 )edit
1

Thanks again Berak, You helped me a lot. But still getting this error : Error: Parsing error (/data/data/com.ds.openworld/app_model/lbfmodel.yaml(12): Invalid dt in Base64 header) in char* icvYMLParseBase64 I have searched a lot but couldn't found anything. Is there anything wrong while downloading the file.

Sar gravatar imageSar ( 2018-12-03 06:19:35 -0500 )edit
1

sounds like you corrupted your model while either downloading or copying.

do some checks

berak gravatar imageberak ( 2018-12-03 06:25:17 -0500 )edit

No luck yet. Same error repeatedly. I have also tried to save file as text and xml as stated here in issue no 5

Sar gravatar imageSar ( 2018-12-04 06:15:51 -0500 )edit

sorry, tried with the desktop java sample, and could not reproduce it

(invalid dt would be this)

berak gravatar imageberak ( 2018-12-04 06:29:05 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-12-02 23:04:28 -0500

Seen: 24 times

Last updated: Dec 03