本文整理汇总了Java中org.opencv.core.Rect2d类的典型用法代码示例。如果您正苦于以下问题:Java Rect2d类的具体用法?Java Rect2d怎么用?Java Rect2d使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rect2d类属于org.opencv.core包,在下文中一共展示了Rect2d类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: vector_Rect2d_to_Mat
import org.opencv.core.Rect2d; //导入依赖的package包/类
public static Mat vector_Rect2d_to_Mat(List<Rect2d> rs) {
Mat res;
int count = (rs != null) ? rs.size() : 0;
if (count > 0) {
res = new Mat(count, 1, CvType.CV_64FC4);
double[] buff = new double[4 * count];
for (int i = 0; i < count; i++) {
Rect2d r = rs.get(i);
buff[4 * i] = r.x;
buff[4 * i + 1] = r.y;
buff[4 * i + 2] = r.width;
buff[4 * i + 3] = r.height;
}
res.put(0, 0, buff);
} else {
res = new Mat();
}
return res;
}
示例2: Mat_to_vector_Rect2d
import org.opencv.core.Rect2d; //导入依赖的package包/类
public static void Mat_to_vector_Rect2d(Mat m, List<Rect2d> rs) {
if (rs == null)
throw new java.lang.IllegalArgumentException("rs == 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.rows()!=1\n" + m);
rs.clear();
double[] buff = new double[4 * count];
m.get(0, 0, buff);
for (int i = 0; i < count; i++) {
rs.add(new Rect2d(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
}
}