Saving knn training data in java

asked 2016-03-24 03:46:27 -0500

Max3 gravatar image

Hello, I have a KNearest object, i trained it and it works well but I should want to save the training data because I don't want to train my KNearest object everytime I run my app. I've tried to use knn.save() function but i got this error:

Exception in thread "AWT-EventQueue-0" java.security.PrivilegedActionException: java.security.PrivilegedActionException: java.lang.Exception: unknown exception

I've also tried to save my training data Mat as image but when I loaded it and I tried to train I got this error:

OpenCV Error: Assertion failed (samples.type() == CV_32F || samples.type() == CV_32S) in cv::ml::TrainDataImpl::setData, file C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\ml\src\data.cpp, line 251
Exception in thread "AWT-EventQueue-0" CvException [org.opencv.core.CvException: cv::Exception: C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\ml\src\data.cpp:251: error: (-215) samples.type() == CV_32F || samples.type() == CV_32S in function cv::ml::TrainDataImpl::setData
]

But my image is CV_32F type. How can I solve this problem?

edit retag flag offensive close merge delete

Comments

"I've also tried to save my training data Mat as image" -- the only image format able to save float data is exr.

most probably , your data got converted to uchar, when saving

berak gravatar imageberak ( 2016-03-24 04:00:05 -0500 )edit