Ask Your Question
0

opencv_traincascade line 152

asked 2015-09-02 02:31:28 -0600

synome gravatar image

Hi All,

I am trying to make their own cascade classifier.

Here's what I've done:

1)positive file

opencv_createsamples.exe -img sample.png -vec sample.vec -num 1000 -bgcolor 255 -randinv -w 196 -h 106

2)negative file

bg.txt in image PATH. (PATH + name.jpg&png&gif)

3)traincascade

opencv_traincascade -data sample/ -vec sample.vec -bg bg.txt -numPos 900 -numNeg 270 -featureType HAAR -mode ALL

But...Here, the error will occur.

Error code.

===== TRAINING 0-stage =====

OpenCV Error: Assertion failed (_img.rows * _img.cols == vecSize) in CvCascadeIm ageReader::PosReader::get, file C:\builds\master_PackSlave-win32-vc12-shared\opencv\apps\traincascade\imagestorage.cpp, line 152

Nothing no clue.

I do not know what to do.

Please help me.

Sorry...I can't English.(Using Google Translation)

Thanks for reading.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-09-02 08:21:53 -0600

updated 2015-09-02 08:23:48 -0600

You did not specify the -w and -h parameter for the traincascade interface and thus it uses the standard 24x24 dimensions. Those are not the same as your training data for the opencv createsamples utility. I suggest you to update your command to

opencv_traincascade -data sample/ -vec sample.vec -bg bg.txt -numPos 900 -numNeg 270 -featureType HAAR -mode ALL -w196 -h 106

So that it at least passes by these asserts. That being said, you also have a problem with dimensionality. For now you are using the standard 1024 MB of memory for the process, but with those dimensions and those number of samples, you will soon run out of memory. Search this forum for traincascade parameters to get a better insight in all of this.

edit flag offensive delete link more

Comments

1

@StevenPuttemans: when is that PacktPub book coming out? I can't't wait to get my hands over your chapter

LorenaGdL gravatar imageLorenaGdL ( 2015-09-02 08:27:25 -0600 )edit

Hehe, the pre-order is already open and the release should be for october. Last chapters of other authors are being finalized as we speak.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-09-02 08:43:25 -0600 )edit
1

Hi Steven,

Thanks you. You're a genius.

Sorry...I don't know PacktPub book,What should I do?

It was work by the following test command

opencv_traincascade -data sample -vec sample.vec -bg bg.txt -numPos 90 -numNeg 10 -featureType HAAR -mode ALL -w 30-h 17 -precalcValBufSize 256 -precalcIdxBufSize 256

but...Kill the stage 19 is finished. This is where looking answer.

synome gravatar imagesynome ( 2015-09-02 21:44:17 -0600 )edit
1

You had said that of this book.

https://www.packtpub.com/application-...

amazing! ! I am looking forward to October.

synome gravatar imagesynome ( 2015-09-11 02:39:24 -0600 )edit

Nice to know people are enthousiastic about it! Do let people know this and spread the word :D

StevenPuttemans gravatar imageStevenPuttemans ( 2015-09-11 04:23:54 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-09-02 02:31:28 -0600

Seen: 840 times

Last updated: Sep 02 '15