public static Mat vector_KeyPoint_to_Mat(List <KeyPoint> kps) { Mat res; int count = (kps != null) ? kps.Count : 0; if (count > 0) { res = new Mat(count, 1, CvType.CV_64FC(7)); double[] buff = new double[count * 7]; for (int i = 0; i < count; i++) { KeyPoint kp = kps [i]; buff [7 * i] = kp.pt.x; buff [7 * i + 1] = kp.pt.y; buff [7 * i + 2] = kp.size; buff [7 * i + 3] = kp.angle; buff [7 * i + 4] = kp.response; buff [7 * i + 5] = kp.octave; buff [7 * i + 6] = kp.class_id; } res.put(0, 0, buff); } else { res = new Mat(); } return(res); }
public static void Mat_to_vector_KeyPoint(Mat m, List <KeyPoint> kps) { if (m != null) { m.ThrowIfDisposed(); } if (kps == null) { throw new CvException("Output List can't be null"); } int count = m.rows(); if (CvType.CV_64FC(7) != m.type() || m.cols() != 1) { throw new CvException( "CvType.CV_64FC(7) != m.type() || m.cols()!=1\n" + m); } kps.Clear(); double[] buff = new double[7 * count]; m.get(0, 0, buff); for (int i = 0; i < count; i++) { kps.Add(new KeyPoint((float)buff [7 * i], (float)buff [7 * i + 1], (float)buff [7 * i + 2], (float)buff [7 * i + 3], (float)buff [7 * i + 4], (int)buff [7 * i + 5], (int)buff [7 * i + 6])); } }
public void alloc(int elemNumber) { if (elemNumber > 0) { base.create(elemNumber, 1, CvType.makeType(_depth, _channels)); } }