本文整理汇总了C#中Microsoft.Kinect.ColorImageFrameReadyEventArgs.OpenColorImageFrame方法的典型用法代码示例。如果您正苦于以下问题:C# ColorImageFrameReadyEventArgs.OpenColorImageFrame方法的具体用法?C# ColorImageFrameReadyEventArgs.OpenColorImageFrame怎么用?C# ColorImageFrameReadyEventArgs.OpenColorImageFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Kinect.ColorImageFrameReadyEventArgs
的用法示例。
在下文中一共展示了ColorImageFrameReadyEventArgs.OpenColorImageFrame方法的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: 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);
}
}
示例4: 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);
}
}
}
示例5: 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
);
}
}
示例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: 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();
}
}
示例9: 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++;
}
}
}
示例10: 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();
}
}
}
示例11: sensor_ColorFrameReady
protected void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
using (var frame = e.OpenColorImageFrame()) {
if (frame != null) {
this.ProcessFrame(frame);
}
}
}
示例12: 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;
}
}
}
}
}
}
示例13: kinect_ColorFrameReady
void kinect_ColorFrameReady( object sender, ColorImageFrameReadyEventArgs e )
{
// Disposableなのでusingでくくる
using ( ColorImageFrame colorFrame = e.OpenColorImageFrame() ) {
if ( colorFrame != null ) {
imageRgbCamera.Source = colorFrame.ToBitmapSource();
}
}
}
示例14: myKinect_ColorFrameReady
void myKinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame == null) return;
bmap = OpenCV2WPFConverter.ColorImageFrameToBitmap(colorFrame);
imgBgr = new Image<Bgr, Byte>(bmap);
imgHsv = new Image<Hsv, Byte>(bmap);
if (imgBgr == null || imgHsv == null) return;
processedBgr = imgBgr.InRange(new Bgr(B_min, G_min, R_min), new Bgr(B_max, G_max, R_max));
processedHsv = imgHsv.InRange(new Hsv(H_min, S_min, V_min), new Hsv(H_max, S_max, V_max));
//0,130,0 ~ 120, 256, 120 for green color.
processedBgr = processedBgr.SmoothGaussian(7);
processedHsv = processedHsv.SmoothGaussian(7);
CircleF[] circlesBgr = processedBgr.HoughCircles(cannyThreshold, circleAccumulatorThreshold
, 2, processedBgr.Height / 8 , 8, 40)[0];
CircleF[] circlesHsv = processedBgr.HoughCircles(cannyThreshold, circleAccumulatorThreshold
, 2, processedHsv.Height / 8, 8, 40)[0];
HsvCircleCount = 0;
RgbCircleCount = 0;
// Draw Circles for RBG video stream
foreach (CircleF circle in circlesBgr)
{
RgbCircleCount += 1;
imgBgr.Draw(circle, new Bgr(System.Drawing.Color.Bisque), 3);
}
// Draw Circles for HSV video stream
foreach (CircleF circle in circlesHsv)
{
HsvCircleCount += 1;
imgBgr.Draw(circle, new Bgr(System.Drawing.Color.Bisque), 3);
}
kinectVideo.Source = OpenCV2WPFConverter.ToBitmapSource(imgBgr);
HsvVideo.Source = OpenCV2WPFConverter.ToBitmapSource(processedHsv);
RgbVideo.Source = OpenCV2WPFConverter.ToBitmapSource(processedBgr);
//control the distance of different circles!
this.HsvCircleUI.Content = HsvCircleCount.ToString();
this.RgbCircleUI.Content = RgbCircleCount.ToString();
}
}
示例15: sensor_ColorFrameReady
void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
ColorImageFrame colorFrame = e.OpenColorImageFrame();
if (colorFrame != null)
{
byte[] pixelData = new byte[colorFrame.PixelDataLength];
colorFrame.CopyPixelDataTo(pixelData);
BitmapSource source = BitmapSource.Create(640,480,96,96,PixelFormats.Bgr32, null, pixelData, 640*4);
imgKinect.Source = source;
}
}