Capture a single image and save it Kinect v2 - c#

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.

Related

How can I save a webcam-recorded mp4 with audio in Visual C#?

I'm two days into researching this so I thought I'd post here. It looks like video recording software is usually written in C++ but my project requires C#. It's a WPF application and I just need it to save an mp4 locally. I don't need to upload to a server, I don't need to let the user pick a file location, I don't even need it to display the webcam feed as it's recording. All I need it to do is start/stop recording audio and video from a webcam/microphone and save it in a location that's determined by the code. I understand this may be broken down into steps like connecting to a webcam, connecting to a microphone, synchronizing them, encoding a video file, and saving it on the hard drive.
Are there any .NET classes that can help me with this? If not, can anyone recommend some libraries/frameworks/etc. that handle this sort of thing? I appreciate any help regarding how to do this. Thank you.

displaying Video Image in winRT gridview

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.

Kinect RGB to AVI File

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.

Getting Matrix (CGAffineTransform) Info from iPhone Movies in C#/C++

When the iPhone records a video it puts the data from the camera directly onto the disk. What tells the player how to reorient the video is the Transform Matrix. Its a Mathematics structure that is used to change the position of the pixels in X,Y space.
In the iPhone and in the Macintosh I can ask the Video what its Transform is, and I get back a CGAffineTransform with a b c d tx and ty. Apple describes the Transform Matrix here
With this information I can determine what the Video layout is supposed to be and determine if it is expecting to be rotated before display.
I can get this information with ease in the osx and ios environments. I am trying to determine a way to get the same matrix information with Windows. Preferrable C# however if I must use C++ then so be it. Active X solutions are entirely undesirable and I am hoping that the Quicktime SDK for windows has some use. Otherwise what the heck did Apple write it for ??
If anyone knows how to obtain the Transform Matrix from a video or any place to start please, point me in the right direction.
It appears that the CGAffineTransform is something that will need to be pulled right out of the file itself. I used the Quicktime File Format Specification pdf to gain an understanding of the file and where to get the CGAffineMatrix
Here is a link to the page with the Matrix data on it
Quicktime File Format Specification Matrix Info
as you can see from this clip the matrix is in the Movie header atom. dignified with the 'mvhd' type.
it is a total of 36 Bytes long and is a total of 36 bytes after the 'mvhd' atom typename.
Given the file format specifications of the frames and tracks the Matrix can change throughout the playback of the video. But it is my experience that this method is not exercised on the videos that are output from the iphone.
I imagine that the matrix will need to be grabbed from each frame sometime in the near future and perhaps this is something that FFMpeg or other video format applications can work into their frame grabbers and video translators. But since I currently do not have a version of ffmpeg that used this matrix information I will be creating a simple Movie header grabber that will pull out the matrix and allow me to adjust my ffmpeg command line parameters accordingly, allowing me to translate my video appropriately..
If I come up with a better idea I will try to include this post on that knowledge.
A side note on the journey to this answer
For all of those who downvoted this question because You did not know what I was talking about. A request to clarify could have been quite sufficient. Coming in and downvoting because you dont understand or dont know the answer is neither constructive or fair. This is a very specific question and this answer will assist more than just myself.
I believe in helping to spread all kinds of knowledge and those of you who think its helpful to downvote because you just dont have any clue on how to help. I hope this gives you a better understanding of the issues that people are looking to solve. Just because you dont know what the problem is does not mean you should turn your nose up at it and certainly does not mean that you should discount those looking for answers that you cannot provide.
I am glad that I have an answer to my question and will definitely be open to any further criticism to the answer that I have given. Perhaps this answer will spark more questions about this issue and I will be able to learn and contribute to the future discussions about it
Thank you StackOverflow for restoring my question so I could answer it appropriately.

Getting WM/Picture using C# and WM Encoder SDK

I was hoping someone could help point me in the right direction and/or provide a sample for me to look at. I need to get the WM/Picture field inside a WMA file that I decode using WM Encoder and C#. I have been able to get all the other tags fine, but media.getAttributeCountByType("WM/Picture", "") function always return 0. But Windows Media Player can display the picture correctly and I saw two hidden JPG files under the same music folder. MSDN don't provide much information about it. Thanks.
program chat voice with c#

Categories