Ask Your Question
1

Convert new format haarcasccade xml file to old format

asked 2014-10-24 22:54:04 -0600

hritzanimesh gravatar image

updated 2017-08-29 17:02:13 -0600

I have a haarcascade file generated using opencv_traincascade which generates an xml file. The format of this xml file is different from that of generated by opencv_haartraining.

OpenCV documentation says that opencv_traincascade can save (export) a trained cascade in the older format. However, I have not found any way to do this.

I wanted to ask if anybody has any luck in converting a new format haarcascade xml file to the older format.

edit retag flag offensive close merge delete

Comments

why on earth do you want the old format ?

if you got legacy code, that only can read that, it's probably a better idea, to update that instead.

berak gravatar imageberak ( 2014-10-25 02:06:00 -0600 )edit
1

@berak I am working on GPU version of haar object detection. For that I need the haar classifier file to be loaded in the gpu::CascadeClassifier_GPU class. It turns out that it doesn't support the new xml format.

hritzanimesh gravatar imagehritzanimesh ( 2014-10-29 17:59:37 -0600 )edit

It seems there isn't any way to achieve this. It is sad that the documentation is misleading.

hritzanimesh gravatar imagehritzanimesh ( 2014-11-06 15:27:20 -0600 )edit

@berak like he said, gpu version of 3.0 only works with old models...

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-16 14:40:08 -0600 )edit

^^ yep, learned that from the issues page lately.

berak gravatar imageberak ( 2015-03-16 14:42:37 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-03-16 13:58:34 -0600

ragnarok12 gravatar image

updated 2015-03-16 21:16:53 -0600

Hi, if you run "opencv_traincascade" with the "-baseFormatSave" flag, it will save it in the old format. To save it in the new format, just leave that flag out.

http://docs.opencv.org/doc/user_guide...

===== Example export to old format =====

opencv_traincascade -data classifier -vec samples.vec -bg negatives.txt\ -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 1000\ -numNeg 600 -w 80 -h 40 -mode ALL -precalcValBufSize 1024\ -precalcIdxBufSize 1024 -baseFormatSave

edit: this only works for HAAR feature detection

edit flag offensive delete link more

Comments

Lets add that this only works for haar features!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-16 14:39:25 -0600 )edit

Question Tools

Stats

Asked: 2014-10-24 22:54:04 -0600

Seen: 1,593 times

Last updated: Mar 16 '15