Using HOGDescriptor's setSVMDetector functionality with an input array
I am having some trouble with the HOGDescriptor.setSVMDetector functionality in OpenCV4Android.
Android requires a passed Mat() for the HOGDescriptor.setSVMDetector()
method. Note that this differs from the C++ specification, where the function is declared as setSVMDetector(const vector<float>& detector)
. The question is how to input a linear SVM model in - that is, how do you turn an array of floating point values into an OpenCV4Android Mat such that a HOGDescriptor object will accept it as input to the setSVMDetector method?
I have tried analyzing the output of HOGDescriptor.getDefaultPeopleDetector()
. This gives a Mat with 3781 rows, 1 column, and type CV_32F. When recreating this, and for that matter when trying any variation (e.g. transposition, 1x1 Mat with a single array entry, etc), the output is:
error: checkDetectorSize() in function virtual void cv::HOGDescriptor::setSVMDetector(cv::InputArray)
Any advice on how to set up an SVM detector this way in Android would be hugely appreciated!