/// <summary> /// runs when new color frame is received /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void SensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e) { if (is_observing_live) { using (ColorImageFrame colorFrame = e.OpenColorImageFrame()) { if (colorFrame != null) { if (is_recording) { long now = colorFrame.Timestamp; MyColorFrame myColorFrame = new MyColorFrame(now, colorFrame.ToBitmap()); recorded_color_frames.Add(myColorFrame); clabel2.Content = recorded_color_frames.Count; } // Copy the pixel data from the image to a temporary array colorFrame.CopyPixelDataTo(this.colorPixels); // Write the pixel data into our bitmap this.colorBitmap.WritePixels( new Int32Rect(0, 0, this.colorBitmap.PixelWidth, this.colorBitmap.PixelHeight), this.colorPixels, this.colorBitmap.PixelWidth * sizeof(int), 0); } } } }
public static Image <TColor, TDepth> ToOpenCVImage <TColor, TDepth>(this ColorImageFrame image) where TColor : struct, IColor where TDepth : new() { var bitmap = image.ToBitmap(); return(new Image <TColor, TDepth>(bitmap)); }
void RuntimeColorFrameReady(AllFramesReadyEventArgs e) { using (ColorImageFrame colorFrame = e.OpenColorImageFrame()) { if (colorFrame == null) { return; } ColorImage.Image = colorFrame.ToBitmap(); if (_saveColorFrame) { _saveColorFrame = false; colorFrame.ToBitmap().Save(DateTime.Now.ToString("yyyyMMddHHmmss") + "_color.jpg", ImageFormat.Jpeg); } } }
/// <summary> /// When all the frames we need from the kinect sensor are ready, process them /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event</param> private void SensorOnAllFramesReady(object sender, AllFramesReadyEventArgs e) { // Process the color frame using (ColorImageFrame colorFrame = e.OpenColorImageFrame()) { // We have a color frame (this is always true unless camera feed is cut) if (colorFrame != null) { KinectCamera.Source = colorFrame.ToBitmap(); } } using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) { SkeletonCanvas.Children.Clear(); if (skeletonFrame != null) { // Clear previous frame of skeleton drawings // RESET FOR ORIGINAL METHOD SkeletonCanvas.Children.Clear(); // Copy the skeletons from the frame into class property skeletonFrame.CopySkeletonDataTo(this.skeletons); using (DrawingContext dc = this.drawingVisual.RenderOpen()) { // process each skeleton foreach (Skeleton skeleton in this.skeletons) { if (skeleton.TrackingState == SkeletonTrackingState.Tracked) { if (this.DEBUG) { this.DrawBonesAndJoints(skeleton, dc); } this.DrawShirtToSkeleton(skeleton); } } SkeletonCanvas.Children.Add(this.visualHost); } } } }
void FrameReady(object sender, ColorImageFrameReadyEventArgs e) { ColorImageFrame imageFrameC = e.OpenColorImageFrame(); if (imageFrameC != null) { //Bitmap bmap = ImageToBitmap(imageFrame); //Image<Bgr, Byte> img = bmap. Bitmap bmap = imageFrameC.ToBitmap(); running = true; My_Image = new Image <Bgr, Byte>(bmap); //pictureBox1.Image = My_Image.ToBitmap(); } else { running = false; } }
public static Bitmap ToBitmap(this ColorImageFrame image) { return(image.ToBitmap(System.Drawing.Imaging.PixelFormat.Format32bppRgb)); }
/// <summary> /// Converts a color frame to a System.Media.ImageSource. /// </summary> /// <param name="frame">A ColorImageFrame generated from a Kinect sensor.</param> /// <returns>The specified frame in a System.media.ImageSource format.</returns> public static ImageSource ToBitmap(this ColorImageFrame frame) { return(frame.ToBitmap(PixelFormats.Bgr32)); }
/// <summary> /// Converts a color frame to a System.Drawing.Bitmap. /// </summary> /// <param name="frame">A ColorImageFrame generated from a Kinect sensor.</param> /// <returns>The specified frame in a System.Drawing.Bitmap format.</returns> public static Bitmap ToBitmap(this ColorImageFrame frame) { return(frame.ToBitmap(PixelFormat.Format32bppRgb)); }