Permalink
Browse files

changed to rendertarget2d

instead of texture2d for the final image we are calling the
rendertarget2d and opennextframe.

but opennextframe is always null < fix that.
  • Loading branch information...
1 parent a28fc50 commit de1a0e759e4d8e81488296433b56c71d44885d72 Vincent Purcell committed Feb 21, 2013
Showing with 29 additions and 15 deletions.
  1. BIN HIVE_KinectGame/HIVE_KinectGame.suo
  2. +27 −13 HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/Game1.cs
  3. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/bin/x86/Debug/Content/screenshots/snapshot-0.png
  4. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/bin/x86/Debug/Content/screenshots/snapshot-1.png
  5. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/bin/x86/Debug/Content/screenshots/snapshot-2.png
  6. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/bin/x86/Debug/Content/screenshots/snapshot-3.png
  7. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/bin/x86/Debug/Content/screenshots/snapshot-4.png
  8. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/bin/x86/Debug/Content/screenshots/snapshot-6.png
  9. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/bin/x86/Debug/Content/screenshots/snapshot-7.png
  10. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/bin/x86/Debug/HIVE_KinectGame.exe
  11. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/bin/x86/Debug/HIVE_KinectGame.pdb
  12. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/bin/x86/Debug/SkinnedModel.dll
  13. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/bin/x86/Debug/SkinnedModel.pdb
  14. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/obj/x86/Debug/HIVE_KinectGame.exe
  15. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/obj/x86/Debug/HIVE_KinectGame.pdb
  16. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGame/obj/x86/Debug/ResolveAssemblyReference.cache
  17. +2 −2 HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGameContent/obj/x86/Debug/ContentPipeline.xml
  18. BIN HIVE_KinectGame/HIVE_KinectGame/HIVE_KinectGameContent/obj/x86/Debug/ResolveAssemblyReference.cache
  19. BIN HIVE_KinectGame/SkinnedModel/bin/x86/Debug/SkinnedModel.dll
  20. BIN HIVE_KinectGame/SkinnedModel/bin/x86/Debug/SkinnedModel.pdb
  21. BIN HIVE_KinectGame/SkinnedModel/obj/x86/Debug/ResolveAssemblyReference.cache
  22. BIN HIVE_KinectGame/SkinnedModel/obj/x86/Debug/SkinnedModel.dll
  23. BIN HIVE_KinectGame/SkinnedModel/obj/x86/Debug/SkinnedModel.pdb
  24. BIN HIVE_KinectGame/SkinnedModelPipeline/bin/x86/Debug/SkinnedModel.dll
  25. BIN HIVE_KinectGame/SkinnedModelPipeline/bin/x86/Debug/SkinnedModel.pdb
  26. BIN HIVE_KinectGame/SkinnedModelPipeline/bin/x86/Debug/SkinnedModelPipeline.dll
  27. BIN HIVE_KinectGame/SkinnedModelPipeline/bin/x86/Debug/SkinnedModelPipeline.pdb
  28. BIN HIVE_KinectGame/SkinnedModelPipeline/obj/x86/Debug/ResolveAssemblyReference.cache
  29. BIN HIVE_KinectGame/SkinnedModelPipeline/obj/x86/Debug/SkinnedModelPipeline.dll
  30. BIN HIVE_KinectGame/SkinnedModelPipeline/obj/x86/Debug/SkinnedModelPipeline.pdb
Binary file not shown.
@@ -548,14 +548,8 @@ protected void kinect_AllFramesReady(object sender, AllFramesReadyEventArgs imag
this.depthPixels = new DepthImagePixel[this.kinect.DepthStream.FramePixelDataLength];
this.greenScreenPixelData = new int[this.kinect.DepthStream.FramePixelDataLength];
this.colorCoordinates = new ColorImagePoint[this.kinect.DepthStream.FramePixelDataLength];
- this.colorPixels = new Byte[colorFrame.PixelDataLength];
this.depthFrame.CopyDepthImagePixelDataTo(this.depthPixels);
- this.colorFrame.CopyPixelDataTo(this.colorPixels);
- // Create a new Texture2D in which we will store out final image (masked player image)
- this.finalImage = new Texture2D(graphics.GraphicsDevice, this.kinect.ColorStream.FrameWidth, this.kinect.ColorStream.FrameHeight);
- // Once we've completed processing the image, save it into the screenshots directory.
- this.finalImage.SetData(this.colorPixels);
this.kinect.CoordinateMapper.MapDepthFrameToColorFrame(
DepthImageFormat.Resolution640x480Fps30,
@@ -616,18 +610,38 @@ protected void kinect_AllFramesReady(object sender, AllFramesReadyEventArgs imag
{
// get the RGB color frame image
// this.colorFrame.CopyPixelDataTo(this.colorPixels);
+ byte[] colorFrameData = null;
+ RenderTarget2D cameraTexture = new RenderTarget2D(this.GraphicsDevice, 640, 480);
+ using (var frame = this.kinect.ColorStream.OpenNextFrame(0))
+ {
+ if (frame != null)
+ {
+ if (colorFrameData == null || colorFrameData.Length != frame.PixelDataLength)
+ {
+ colorFrameData = new byte[frame.PixelDataLength];
+ }
+
+ frame.CopyPixelDataTo(colorFrameData);
+ GraphicsDevice.Textures[0] = null;
+ cameraTexture.SetData<byte>(colorFrameData);
+
+ // TODO: Process the image and merge the player onto our background scene.
+
+
+ //finalImage.SetData(this.greenScreenPixelData);
+ Stream stream = File.OpenWrite(this.Content.RootDirectory + "\\screenshots\\" + "snapshot-" + this.snapNumber + ".png");
+ cameraTexture.SaveAsPng(stream, 640, 480);
+ //this.finalImage.SaveAsPng(stream, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight);
+ this.snapNumber++;
+ stream.Close();
+
+ }
+ }
- // TODO: Process the image and merge the player onto our background scene.
- //finalImage.SetData(this.greenScreenPixelData);
- Stream stream = File.OpenWrite(this.Content.RootDirectory + "\\screenshots\\" + "snapshot-" + this.snapNumber + ".png");
- this.finalImage.SaveAsPng(stream, 640, 480);
- //this.finalImage.SaveAsPng(stream, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight);
- this.snapNumber++;
- stream.Close();
}
this.takeScreencap = false;
this.sceneJustChanged = true;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -20,7 +20,7 @@
<Time>2013-02-21T16:01:16.7102257-05:00</Time>
<Dependency>
<Key>obj\x86\Debug\dude_0.xml</Key>
- <Value>2013-02-21T16:10:58.1212048-05:00</Value>
+ <Value>2013-02-21T16:36:49.1460519-05:00</Value>
</Dependency>
<Request>C:\Users\hive\Documents\GitHub\A-S-Kinect-Digital-Signage\HIVE_KinectGame\HIVE_KinectGame\HIVE_KinectGame\bin\x86\Debug\Content\head_0.xnb</Request>
<Request>C:\Users\hive\Documents\GitHub\A-S-Kinect-Digital-Signage\HIVE_KinectGame\HIVE_KinectGame\HIVE_KinectGame\bin\x86\Debug\Content\jacket_0.xnb</Request>
@@ -112,7 +112,7 @@
<Assemblies>
<Assembly>
<Key>C:\Users\hive\Documents\GitHub\A-S-Kinect-Digital-Signage\HIVE_KinectGame\SkinnedModelPipeline\bin\x86\Debug\SkinnedModelPipeline.dll</Key>
- <Value>2013-02-21T16:10:53.7587978-05:00</Value>
+ <Value>2013-02-21T16:36:45.770241-05:00</Value>
</Assembly>
<Assembly>
<Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll</Key>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit de1a0e7

Please sign in to comment.