This posting is for cleanning up the SVM + HOG learning and detection methods to help you.
Step 1. Prepare Data.
Prepare Positive and Negative images
Same size and gray scale
And make xml file for a more convenient data management.
Refer to this page for this step
Step 2. Training by SVM
Load positive.xml and Negative.xml and train by SVM
Refer to this page for this step 2
Step 3. Test by SVM
After training, test other images.
Refer to this page for this step 3
Step 4. for using MultiScaleDetection()
For using Hog.MultiScaleDetection() and other functions.
We have to change the value that result of svm training.
Refer to this page for Step 4. (There is a method for converting the end of source code)
http://study.marearts.com/2014/11/opencv-svm-learning-method-and-xml.htmlafter training.
refer to this source code for using method
..//Load trained SVM xml data FileStorage svmDX_Xml("XXXXX.xml", FileStorage::READ); Mat xMat; svmDX_Xml["SecondSVMd"] >> xMat; vector< float> VX; //copy mat to vector VX.assign((float*)xMat.datastart, (float*)xMat.dataend); //HogDescriptor HOGDescriptor d( Size(64,64), Size(16,16), Size(8,8), Size(8,8), 9); //must be same with training setting. d.setSVMDetector(VX); ... d.detect(...) or d.detectMultiScale(...)..
Thank you.
์๋์ชฝ์ ์๋ trained svm xml data์ ๊ฒฝ์ฐ ์ด์ ์ ์ฌ์ฉํ๋ hogdetectorxml์ ์ฌ์ฉํ๋๊ฒ์ด ๋ง๋์?
ReplyDeletehogdescriptor์ ์ธํ ์ training๋์ฒ๋ผ Size(32, 16), Size(8, 8), Size(4, 4), Size(4, 4), 9 ๋ก ํ๊ณ ์งํํ๋๋ฐ d.setsvmdetector method์์ ๋ฉ๋ชจ๋ฆฌ ์ฐธ์กฐ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค์
ํน์๋ํ๊ณ trainedsvm.xml๋ ์ฌ์ฉํด๋ณด์์ง๋ง...์๋๊ฑธ ์๊ธฐ์
dataset์ 600๊ฐ๋ฅผ ์ฌ์ฉํด์ ๋ฐ์ดํฐ์ ํฐ๋ฌธ์ ๋ ์์๊ฑฐ ๊ฐ์๋ฐ hogdetectorxml์์ฑ๊ณผ์ ์์ ์ฐจ์ด๊ฐ ๋ฒกํฐ๊ธธ์ด์ ๋ฌธ์ ๊ฐ์๋๊ฑด์ง ์ด๋ค๊ฑด์ง ์ ๋ชจ๋ฅด๊ฒ๋ค์ใ ใ
Hi, could you give me some helps ? It works perfectly on step 123 but it has error when running to this line "d.setSVMDetector(VX);"
ReplyDeleteBoth the HOG descriptor was the same, image for training was converted to gray and same size for both pos and neg images.