本文整理匯總了Java中org.opencv.core.DMatch類的典型用法代碼示例。如果您正苦於以下問題:Java DMatch類的具體用法?Java DMatch怎麽用?Java DMatch使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DMatch類屬於org.opencv.core包,在下文中一共展示了DMatch類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Mat_to_vector_DMatch
import org.opencv.core.DMatch; //導入依賴的package包/類
public static void Mat_to_vector_DMatch(Mat m, List<DMatch> matches) {
if (matches == null)
throw new java.lang.IllegalArgumentException("Output List can't be null");
int count = m.rows();
if (CvType.CV_64FC4 != m.type() || m.cols() != 1)
throw new java.lang.IllegalArgumentException(
"CvType.CV_64FC4 != m.type() || m.cols()!=1\n" + m);
matches.clear();
double[] buff = new double[4 * count];
m.get(0, 0, buff);
for (int i = 0; i < count; i++) {
matches.add(new DMatch((int) buff[4 * i], (int) buff[4 * i + 1], (int) buff[4 * i + 2], (float) buff[4 * i + 3]));
}
}
示例2: fromArray
import org.opencv.core.DMatch; //導入依賴的package包/類
public void fromArray(DMatch...a) {
if(a==null || a.length==0)
return;
int num = a.length;
alloc(num);
float buff[] = new float[num * _channels];
for(int i=0; i<num; i++) {
DMatch m = a[i];
buff[_channels*i+0] = m.queryIdx;
buff[_channels*i+1] = m.trainIdx;
buff[_channels*i+2] = m.imgIdx;
buff[_channels*i+3] = m.distance;
}
put(0, 0, buff); //TODO: check ret val!
}
示例3: toArray
import org.opencv.core.DMatch; //導入依賴的package包/類
public DMatch[] toArray() {
int num = (int) total();
DMatch[] a = new DMatch[num];
if(num == 0)
return a;
float buff[] = new float[num * _channels];
get(0, 0, buff); //TODO: check ret val!
for(int i=0; i<num; i++)
a[i] = new DMatch((int) buff[_channels*i+0], (int) buff[_channels*i+1], (int) buff[_channels*i+2], buff[_channels*i+3]);
return a;
}