android: how to put a column into Mat
According to the best practices page we want to use the fewest calls to the JNI as possible to get the job done.
In my application, I want to add a column of data (held in a List<double> or double[] to a Mat column. Rather than doing this
public void putColumn(int colIndex, List<Double> colData, MatOfDouble mat) {
for( int i=0; i<colData.size(); i++) {
mat.put(i, colIndex, colData[i]);
}
I'd prefer to do something like this:
mat.putColumn(List<Double> colData);
Thus reducing the number of JNI calls from colData.size() to 1 call. Is there such a function in the Android API that does this, or do I have to build one with the JNI?
MatOfDouble
has nice calls for exporting Mat data to java:
List<Double> mat.toList()
double[] mat.toArray()
but the fromArray(double...a)
only seems to be for the constructor.
By the way, why the difference in declarations for float and double versions of put in MatOfDouble
?
public int put(int row, int col, double... data)
public int put(int row, int col, float[] data)
I'm a c++ programmer and "double...a"
is not something i'm familiar with. What does it mean?
I think this post is useful for you http://answers.opencv.org/question/5/how-to-get-and-modify-the-pixel-of-mat-in-java/ . It explains how to modify your data in Java and update it at once in native