svm.save() is not working opencv4android
I trained the SVM classifier which is working perfectly fine but when I tried to save the classifier, it gave me this error: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 17404. After exploration i thing it seems to be a bug in Opencv 3.10 for Android but I can not find a proper solution. Unanswered question is in here. I use opencv 3.10 for Android, one proposed solution is to downgrade to 2.4 and I do not want to degrade as I have done lots of things using this version.
I would like to update the information here: save() in opencv is inherited from org.opencv.core.algorithms and there is no implementation of the function in the svm html description.
svm.load() also does not work as there is no implementation in Opencv 3.10, so please suggest me to downgrade to 2.4 or not?
Any help is more than appreciated.
@berak please can you suggest any thing based on the last findings, I tried to access all the functions in Algorithm (getDefaultName(), Clear(), save(), and finalize()) and all of them gave me the same segmentation fault and this can be due to calling functions from wrong places or if there is no constructor. Is there any idea solving this as this is the fourth day of the problem and i can not resolve it?
please show exactly , what you've tried, and the outcome.
I tried to call all the functions in public class Algorithm but all of them gives me SIGSEGV error not only the save() when using SVM:
In the SVM class I also added to add the function save() as in load() but nothing changed.
still researching your 1st examples, but for sure, you cannot simply add a load() function in java, without having a resp. c++ implementation (in opencv_java.so)
I knew that, I just added the function save( ) again in the SVM class which already exist in org.opencv.core.algorithm but no change. I thought if I add it to the SVM class, it can work as the load function.
here is some additional information about the crash:
07-05 13:30:07.298 9699-9699/? A/DEBUG: * * 07-05 13:30:07.299 9699-9699/? A/DEBUG: Build fingerprint: 'samsung/hero2ltexx/hero2lte:7.0/NRD90M/G935FXXU1DQD7:user/release-keys' 07-05 13:30:07.299 9699-9699/? A/DEBUG: Revision: '9' 07-05 13:30:07.299 9699-9699/? A/DEBUG: ABI: 'arm64' 07-05 13:30:07.299 9699-9699/? A/DEBUG: pid: 8798, tid: 8798, name: esar.opencvtest >>> com.example.antesar.opencvtest <<< 07-05 13:30:07.299 9699-9699/? A/DEBUG: signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0x7b00000001 07-05 13:30:07.300 9699-9699/? A/DEBUG: x0 0000007b326cc340 x1 0000007fd02c4580 x2 0000007b00000001 x3 0000007b4114e1b2 07-05 13:30:07.300 9699-9699/? A/DEBUG:
@berak One of the solutions I tried is to use opencv 2.4 to train the model because it allow me to save the model to Android sd without any problems and then load the saved model in my previous app which uses opencv3.2 to load the model and do the predictions but i countered this error: OpenCV Error: Assertion failed (samples.cols == var_count && samples.type() == CV_32F) in virtual float cv::ml::SVMImpl::predict(cv::InputArray, cv::OutputArray, int) const, file /build/master_pack-android/opencv/modules/ml/src/svm.cpp, line 1930 ml::predict_10() caught cv::Exception: /build/master_pack-android/opencv/modules/ml/src/svm.cpp:1930: error: (-215) samp Does the saved model using opencv 2.4 differes from opencv 3.2.
Any hints regarding this.
2.4 and 3.x models are incompatible, sad as it is. (not a java problem)
Thanks @berak to save my time. Sadly, I will degrade to version 2.4 as it seems there is no straightforward solutions to save and load svm in opencv 3.x.