Ask Your Question
0

(OpenCv Java) FaceMark: Exception: bad allocation during using FaceMark for loadModel

asked 2018-10-20 03:05:21 -0600

jayaise gravatar image

updated 2018-10-20 03:20:50 -0600

berak gravatar image

// detect faces Hi I am facing exception when I trying to load FaceLandMark Model using loadModel, Can you please help here,

Code:

    cascade.detectMultiScale(img, faces);
    // setup landmarks detector
    Facemark fm = Face.createFacemarkKazemi();
    fm.loadModel("C:\\Users\\Jayashree\\Desktop\\Faces_Oct18th\\model\\flandmark_model.dat");

Exceptions as below:

Exception in thread "main" java.lang.Exception: std::exception: bad allocation
at org.opencv.face.Facemark.loadModel_0(Native Method)
at org.opencv.face.Facemark.loadModel(Facemark.java:49)
at opencv3433.FaceLandMark1.main(FaceLandMark1.java:61)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-10-20 03:21:37 -0600

berak gravatar image

updated 2018-10-20 03:34:53 -0600

bad allocation means: you're out of memory ! (huge model, ~97mb)

  • watch your resources in the Task-manager
  • try to assign more memory to your java process (-Xmx)
  • check, if you built 32bit opencv libs (4gb limit), if so, try with 64bit
  • the LBF model is only half the size (and also more precise, imho)
edit flag offensive delete link more

Comments

I made Java vm args to 2056 in eclipse but still no luck.

Code changed to createFacemarkLBF() :

    Facemark fm = Face.createFacemarkLBF();//.createFacemarkKazemi();
    fm.loadModel("C:\\Users\\Jayashree\\Desktop\\Faces_Oct18th\\model\\flandmark_model.dat");

Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: OpenCV(3.4.3) C:\opencv343\opencv-3.4.3\modules\core\src\persistence_c.cpp:388: error: (-49:Unknown error code -49) Input file is empty in function 'cvOpenFileStorage'
]

at org.opencv.face.Facemark.loadModel_0(Native Method)
at org.opencv.face.Facemark.loadModel(Facemark.java:49)
at opencv3433.FaceLandMark1.main(FaceLandMark1.java:61)

loading data from : C:\Users\Jayashree\Desktop\Faces_Oct18th\model\flandmark_model.dat
jayaise gravatar imagejayaise ( 2018-10-20 05:47:29 -0600 )edit

Also where to make changes to build opencv libs to 64 bit

jayaise gravatar imagejayaise ( 2018-10-20 05:48:20 -0600 )edit

you need another model for lbf: https://raw.githubusercontent.com/kur...

berak gravatar imageberak ( 2018-10-20 06:21:42 -0600 )edit
1

Thanks this helped

jayaise gravatar imagejayaise ( 2018-10-20 06:56:02 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-10-20 03:05:21 -0600

Seen: 749 times

Last updated: Oct 20 '18