Ask Your Question
0

I am getting line an error-215 while training an SVM with OpenCV-Python

asked 2018-01-29 01:05:38 -0600

RSSharma gravatar image

updated 2018-01-29 19:58:17 -0600

In line 100, in <module>svm.train(train_data,cv.ml.ROW_SAMPLE,train_labels) cv2.error: D:\Build\OpenCV\opencv-3.4.0\modules\ml\src\data.cpp:259: error: (-215) samples.type() == 5 || samples.type() == 4 in function cv::ml::TrainDataImpl::setData

Line 100 is: svm.train(train_data,cv.ml.ROW_SAMPLE,train_labels)

train_data is an n-D numpy array with shape [60, 256,512] and type Float 32.

train_labels is a numpy array with shape [60,1] and type int32.

I am unable to understand what the error possibly means, and any help would be appreciated. I am working with OpenCV 3, Python 3.5.X, Windows 10, 64-bit

edit retag flag offensive close merge delete

Comments

1

please show your code for this.

shape [60, 256,512] -- this does not look correct. a 2d array, like [60, 131072] is required there (each sample has to go on a single, flat row, while you seem to have an array of 2d objects).

berak gravatar imageberak ( 2018-01-29 03:17:24 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-01-29 22:48:29 -0600

RSSharma gravatar image

Resolved the issue by 2D-1D conversion. Thanks. I was working with LBP features on images(2-D)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-01-29 01:05:38 -0600

Seen: 1,413 times

Last updated: Jan 29 '18