当前位置: 首页>>代码示例>>Java>>正文


Java MBFImage.drawPolygon方法代码示例

本文整理汇总了Java中org.openimaj.image.MBFImage.drawPolygon方法的典型用法代码示例。如果您正苦于以下问题:Java MBFImage.drawPolygon方法的具体用法?Java MBFImage.drawPolygon怎么用?Java MBFImage.drawPolygon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openimaj.image.MBFImage的用法示例。


在下文中一共展示了MBFImage.drawPolygon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	final VideoCapture vc = new VideoCapture(320, 240);

	final JFrame frame = DisplayUtilities.displaySimple(vc.getNextFrame(), "capture");
	final ConnectedComponentLabeler ccl = new ConnectedComponentLabeler(ConnectMode.CONNECT_4);

	final String dev = "/dev/tty.usbmodemfd121";
	final SerialDevice device = new SerialDevice(dev, 9600, SerialPort.DATABITS_8,
			SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

	while (true) {
		final MBFImage cimg = vc.getNextFrame();
		final FImage gimg = cimg.flatten();
		// gimg.processInplace(new OtsuThreshold());
		gimg.threshold(0.6f);

		ccl.analyseImage(gimg);
		final ConnectedComponent hand = Fingers.findBiggest(ccl.getComponents());

		if (hand != null) {
			final Polygon poly = hand.toPolygon();
			cimg.drawPolygon(poly, 2, RGBColour.RED);

			double ratio = hand.calculateRegularBoundingBoxAspectRatio();

			System.out.println(ratio);

			ratio = 1 - ((ratio - 3.0) / (5.5 - 3));
			ratio = ratio < 0 ? 0 : ratio > 1 ? 1 : ratio;

			final int amt = (int) (ratio * 180);
			sendCommand(device, amt);
			System.out.println(ratio + " " + amt);
		}

		DisplayUtilities.display(cimg, frame);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:39,代码来源:Fingers2.java

示例2: main

import org.openimaj.image.MBFImage; //导入方法依赖的package包/类
public static void main(String[] args) throws VideoCaptureException {
	final VideoCapture vc = new VideoCapture(320, 240);

	final JFrame frame = DisplayUtilities.displaySimple(vc.getNextFrame(), "capture");
	final ConnectedComponentLabeler ccl = new ConnectedComponentLabeler(ConnectMode.CONNECT_4);

	while (true) {
		final MBFImage cimg = vc.getNextFrame();
		final FImage gimg = cimg.flatten();
		gimg.processInplace(new OtsuThreshold());
		// gimg.threshold(0.4f);

		ccl.analyseImage(gimg);
		final ConnectedComponent hand = findBiggest(ccl.getComponents());

		cimg.drawPoints(hand, RGBColour.WHITE, 1);

		if (hand != null) {
			Polygon poly = hand.toPolygon();
			poly = poly.reduceVertices(3);

			final Polygon chull = poly.calculateConvexHull();

			final List<ConvexityDefect> defects = ConvexityDefect.findDefects(poly, chull);
			// for (final ConvexityDefect cd : defects) {
			// cimg.drawShapeFilled(cd.getTriangle(), RGBColour.MAGENTA);
			// }

			final List<Point2d> tips = findTips(defects);

			final Point2d centroid = poly.calculateCentroid();
			System.out.println(centroid);

			for (final Point2d pt : tips) {
				cimg.drawLine(centroid, pt, RGBColour.RED);
				cimg.drawShape(new Circle(pt, 5), RGBColour.CYAN);
			}

			cimg.drawPolygon(poly, 1, RGBColour.RED);
			cimg.drawPolygon(chull, 1, RGBColour.BLUE);
		}

		DisplayUtilities.display(cimg, frame);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:46,代码来源:Fingers.java


注:本文中的org.openimaj.image.MBFImage.drawPolygon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。