Attention! This forum will be made read-only by Dec-20. Please migrate to Most of existing active users should've received invitation by e-mail.
Ask Your Question

traincascade error - _cascadeDirName or _bgfileName or _vecFileName is NULL

asked 2015-09-10 14:36:01 -0500

kburnham gravatar image


I am trying to train a cascade classifier with opencv_traincascade, but I keep getting the error:

_cascadeDirName or _bgfileName or _vecFileName is NULL

The specific command I am using is:

./opencv_traincascade vec ~/Documents/Kaggle/whale_faces.vec -data ~/Documents/Kaggle/cascadetrain -bg ~/Documents/Kaggle/negatives/bg.txt -numPos 10 -numNeg 50

And I get the error:

``` OpenCV Error: Bad argument (_cascadeDirName or _bgfileName or _vecFileName is NULL) in train, file /tmp/opencv20150810-26088-1150u2z/opencv-2.4.12/apps/traincascade/cascadeclassifier.cpp, line 146 libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /tmp/opencv20150810-26088-1150u2z/opencv-2.4.12/apps/traincascade/cascadeclassifier.cpp:146: error: (-5) _cascadeDirName or _bgfileName or _vecFileName is NULL in function train

Abort trap: 6 ```

All of the folders and files are valid. I am able to view the vec file with opencv_createsamples.

Does anyone know how I might fix this error? Thanks for the help.


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-09-11 05:04:53 -0500

Some points of attention

  1. First of all there is a typo in the command that you posted, you need a dot line right before the vec parameter, which can be the first problem.
  2. After your data folder, add a slash, just to be sure that it uses the folder itself.
  3. If that does not work, then one of the files is not in that location and you should check it again.
edit flag offensive delete link more


Thank you.

kburnham gravatar imagekburnham ( 2015-09-11 08:02:52 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-09-10 14:36:01 -0500

Seen: 713 times

Last updated: Sep 11 '15