I am attempting to save a video file (e.g., .AVI file) from the Kinect's RGB stream.
I am using the latest Kinect SDK (1.5)
I tried using e2e's DirectShow filters and it didn't work, there must be a more straight forward approach.
I tried the colorBasics method of writing each frames as .png files. But, then the speed reduced to 6fps from 30fps. I guess, multi-threading may help to increase the performance. I dont know how to multi thread it, is there any online source of it. I searched a lot, but no luck yet.
Thanks.
The Kinect does not directly support recording straight off the video streams. You can accomplish it by accessing each frame, as it comes in, and creating an AVI (or other video format) in code.
The Kinect Toolbox has a video recorder, you can look at the source as a starting point.
You can easily extract WriteableBitmap objects from the Kinect RGB camera. From that you can find a lot of information on creating still images to produce an AVI, or produce an AVI directly.
Google Search: Create AVI from still images
Google Search: Create AVI from WPF WriteableBitmap
Have a look at the "Color Basics" example from the Kinect for Windows Developer Toolkit to see how to access the camera and extract data to a WritableBitmap object.
Related
I get a stream of frames, an initial SPS and PPS h264 data packet and then packets for the I and P frames.
Using c# .NET I want to convert into a series of JPEGs? Has anyone done this?
I have tried AForge.NET FFMpeg wrapper, but can only go from MP4 file to JPEGs?
Also looked at DirectShow.
I can't seem to find an examples that even come close to doing this?
Thanks
In Directshow, it sounds like you need to introduce a SampleGrabber filter into your filter graph. Insert this after the H264 decoder.
This is a pass through filter which can receive a callback containing each video frame. You can then obviously choose what you do with the frame, is save it to disk as a jpeg etc.
Rather than regurgitate MSDN, there is a great page explaining its usage here:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd407288(v=vs.85).aspx
Update taking account of Roman's comments:
SampleGrabber is deprecated as its part of Directshow Editing Services. However, it is quite self contained. If it was removed from a later version of Windows it would be straight forward to replace with an alternative filter. I still use it in one of my consumer applications. Roman is correct though - it has a steep learning curve.
I have a small problem that I am sure has an easy fix but I am having difficulty finding an example or working code. I am programming in Visual Studio using C#.
I am trying to capture an image from the Kinect (v2) device. The device is already working as its intended in my programme and is displaying the colour feed and skeletal data on screen. When the user meets certain conditions, I want to write a method to capture 5 or so consecutive frames from the camera and save those image files somewhere on my computer.
I have been looking at examples such as Capture Image from Kinect v2 Sensor but these aren't really leading anywhere! I have read that I should be using CanvasBitmap method but not really sure where to take it from there?
Any help would be appreciated
The ColorBasics Sample, (stored in C:\Program Files\Microsoft SDKs\Kinect\v2.0_1409\Samples\Managed\ColorBasics-WPF after you have installed the Kinect v2 SDK) shows you how to store the color stream into a WriteableBitmap.
You can then use the information from this answer to store the image.
I'm developing a Windows 8 Store App, I have this problem,
I want the user to add the videos from a file picker and i managed it,
the problem is I want to display the videos images in a GridView,
like snap shot of the video in a certain position, i tried the media element and it's not working
also an image and it doesn't make sense.
There might not be a pure C# solution to this problem. Perhaps SharpDX would let you do that, but I haven't tried and I don't know if it was done before. If you look at these two threads:
http://social.msdn.microsoft.com/Forums/fil-PH/wingameswithdirectx/thread/05731d4f-5b7f-4ed1-8e28-94604655139e
http://social.msdn.microsoft.com/Forums/en/wingameswithdirectx/thread/ffacd05c-6e9e-43bf-b691-99127240730c
-- you should see that there is a TransferVideoFrame method you can use to copy a frame from a video stream to a DirectX texture. The Media engine native C++ video playback sample shows how you can use it natively. If you search for TransferVideoFrame+SharpDX - you can find this sample that uses the SharpDX version of this method in C#. After you transfer that frame to a texture - you can either copy the contents of the texture to a WriteableBitmap using the Map and Unmap methods like here. You can also save it to a file either using BitmapEncoder a here or directly from the DirectX texture to a file using WIC or say SharpDX Toolkit as in here. You will probably want to build a cache of thumbnails to avoid having to process the videos every time you display the list, so saving to a file is something you should do anyway.
Your own solution that you quoted elsewhere that should work for at least some videos:
var thumb = await
storageFile.GetThumbnailAsync(
Windows.Storage.FileProperties.ThumbnailMode.PicturesView,
1000,
Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale);
I suggest using GetThumbnailAsync(), which works just as well. You don't even need to get the video properties or anything like that. If the StorageFile is loaded, this should work for a normal video of any format.
I'm trying to figure out how to overlay an image over a (saved file) video in Visual C#, and then resave it. I've been ripping my hair out trying to do this for the past four hours, looking everywhere, so any help would be hugely appreciated.
DirectShow.NET is a wrapper over DirectShow, a [previous generation] MS Multimedia API. The API itself is better suitable for native development, however .NET wrapper is pretty popular and powerful.
DirectShow.NET samples include:
Samples\Capture\DxLogo
---------------------- A sample application showing how to superimpose a logo on a data stream. It uses a capture device for the video
source, and outputs the result to a file.
Samples\Players\DxText
---------------------- A sample application showing how to superimpose text strings on a datastream. The stream is read from an avi file.
I'm gathering consecutive images from Kinect's RGB camera from the code below;
PlanarImage Image = e.ImageFrame.Image;
video.Source = BitmapSource.Create(
Image.Width, Image.Height, 96, 96, PixelFormats.Bgr32, null, Image.Bits, Image.Width * Image.BytesPerPixel);
And i want to stream the series of images that i get from Kinect as a real time stream on my WPF application, but I don't know how to. The reason is that i want to be able to use the Kinect as a webcam, but the other solutions (coding a directshow filter, or using only one available one) didn't worked for me for resolution or my lack of knowledge in C++ issues. Writing a direct show filter for Kinect to act as a virtual cam is extremely challenging for someone on my level with C++.
To sum up, problem lies within the output of Kinect, it gives me a series of images which i don't really know how to turn it to a real time stream that I can display from other applications.
Any help is appreciated thanks!
IF a commercial library is an option take a look at http://www.visioforge.com/video-capture-sdk-net2.html - it can capture and also stream in WMV...
Another commercial option would be Leadtools Videostreaming SDK - see http://www.leadtools.com/sdk/video-streaming.htm
DirectShow is indeed your best bet. There is nothing in WPF for streaming video to other apps.
As mentioned in the comments above the Kinect produces a series of Images instead of generating a streaming video.
This page is going to be helpful while extracting depth data from the Kinect in Microsoft Kinect SDK:
http://www.i-programmer.info/programming/hardware/2714-getting-started-with-microsoft-kinect-sdk-depth.html
If you are using processing you can import the SimpleOpenNI library(https://code.google.com/p/simple-openni/) which supports video capture (you can find examples within the library).
This video stream comes in .ONI format, which can be converted into AVI via the following library:
http://kirilllykov.github.io/blog/2013/03/19/convert-openni-star-dot-oni-files-into-avi/
All the best, let us know if you find any other method.