當前位置: 首頁>>代碼示例>>Java>>正文


Java UtilOpenKinect類代碼示例

本文整理匯總了Java中boofcv.openkinect.UtilOpenKinect的典型用法代碼示例。如果您正苦於以下問題:Java UtilOpenKinect類的具體用法?Java UtilOpenKinect怎麽用?Java UtilOpenKinect使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UtilOpenKinect類屬於boofcv.openkinect包,在下文中一共展示了UtilOpenKinect類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processRgb

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
protected void processRgb(FrameMode mode, ByteBuffer frame, int timestamp) {
  if (mode.getVideoFormat() != VideoFormat.RGB) {
    System.out.println("Bad rgb format!");
  }

  System.out.println("Got rgb!   " + timestamp);

  if (outRgb == null) {
    rgb.reshape(mode.getWidth(), mode.getHeight());
    outRgb = new BufferedImage(rgb.width, rgb.height, BufferedImage.TYPE_INT_RGB);
    guiRgb = ShowImages.showWindow(outRgb, "RGB Image");
  }

  UtilOpenKinect.bufferRgbToMsU8(frame, rgb);
  ConvertBufferedImage.convertTo_U8(rgb, outRgb, true);

  guiRgb.repaint();
}
 
開發者ID:MyRobotLab,項目名稱:myrobotlab,代碼行數:19,代碼來源:KinectStreamer.java

示例2: processRgb

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
protected void processRgb( FrameMode mode, ByteBuffer frame, int timestamp ) {
	if( mode.getVideoFormat() != VideoFormat.RGB ) {
		System.out.println("Bad rgb format!");
	}

	System.out.println("Got rgb! "+timestamp);

	if( outRgb == null ) {
		rgb.reshape(mode.getWidth(),mode.getHeight());
		outRgb = new BufferedImage(rgb.width,rgb.height,BufferedImage.TYPE_INT_RGB);
		guiRgb = ShowImages.showWindow(outRgb,"RGB Image");
	}

	UtilOpenKinect.bufferRgbToMsU8(frame, rgb);
	ConvertBufferedImage.convertTo_U8(rgb,outRgb);

	guiRgb.repaint();
}
 
開發者ID:intrack,項目名稱:BoofCV-master,代碼行數:19,代碼來源:OpenKinectStreamingTest.java

示例3: process

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
public void process() throws IOException {
	parseFrame(0);

	outRgb = new BufferedImage(rgb.getWidth(),rgb.getHeight(),BufferedImage.TYPE_INT_RGB);
	outDepth = new BufferedImage(depth.getWidth(),depth.getHeight(),BufferedImage.TYPE_INT_RGB);

	gui = new ImageGridPanel(1,2,outRgb,outDepth);
	ShowImages.showWindow(gui,"Kinect Data");

	int frame = 1;
	while( true ) {
		parseFrame(frame++);
		ConvertBufferedImage.convertTo_U8(rgb,outRgb);
		VisualizeImageData.disparity(depth, outDepth, 0, UtilOpenKinect.FREENECT_DEPTH_MM_MAX_VALUE, 0);
		gui.repaint();
		BoofMiscOps.pause(30);
	}
}
 
開發者ID:intrack,項目名稱:BoofCV-master,代碼行數:19,代碼來源:PlaybackKinectLogApp.java

示例4: processKinect

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
@Override
public void processKinect(MultiSpectral<ImageUInt8> rgb, ImageUInt16 depth, long timeRgb, long timeDepth) {
	System.out.println(frameNumber+"  "+timeRgb);
	try {
		logFile.write(String.format("%10d %d %d\n",frameNumber,timeRgb,timeDepth).getBytes());
		logFile.flush();
		UtilImageIO.savePPM(rgb, String.format("log/rgb%07d.ppm", frameNumber), buffer);
		UtilOpenKinect.saveDepth(depth, String.format("log/depth%07d.depth", frameNumber), buffer);
		frameNumber++;

		if( showImage ) {
			ConvertBufferedImage.convertTo_U8(rgb,buffRgb);
			gui.repaint();
		}
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:intrack,項目名稱:BoofCV-master,代碼行數:19,代碼來源:LogKinectDataApp.java

示例5: processDepth

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
protected void processDepth(FrameMode mode, ByteBuffer frame, int timestamp) {

	if (outDepth == null) {
		depth.reshape(mode.getWidth(), mode.getHeight());
		// in my case: width 640, height 480
		outDepth = new BufferedImage(depth.width, depth.height, BufferedImage.TYPE_INT_RGB);
		guiDepth = ShowImages.showWindow(outDepth, "Depth Image");
	}

	App.bufferDepthToU16(frame, depth);

	processButtonStatePhaseOne(buttonMove);
	processButtonStatePhaseOne(buttonStop);
	processButtonStatePhaseOne(buttonLeft);
	processButtonStatePhaseOne(buttonRight);

	VisualizeImageData.grayUnsigned(depth, outDepth, UtilOpenKinect.FREENECT_DEPTH_MM_MAX_VALUE);

	drawButton(buttonMove, outDepth);
	drawButton(buttonStop, outDepth);
	drawButton(buttonLeft, outDepth);
	drawButton(buttonRight, outDepth);

	processButtonStatePhaseTwo(buttonMove, outDepth);
	processButtonStatePhaseTwo(buttonStop, outDepth);
	processButtonStatePhaseTwo(buttonLeft, outDepth);
	processButtonStatePhaseTwo(buttonRight, outDepth);

	guiDepth.repaint();
}
 
開發者ID:IBM-Cloud,項目名稱:controller-kinect-bluemix,代碼行數:31,代碼來源:App.java

示例6: processDepth

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
protected void processDepth(FrameMode mode, ByteBuffer frame, int timestamp) {
  System.out.println("Got depth! " + timestamp);

  if (outDepth == null) {
    depth.reshape(mode.getWidth(), mode.getHeight());
    outDepth = new BufferedImage(depth.width, depth.height, BufferedImage.TYPE_INT_RGB);
    guiDepth = ShowImages.showWindow(outDepth, "Depth Image");
  }

  UtilOpenKinect.bufferDepthToU16(frame, depth);

  // VisualizeImageData.grayUnsigned(depth,outDepth,UtilOpenKinect.FREENECT_DEPTH_MM_MAX_VALUE);
  VisualizeImageData.disparity(depth, outDepth, 0, UtilOpenKinect.FREENECT_DEPTH_MM_MAX_VALUE, 0);
  guiDepth.repaint();
}
 
開發者ID:MyRobotLab,項目名稱:myrobotlab,代碼行數:16,代碼來源:KinectStreamer.java

示例7: processKinect

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
@Override
public void processKinect(Planar<GrayU8> rgb, GrayU16 depth, long timeRgb, long timeDepth) {
  VisualizeImageData.disparity(depth, buffDepth, 0, UtilOpenKinect.FREENECT_DEPTH_MM_MAX_VALUE, 0);
  ConvertBufferedImage.convertTo_U8(rgb, buffRgb, true);

  Graphics2D g2 = buffRgb.createGraphics();
  float alpha = 0.5f;
  int type = AlphaComposite.SRC_OVER;
  AlphaComposite composite = AlphaComposite.getInstance(type, alpha);
  g2.setComposite(composite);
  g2.drawImage(buffDepth, 0, 0, null);

  gui.repaint();
}
 
開發者ID:MyRobotLab,項目名稱:myrobotlab,代碼行數:15,代碼來源:KinectRGBDepth.java

示例8: main

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
public static void main( String args[] ) throws IOException {
		String baseDir = "../data/evaluation/kinect/";

		String nameRgb = baseDir+"basket.ppm";
		String nameDepth = baseDir+"basket.depth";
		String nameCalib = baseDir+"intrinsic.xml";

		IntrinsicParameters param = BoofMiscOps.loadXML(nameCalib);

		ImageUInt16 depth = new ImageUInt16(1,1);
		MultiSpectral<ImageUInt8> rgb = new MultiSpectral<ImageUInt8>(ImageUInt8.class,1,1,3);

		UtilImageIO.loadPPM_U8(nameRgb, rgb, null);
		UtilOpenKinect.parseDepth(nameDepth,depth,null);

		FastQueue<Point3D_F64> cloud = new FastQueue<Point3D_F64>(Point3D_F64.class,true);
		FastQueueArray_I32 cloudColor = new FastQueueArray_I32(3);

		VisualDepthOps.depthTo3D(param, rgb, depth, cloud, cloudColor);

		DenseMatrix64F K = PerspectiveOps.calibrationMatrix(param,null);

		PointCloudViewer viewer = new PointCloudViewer(K,20);
		viewer.setPreferredSize(new Dimension(rgb.width,rgb.height));

		for( int i = 0; i < cloud.size; i++ ) {
			Point3D_F64 p = cloud.get(i);
			int[] color = cloudColor.get(i);
			int c = (color[0] << 16 ) | (color[1] << 8) | color[2];
			viewer.addPoint(p.x,p.y,p.z,c);
		}

		ShowImages.showWindow(viewer,"Point Cloud");
		System.out.println("Total points = "+cloud.size);

//		BufferedImage depthOut = VisualizeImageData.disparity(depth, null, 0, UtilOpenKinect.FREENECT_DEPTH_MM_MAX_VALUE, 0);
//		ShowImages.showWindow(depthOut,"Depth Image");
	}
 
開發者ID:intrack,項目名稱:BoofCV-master,代碼行數:39,代碼來源:DisplayKinectPointCloudApp.java

示例9: processDepth

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
protected void processDepth( FrameMode mode, ByteBuffer frame, int timestamp ) {
	System.out.println("Got depth! "+timestamp);

	if( outDepth == null ) {
		depth.reshape(mode.getWidth(),mode.getHeight());
		outDepth = new BufferedImage(depth.width,depth.height,BufferedImage.TYPE_INT_RGB);
		guiDepth = ShowImages.showWindow(outDepth,"Depth Image");
	}

	UtilOpenKinect.bufferDepthToU16(frame, depth);

	VisualizeImageData.grayUnsigned(depth,outDepth,1000);
	guiDepth.repaint();
}
 
開發者ID:intrack,項目名稱:BoofCV-master,代碼行數:15,代碼來源:OpenKinectStreamingTest.java

示例10: parseFrame

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
private void parseFrame(int frameNumber ) throws IOException {
	UtilImageIO.loadPPM_U8(String.format("%s/rgb%07d.ppm", directory, frameNumber), rgb, data);
	if( depthIsPng ) {
		BufferedImage image = UtilImageIO.loadImage(String.format("%s/depth%07d.png", directory, frameNumber));
		ConvertBufferedImage.convertFrom(image,depth);
	} else {
		UtilOpenKinect.parseDepth(String.format("%s/depth%07d.depth", directory, frameNumber), depth, data);
	}

}
 
開發者ID:intrack,項目名稱:BoofCV-master,代碼行數:11,代碼來源:PlaybackKinectLogApp.java

示例11: processKinect

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
@Override
public void processKinect(MultiSpectral<ImageUInt8> rgb, ImageUInt16 depth, long timeRgb, long timeDepth) {
	VisualizeImageData.disparity(depth, buffDepth, 0, UtilOpenKinect.FREENECT_DEPTH_MM_MAX_VALUE,0);
	ConvertBufferedImage.convertTo_U8(rgb,buffRgb);

	Graphics2D g2 = buffRgb.createGraphics();
	float alpha = 0.5f;
	int type = AlphaComposite.SRC_OVER;
	AlphaComposite composite =
			AlphaComposite.getInstance(type, alpha);
	g2.setComposite(composite);
	g2.drawImage(buffDepth,0,0,null);

	gui.repaint();
}
 
開發者ID:intrack,項目名稱:BoofCV-master,代碼行數:16,代碼來源:OverlayRgbDepthStreamsApp.java

示例12: main

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
public static void main( String args[] ) throws IOException {
	String baseDir = "log/";

	String nameRgb = baseDir+"rgb0000000.ppm";
	String nameDepth = baseDir+"depth0000000.depth";
	String nameCalib = baseDir+"intrinsic.xml";

	IntrinsicParameters param = BoofMiscOps.loadXML(nameCalib);

	ImageUInt16 depth = new ImageUInt16(1,1);
	MultiSpectral<ImageUInt8> rgb = new MultiSpectral<ImageUInt8>(ImageUInt8.class,1,1,3);

	UtilImageIO.loadPPM_U8(nameRgb, rgb, null);
	UtilOpenKinect.parseDepth(nameDepth,depth,null);

	FastQueue<Point3D_F64> cloud = new FastQueue<Point3D_F64>(Point3D_F64.class,true);
	FastQueueArray_I32 cloudColor = new FastQueueArray_I32(3);

	VisualDepthOps.depthTo3D(param, rgb, depth, cloud, cloudColor);

	DataOutputStream file = new DataOutputStream(new FileOutputStream("kinect_pointcloud.txt"));

	file.write("# Kinect RGB Point cloud. Units: millimeters. Format: X Y Z R G B\n".getBytes());

	for( int i = 0; i < cloud.size; i++ ) {
		Point3D_F64 p = cloud.get(i);
		int[] color = cloudColor.get(i);

		String line = String.format("%.10f %.10f %.10f %d %d %d\n",p.x,p.y,p.z,color[0],color[1],color[2]);
		file.write(line.getBytes());
	}
	file.close();

	System.out.println("Total points = "+cloud.size);
}
 
開發者ID:intrack,項目名稱:BoofCV-master,代碼行數:36,代碼來源:CreateRgbPointCloudFileApp.java

示例13: process

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
public void process() throws IOException {

		logFile = new DataOutputStream(new FileOutputStream("log/timestamps.txt"));
		logFile.write("# Time stamps for rgb and depth cameras.\n".getBytes());

		int w = UtilOpenKinect.getWidth(resolution);
		int h = UtilOpenKinect.getHeight(resolution);

		buffRgb = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);

		if( showImage ) {
			gui = ShowImages.showWindow(buffRgb,"Kinect RGB");
		}

		StreamOpenKinectRgbDepth stream = new StreamOpenKinectRgbDepth();
		Context kinect = Freenect.createContext();

		if( kinect.numDevices() < 0 )
			throw new RuntimeException("No kinect found!");

		Device device = kinect.openDevice(0);

		stream.start(device,resolution,this);

		if( maxImages > 0 ) {
			while( frameNumber < maxImages ) {
				System.out.printf("Total saved %d\n",frameNumber);
				BoofMiscOps.pause(100);
			}
			stream.stop();
			System.out.println("Exceeded max images");
			System.exit(0);
		}
	}
 
開發者ID:intrack,項目名稱:BoofCV-master,代碼行數:35,代碼來源:LogKinectDataApp.java

示例14: process

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
public void process() {

    int w = UtilOpenKinect.getWidth(resolution);
    int h = UtilOpenKinect.getHeight(resolution);

    buffRgb = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    buffDepth = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);

    gui = ShowImages.showWindow(buffRgb, "Kinect Overlay");

    StreamOpenKinectRgbDepth stream = new StreamOpenKinectRgbDepth();
    Context kinect = Freenect.createContext();

    if (kinect.numDevices() < 0)
      throw new RuntimeException("No kinect found!");

    Device device = kinect.openDevice(0);
    stream.start(device, resolution, this);
  }
 
開發者ID:MyRobotLab,項目名稱:myrobotlab,代碼行數:20,代碼來源:KinectRGBDepth.java

示例15: process

import boofcv.openkinect.UtilOpenKinect; //導入依賴的package包/類
public void process() throws IOException {

		// make sure there is a "log" directory
		new File("log").mkdir();

		int w = UtilOpenKinect.getWidth(resolution);
		int h = UtilOpenKinect.getHeight(resolution);

		buffRgb = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);

		savedRgb = new MultiSpectral<ImageUInt8>(ImageUInt8.class,w,h,3);
		savedDepth = new ImageUInt16(w,h);

		gui = ShowImages.showWindow(buffRgb, "Kinect RGB");
		gui.addKeyListener(this);
		gui.requestFocus();

		StreamOpenKinectRgbDepth stream = new StreamOpenKinectRgbDepth();
		Context kinect = Freenect.createContext();

		if( kinect.numDevices() < 0 )
			throw new RuntimeException("No kinect found!");

		Device device = kinect.openDevice(0);

		stream.start(device,resolution,this);

		long targetTime = System.currentTimeMillis() + period;
		updateDisplay = true;
		while( true ) {
			BoofMiscOps.pause(100);

			if( targetTime < System.currentTimeMillis() ) {
				userChoice = -1;
				savedImages = false;
				updateDisplay = false;
				while( true ) {
					if( savedImages && userChoice != -1 ) {
						if( userChoice == 1 ) {
							UtilImageIO.savePPM(savedRgb, String.format(directory + "rgb%07d.ppm", frameNumber), buffer);
							UtilOpenKinect.saveDepth(savedDepth, String.format(directory + "depth%07d.depth", frameNumber), buffer);
							frameNumber++;
							text = "Image Saved!";
						} else {
							text = "Image Discarded!";
						}
						timeText = System.currentTimeMillis()+500;
						updateDisplay = true;
						targetTime = System.currentTimeMillis()+period;
						break;
					}
					BoofMiscOps.pause(50);
				}
			}
		}
	}
 
開發者ID:intrack,項目名稱:BoofCV-master,代碼行數:57,代碼來源:CaptureCalibrationImagesApp.java


注:本文中的boofcv.openkinect.UtilOpenKinect類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。