android - XML file saved by svm opencv gives strange content -


i trained svm classifier using following code , gave me wrong classification , when looked @ saved xml file, found strange contents. 1 vector in xml file , classification -1 test data. found classifier same before , after classifier.train(...). here code:

log.i(tag,"training..."); v_features.copyto(trainingdata); trainingdata.convertto(trainingdata, cvtype.cv_32f); traininglabels.copyto(classes); classes.convertto(classes, cvtype.cv_32s); classes.convertto(classes, cvtype.cv_32s); cvsvmparams params = new cvsvmparams(); //first method working fine params.set_svm_type(cvsvm.c_svc); params.set_kernel_type(cvsvm.linear); params.set_gamma(0.01); params.set_nu(0.5); params.set_c(1000); termcriteria criteria = new termcriteria(termcriteria.max_iter,100, 1e-6); params.set_term_crit(criteria); // initialize svm object avoid being null object classifier = new cvsvm(trainingdata, classes, new mat(), new mat(), params); classifier.save(xml1.tostring()); classifier.train(trainingdata, classes, new mat(), new mat(), params); classifier.save(xml.tostring()); 

here xml file:

<?xml version="1.0"?> <opencv_storage> <my_svm type_id="opencv-ml-svm"> <svm_type>c_svc</svm_type> <kernel> <type>linear</type> </kernel> <c>1000.</c> <term_criteria> <epsilon>2.2204460492503131e-16</epsilon> <iterations>100</iterations> </term_criteria> <var_all>18</var_all> <var_count>18</var_count> <class_count>2</class_count> <class_labels type_id="opencv-matrix"> <rows>1</rows> <cols>2</cols> <dt>i</dt> <data> -1 1</data> </class_labels> <sv_total>1</sv_total> <support_vectors> <_> -9.17065036e-18 7.35845397e-18 -5.99237967e-18 4.50786054e-18 1.91758168e-18 1.38351872e-18 -3.33754597e-18 1.15368551e-17 -2.76280041e-18 3.05637369e-19 -6.48722237e-19 -2.11365533e-18 -1.00750228e-10 3.54062057e-10 1.56639299e-10 0. 3.43815959e-14 -2.05199830e-14</_> </support_vectors> -<decision_functions> -<_> <sv_count>1</sv_count> <rho>-4.7668412450595643e-01</rho> <alpha> 1.</alpha> <index> 0</index> </_> </decision_functions> </my_svm> </opencv_storage> 

when change line classifier.train(trainingdata, classes, new mat(), new mat(), params); classifier.train(trainingdata, classes);, classifier take default values instead of assigned parameter , decision function 1.here xml file:

<?xml version="1.0"?> -<opencv_storage> -<my_svm type_id="opencv-ml-svm"> <svm_type>c_svc</svm_type> -<kernel> <type>rbf</type> <gamma>1.</gamma> </kernel> <c>1.</c> -<term_criteria> <epsilon>1.1920928955078125e-07</epsilon> <iterations>1000</iterations> </term_criteria> <var_all>18</var_all> <var_count>18</var_count> <class_count>2</class_count> -<class_labels type_id="opencv-matrix"> <rows>1</rows> <cols>2</cols> <dt>i</dt> <data> -1 1</data> </class_labels>     <sv_total>78</sv_total>     -<support_vectors>          </support_vectors>         -<decision_functions>         -<_>         <sv_count>78</sv_count>         <rho>2.6666666666666666e-01</rho>         <alpha> 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. -7.3333328962326050e-01 -7.3333328962326050e-01 -7.3333328962326050e-01 -7.3333328962326050e-01 -7.3333328962326050e-01 -7.3333328962326050e-01 -7.3333328962326050e-01 -7.3333328962326050e-01 -7.3333328962326050e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333334922790527e-01 -7.3333328962326050e-01 -7.3333328962326050e-01 -7.3333328962326050e-01</alpha>         <index> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77</index>         </_>         </decision_functions>         </my_svm>         </opencv_storage> 

can kindly give insights reason of this. use opencv 2.4.13 android.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -