本文整理汇总了C#中Microsoft.Kinect.ColorImageFrameReadyEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# ColorImageFrameReadyEventArgs类的具体用法?C# ColorImageFrameReadyEventArgs怎么用?C# ColorImageFrameReadyEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ColorImageFrameReadyEventArgs类属于Microsoft.Kinect命名空间,在下文中一共展示了ColorImageFrameReadyEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KinectColorFrameReady
/// <summary>
/// Sets the data of ColorVideo.
/// </summary>
/// <param name="sender"></param>
/// <param name="colorImageFrame"></param>
public void KinectColorFrameReady(object sender, ColorImageFrameReadyEventArgs colorImageFrame)
{
//Get raw image
ColorVideoFrame = colorImageFrame.OpenColorImageFrame();
if (ColorVideoFrame != null)
{
//Create array for pixel data and copy it from the image frame
PixelData = new Byte[ColorVideoFrame.PixelDataLength];
ColorVideoFrame.CopyPixelDataTo(PixelData);
//Convert RGBA to BGRA, Kinect and XNA uses different color-formats.
BgraPixelData = new Byte[ColorVideoFrame.PixelDataLength];
for (int i = 0; i < PixelData.Length; i += 4)
{
BgraPixelData[i] = PixelData[i + 2];
BgraPixelData[i + 1] = PixelData[i + 1];
BgraPixelData[i + 2] = PixelData[i];
BgraPixelData[i + 3] = (Byte)255; //The video comes with 0 alpha so it is transparent
}
// Create a texture and assign the realigned pixels
ColorVideo = new Texture2D(Graphics.GraphicsDevice, ColorVideoFrame.Width, ColorVideoFrame.Height);
ColorVideo.SetData(BgraPixelData);
ColorVideoFrame.Dispose();
}
}
示例2: SensorColorFrameReady
/// <summary>
/// Event handler for Kinect sensor's ColorFrameReady event
/// </summary>
/// <param name="sender">object sending the event</param>
/// <param name="e">event arguments</param>
private void SensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
//drop the frame if you're not done with the last one
if (!this.processingFrame)
{
this.processingFrame = true;
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame != null)
{
// Copy the pixel data from the image to a temporary array
colorFrame.CopyPixelDataTo(this.colorPixels);
IntPtr filteredPixels = this.colorFilter.FilterFrame(this.colorPixels, this.colorBitmap.PixelWidth, this.colorBitmap.PixelHeight);
this.colorBitmap.WritePixels(
new Int32Rect(0, 0, this.colorBitmap.PixelWidth, this.colorBitmap.PixelHeight),
filteredPixels,
this.colorPixels.Length,
this.colorBitmap.PixelWidth * sizeof(int));
}
}
this.processingFrame = false;
}
}
示例3: sensor_ColorFrameReady
void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
if (this.ColorFrameReady != null)
{
this.ColorFrameReady(this, e);
}
}
示例4: miKinect_ColorFrameReady
void miKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
using (ColorImageFrame framesImagen = e.OpenColorImageFrame()) {
if (framesImagen == null)
return;
byte[] datosColor = new byte[framesImagen.PixelDataLength];
framesImagen.CopyPixelDataTo(datosColor);
if (grabarFoto)
{
bitmapImagen = BitmapSource.Create(
framesImagen.Width, framesImagen.Height, 96, 96, PixelFormats.Bgr32, null,
datosColor, framesImagen.Width * framesImagen.BytesPerPixel);
grabarFoto = false;
}
colorStream.Source = BitmapSource.Create(
framesImagen.Width, framesImagen.Height,
96,
96,
PixelFormats.Bgr32,
null,
datosColor,
framesImagen.Width * framesImagen.BytesPerPixel
);
}
}
示例5: miKinect_ColorFrameReady
void miKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
using (ColorImageFrame framesColor = e.OpenColorImageFrame())
{
if (framesColor == null) return;
if (datosColor == null)
datosColor = new byte[framesColor.PixelDataLength];
framesColor.CopyPixelDataTo(datosColor);
if (colorImagenBitmap == null)
{
this.colorImagenBitmap = new WriteableBitmap(
framesColor.Width,
framesColor.Height,
96,
96,
PixelFormats.Bgr32,
null);
}
this.colorImagenBitmap.WritePixels(
new Int32Rect(0, 0, framesColor.Width, framesColor.Height),
datosColor,
framesColor.Width * framesColor.BytesPerPixel,
0
);
canvasEsqueleto.Background = new ImageBrush(colorImagenBitmap);
}
}
示例6: sensor_ColorFrameReady
/// <summary>
/// Color frame main class
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
using (ColorImageFrame imageFrame = e.OpenColorImageFrame())
{
// Check if the incoming frame is not null
if (imageFrame != null)
{
// Get the pixel data in byte array
this.pixelData = new byte[imageFrame.PixelDataLength];
// Copy the pixel data
imageFrame.CopyPixelDataTo(this.pixelData);
// assign the bitmap image source into image control
BitmapSource bitmapS = BitmapSource.Create(
imageFrame.Width,
imageFrame.Height,
96,
96,
PixelFormats.Bgr32,
null,
pixelData,
imageFrame.Width *4 );
// this.caller.setImg(bitmapS); //we send data to the caller class
}
}
}
示例7: kinect_ColorFrameReady
public void kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
try
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame != null)
{
// RGBカメラのフレームデータを取得する
byte[] colorPixel = new byte[colorFrame.PixelDataLength];
colorFrame.CopyPixelDataTo(colorPixel);
// ピクセルデータをビットマップに変換する
mainWindow.imageRgb.Source = BitmapSource.Create(colorFrame.Width,
colorFrame.Height, 96, 96, PixelFormats.Bgr32, null,
colorPixel, colorFrame.Width * colorFrame.BytesPerPixel);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例8: sensor_ColorFrameReady
private void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
if (Enabled)
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
// can happen that we have to drop frames
if (null == colorFrame)
{
return;
}
height = colorFrame.Height;
width = colorFrame.Width;
bytesPerPixel = colorFrame.BytesPerPixel;
// TODO: does this remove the need to allocate the same space over and over again?
if (null == imageBuffer || imageBuffer.Length != colorFrame.PixelDataLength)
{
this.imageBuffer = new byte[colorFrame.PixelDataLength];
}
colorFrame.CopyPixelDataTo(this.imageBuffer);
}
}
}
示例9: ColorFrameReady
private void ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
ColorImageFrame frame = e.OpenColorImageFrame();
if (frame != null)
{
if (frame.Format != this.oldformat)
{
int bpp = frame.Format == ColorImageFormat.RgbResolution640x480Fps30 ? 4 : 2;
this.colorimage = new byte[640 * 480 * bpp];
this.oldformat = frame.Format;
this.DisposeTextures();
}
this.FInvalidate = true;
this.frameindex = frame.FrameNumber;
lock (m_lock)
{
frame.CopyPixelDataTo(this.colorimage);
}
frame.Dispose();
}
}
示例10: SensorColorFrameReady
public void SensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame != null)
{
if (0 == (framesNum + 1) % BUFFERSIZE) //if buffer is full - empty buffer to file\s
{
for (int i = framesNum - BUFFERSIZE + 1; i < framesNum + 1; i++)
{
// CreateThumbnail(@"images\color"+i+".bmp", ConvertWriteableBitmapToBitmapImage(colorBitmap[i%BUFFERSIZE]));
//AddBmpToAvi(@"images\video.avi", BitmapFromWriteableBitmap(colorBitmap[i % BUFFERSIZE]));
}
}
// Copy the pixel data from the image to a temporary array
colorFrame.CopyPixelDataTo(this.colorPixels);
// Write the pixel data into our bitmap
this.colorBitmap[framesNum % BUFFERSIZE].WritePixels(
new Int32Rect(0, 0, this.colorBitmap[framesNum % BUFFERSIZE].PixelWidth, this.colorBitmap[framesNum % BUFFERSIZE].PixelHeight),
this.colorPixels,
this.colorBitmap[framesNum % BUFFERSIZE].PixelWidth * sizeof(int),
0);
framesNum++;
}
}
}
示例11: KinectSensorColorFrameReady
void KinectSensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
bool receivedData = false;
using (ColorImageFrame cFrame = e.OpenColorImageFrame())
{
if (cFrame == null)
{
// The image processing took too long. More than 2 frames behind.
}
else
{
pixelData = new byte[cFrame.PixelDataLength];
cFrame.CopyPixelDataTo(pixelData);
receivedData = true;
}
}
if (receivedData)
{
BitmapSource source = BitmapSource.Create(640, 480, 96, 96,
PixelFormats.Bgr32, null, pixelData, 640 * 4);
videoImage.Source = source;
}
}
示例12: SensorColorFrameReady
public void SensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
if (bitmap == null) {
bitmap = ((WSRKinect)WSRConfig.GetInstance().GetWSRMicro()).NewColorBitmap();
}
CheckQRCode();
}
示例13: sensor_ColorFrameReady
protected void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
using (var frame = e.OpenColorImageFrame()) {
if (frame != null) {
this.ProcessFrame(frame);
}
}
}
示例14: kinect_ColorFrameReady
/// <summary>
/// RGBカメラのフレーム更新イベント
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void kinect_ColorFrameReady( object sender, ColorImageFrameReadyEventArgs e )
{
using ( var colorFrame = e.OpenColorImageFrame() ) {
if ( colorFrame != null ) {
imageRgbCamera.Source = colorFrame.ToBitmapSource();
}
}
}
示例15: SensorColorFrameReady
private void SensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
var colorImageFrame = e.OpenColorImageFrame();
if (colorImageFrame != null)
{
var faceDetection = new FaceDetectionRecognition();
var pixelData = new byte[colorImageFrame.PixelDataLength];
colorImageFrame.CopyPixelDataTo(pixelData);
pictureBox3.Image = FaceDetectionRecognition.BytesToBitmap(pixelData, colorImageFrame.Height, colorImageFrame.Width);
pictureBox3.Refresh();
var detectedFace = faceDetection.GetDetectedFace(pixelData, colorImageFrame.Height, colorImageFrame.Width);
if (detectedFace != null)
{
pictureBox4.Image = detectedFace.Bitmap;
pictureBox4.Refresh();
if (_remainingShots > 0)
{
faceDetection.SaveNewDetectedFace(_tempName, detectedFace);
_remainingShots--;
}
else
{
var user = faceDetection.RecognizeFace(detectedFace);
if (user != null)
{
Console.WriteLine("I recognize you with a mouth!, your are: {0}", user.NickName);
pictureBox2.Image = user.Face.GetBitmap();
pictureBox2.Refresh();
}
else
{
Console.Clear();
Console.WriteLine("You are a new user, would you like to be added to the database? Y/N");
var key = Console.ReadKey();
if (key.KeyChar == 'Y' || key.KeyChar == 'y')
{
Console.WriteLine("Please provide a nick name for you: ");
var name = Console.ReadLine();
faceDetection.SaveNewDetectedFace(name, detectedFace);
_tempName = name;
_remainingShots = 39;
}
}
}
}
}
}