Reputation: 117
So I'm trying to use opencv to create a regression model.
I'm using this but I can't figure out what's wrong: http://pastebin.com/9vEpn4GC
It's always throwing this out:
OpenCV Error: Unsupported format or combination of formats (type mask must be 8uC1 or 8sC1 array) in cvPreprocessVarType, file ........\opencv\modules\ml\src\inner_functions.cpp, line 519 Traceback (most recent call last):
a.train(save_all[features[i]], cv2.CV_ROW_SAMPLE, Y[:][:, i], params=params, varType=var_types) cv2.error: ........\opencv\modules\ml\src\inner_functions.cpp:519: error: (-210) type mask must be 8uC1 or 8sC1 array in function cvPreprocessVarType
I've tried searching this error but there aren't many results. I guess it involves the var_types declaration.
Upvotes: 0
Views: 180
Reputation: 19041
The var_types
array is a list of enumeration values. As the error message hints, the data type of the elements should be a byte, not float.
The following should do the trick:
var_types = np.array([cv2.CV_VAR_NUMERICAL] * var_n + [cv2.CV_VAR_ORDERED], np.uint8)
Upvotes: 1