Ask Your Question
0

The mat function pop_back does not seem to exist in Java+OpenCv 3.2.X

asked 2017-04-17 11:54:18 -0500

AliUnwala gravatar image

updated 2017-04-17 13:29:29 -0500

I am looking to create some training data in a Mat for a SVM. After I use:

    trainingImages.push_back(img);

I was expecting to be able to do:

    System.out.println( trainingImages.pop_back(img) );

In eclipse this function does not seem to exist: (I don't have enough karma to post inline images)

imgur.com/76zYpAj

And I am using openCV 3.2.0 which I thought would have this functionality:

docs.opencv.org/3.2.0/d3/d63/classcv_1_1Mat.html#a88bbb01901fdfe3f1d0592c592e8757c

I am new to openCV and not sure if I am making a simple mistake. Does anyone have any thoughts?

edit retag flag offensive close merge delete

Comments

could you also highlight, why you think, you need to pop_back() anything at all?

berak gravatar imageberak ( 2017-04-17 14:56:53 -0500 )edit

I thought I would need it for SVM work but it looks like I do not. So not having it worked out.

AliUnwala gravatar imageAliUnwala ( 2017-04-17 16:15:39 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-04-17 14:46:55 -0500

berak gravatar image

no, it's not your fault, it simply does not exist.

(there's a push_back but no pop_back in java, currently, but if at all, it would be probably: void trainingImages.pop_back(int num_rows);)

then, please do not push 2d images, but "flattened", 1d versions of it, like:

 trainingImages.push_back(img.resize(1,1));

(push_back() actually pushes rows, not images. if you don't flatten them, the context, that they belong to a certain image, will be lost, and you end up adding nrows independant samples)

also don't forget to convert your images to float for both SVM training and testing. (just saying)

edit flag offensive delete link more

Comments

Okay so I am not crazy :) One more additional question then. If I resize them the 1d arrays will a SVM still be able to classify the information? Since the image height and image width data is lost?

Also I didnt know about making my images float from SVM training. Thank you for that hint! (I am using CV_32FC1)

AliUnwala gravatar imageAliUnwala ( 2017-04-17 15:36:08 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-04-17 11:54:18 -0500

Seen: 78 times

Last updated: Apr 17 '17