Saving Color and Depth data as png to filestream

I try to save both color and depth data to separate files as PNGs using PngBitmapEncoder but I get much less depth frames saved than color.
If I save color as Jpeg with JpegBitmapEncoder and depth as PNG using PngBitmapEncoder I get the same amount of frames from both streams.
Can anyone explain me why?
private void myKinectSensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
using (ColorImageFrame color = e.OpenColorImageFrame())
if (color != null)
colorbits = new byte[color.PixelDataLength];
color.CopyPixelDataTo(colorbits);
PngBitmapEncoder enc = new PngBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(BitmapSource.Create(color.Width, color.Height, 96, 96, PixelFormats.Bgr32, null, colorbits, color.Width * color.BytesPerPixel)));
if (StartSavingFrames)
string temppath = System.IO.Path.Combine(@"../output/kinect1/color/", colorcnt.ToString() + ".jpeg");
FileStream fs = new FileStream(temppath, FileMode.Create);
enc.Save(fs);
fs.Close();
fs = null;
colorcnt++;
else { colorcnt = 0; }
private void myKinectSensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
using (DepthImageFrame depth = e.OpenDepthImageFrame())
if (depth != null)
frame = new short[depth.PixelDataLength];
depth.CopyPixelDataTo(frame);
for (int i = 0; i < depth.PixelDataLength; i++)
frame[i] = (short)(((ushort)frame[i]) >> 3);
PngBitmapEncoder enc = new PngBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(BitmapSource.Create(depth.Width, depth.Height, 96, 96, PixelFormats.Gray16, null, frame, depth.Width * depth.BytesPerPixel)));
if (StartSavingFrames)
string temppath = System.IO.Path.Combine(@"../output/kinect1/depth/", cnt.ToString() + ".png");
FileStream fs = new FileStream(temppath, FileMode.Create);
enc.Save(fs);
fs.Close();
fs = null;
cnt++;
else { cnt = 0; }

performance of the write operations and the operations of the system at the time you are calling them. You need to ensure your functions are returning and releasing(disposing) of the frames faster than the callback times. When you hold onto data to
long, that just prevents your application from getting new data.
Have a look at the coordinate mapping sample from the toolkit for a way to copy both the depth and color at the same time. From there you need to create a new thread to save that data since write speeds are very slow.
Carmine Sirignano - MSFT

Similar Messages

  • I have 2 apple id's with different apps and data saved under each.  It's very annoying so now I want to create a new id with my primary email address I use now.  If I do that is there any way to transfer all my saved apps and app data like game saves etc?

    I have 2 apple id's with different apps and data saved under each.  It's very annoying so now I want to create a new id with my primary email address I use now.  If I do that is there any way to transfer all my saved apps and app data like game saves etc so I don't lose all of that information and can easily switch to a singular apple id?

    Apple does not transfer content bought with one Apple ID to another Apple ID. Apple will not merge two Apple IDs.
    If most of your content was bought with the Yahoo! Apple ID but you now want the Gmail address for your Apple ID, the trick will be to change the address used for the Yahoo ID with the Gmail address. However, to do that you must first free the Gmail address from that other Apple ID. Use the instructions from Apple to substitute another address that is not used as an Apple ID for your Gmail address in the Apple ID with the Gmail address. Then, when the Gmail address is no longer used in an Apple ID, you can use the same instructions to substitute the Gmail address for the Yahoo address in the Apple ID with the Yahoo address.
    Changing the email address you use for your Apple ID -
    http://support.apple.com/kb/HT5621

  • Microsoft Exchange - saving contacts and calendar data

    Hi all,
    I have just joined a new company and I will be connecting my iPhone to their email network using Microsoft Exchange. However, I want to make sure I do not lose my existing contact and calendar data. Does anybody have any suggestions on what I can do? Currently, my contacts and calendar are synchronized with Outlook in my home computer.

    Mistiano,
    As long as your contact and calendar data is synced to Outlook, you shouldn't lose anything as it will still be saved on your computer.
    If you'd like to keep your personal contacts and calendars synced concurrently to your iPhone along with the companies, you could either move your contacts to their server or apply for a MobileMe account, which would keep your data separate: http://www.apple.com/mobileme/
    Hope this helps,
    Raleigh

  • Mac system updates wipe all my saved passwords and other data

    Every time my macbook performs a system update (which all you mac users know is weekly or bi-weekly) all of my passwords are wiped, as well as any address, phone number, and other data for filling in fields.
    Is this supposed to happen? Is there a way to avoid it?
    I only just started using Firefox a month ago when the Flock programmers turned stooges, so if I can't avoid this it's not too late for me to switch to a different browser.

    You should get your data back when you leave Private Browsing mode, i.e. remove the checkmark and restart Firefox.
    Firefox stores the open tabs in the sessionstore.js file, so make sure that Session Restore is working properly.
    You can reset <b>browser.sessionstore.*</b> prefs that are user set (bold) to the default value via the right-click context menu on the <b>about:config</b> page to make sure that Session Restore is enabled and working properly.
    *http://kb.mozillazine.org/Session_Restore
    *https://support.mozilla.org/kb/restore-previous-session

  • Color and depth lost when reading PNG

    Hello,
    I'm using IMAQ Read Image And Vision Info.vi to read a PNG saved with IMAQ Write Image And Vision Info.vi. The saved image is 24 bits, color. When I open the image and display it using an image control, it shows up as an 8-bit grayscale. How do I get it to open in color?
    Thanks.

    Are you passing a 24-bit color image into the image terminal of this VI? Most likely, you have the default Grayscale (U8) Image type for the initialization of the image that you feed into the IMAQ Read Image And Vision Info.vi. It is a terminal on the bottom of the IMAQ Create vi.
    Hope that this helps,
    Bob
    Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
    DISTek Integration, Inc. - NI Alliance Member
    mailto:[email protected]

  • Saving to and collecting data from a database

    I am working on  a small project where 3 forms need to interact with each other. Form 1 should be completed then the information saved to a database then form 2 called and because of common fields between the 2 forms...data should be populated from the database to form 2 (data that was entered from form1).
    How is this done? Whats the javascript solution for this issue? the code used to save information from a text field, combobox and to retrieve it to populate another?
    Thanks in advance

    This is typically implemented as a LiveCycle orchestration:
    Form 1 is completed and submitted to a LiveCycle orchestration on the server
    The orchestration saves the submitted data to the database and then uses it to pre-populate Form 2
    Form 2 is sent to the user
    Common options for these steps include:
    Submission by email using a LiveCycle email end-point or secure, seamless submission by HTTPS to a web component (e.g. servlet or ASP.NET page) that calls the orchestration as a web service using the LiveCycle SOAP end-point
    Form Pre-population is performed using Forms Data Integration (FDI) or LiveCycle Forms
    Form is sent to user either by email or streamed back in same session if using HTTPS
    Avoka Technologies provides a pre-built web component Process Invoker that makes it easy to implement the HTTPS submission option.
    Of course, if the forms are filled out by the same user, you could merge them into one form and collect all the data on the client side before submitting to the server. You can even use show/hide to give the user the experience of filling out multiple forms if that is desired.
    Ben Walsh
    www.avoka.com

  • Saving files and copying data into final cut express

    I have read that you can create duplicate copies of your I movie project and work between them so ou can make changes but always have a master file.
    but I have not been able to figure out how to do that. And after I am finishend with my project I can export it to final cut express for some additional editing and video layering is that true? can I do the sme with final cut pro or just final cut express? Also is there any quality loss in this method? Thanks in advance

    Hi tnt,
    you write on a piece of paper; you copy that paper; you continue to write on the first one... how does the copy "know", what you've written..???
    sorry, who gave you that advice of copying projects? backup frequently, yepp, that makes sense with ANY data on a computer... but with a backup you allways go back in time.....
    FCE is able to open iMovie project directly (don't know about FCP, don't own, $$$); BUT then the file structure is broken, you can NOT re-import project to iM, BUT the movie...
    you know the difference? a movie is one single block, a project makes it possible to edit transitions, to edit titles etc...
    for sure, you can export and import from and to iM and FCE/P without loss of quality as long as you stay with "dv stream" (native file format of both/all three apps). I'm, doing this a lot, using iM for editing and FCE "just" for "special effects", advanced titles etc.-
    hope I could be helpful

  • Saving table and waveform data

    Hello,
    what i have is a table and digital waveform graph.  what i need to do is save the data and send it to a database in xml format and then when i load the data it will populate the table and graph again.  can someone give advice or an example would be ideal.  thank you.

    Well there are a number of XML functions in String->XML, which should help you convert your data to XML.
    Then, are you using the database toolkit?  If so, there's plenty of help here, and in the forums if you search for it.
    If not, try looking here for some examples Mike Porter posted about connecting without the toolkit.

  • Saving slow and fast data on the time stamp..

    Hi ! I'm retrieving data fast data from DAQ device  (dt=0,01s) and from GPS resiever (dt=1s) . I need to save all data on common time axis.
    Is there way to put zero in slow data colum if regular data are missing ?
    (sorry for stupid question I'm LV beginner )
    thanks
    Attachments:
    GPS_and_fast_data.vi ‏232 KB

    I tried to make it all day. This attachment demonstrate the way that look to be resolution of my problem.
    Message Edited by CUA on 05-07-2007 08:29 AM
    Message Edited by CUA on 05-07-2007 08:30 AM
    Attachments:
    GPS_and_fast_data_rev1.vi ‏201 KB

  • I'm new to photoshop and I want to convert an image file to a fabric file like .zfab or .fab...is this possible? I want the image to be in color and the images are .png. I am using windows 8

    HI I am using software for fashion design called Marvelous Design . I want to import my fabric patterns which are .png image files but they have to be in .zfab or .fab format. can adobe convert these files into these extensions? If so, how do I do it? Thanks for any help!

    This is from File extension FAB - Open .fab files :
    The FAB file extension is associated with the Fabmaster software, or file format developed by the Electronic Source Company.
    Fabmaster seems to be obsolete product that is not supported by its developers.
    ~~~~~~~~~~~~~~~
    As for the software, did you mean Marvelous Designer?
    ~~~~~~~~~~~~~~~
    For ALL file formats supported by Photoshop, see:
    Photoshop Help | Supported file formats

  • New BC Forum (Community) is Sluggish, where is previous saved bookmarks and other data?

    The new forums seem really sluggish to me compared to the old system. Will this be improved?
    Also, my forum account had numerous discussions, bookmarks, etc. None of there are available now. Are they gone or am I missing something?
    If gone, kind of defeated the purpose of saving/bookmarking info for later review if it got wiped out.

    These forums are run by Adobe themselves through Jive, Lots of changes to fix lots of areas have been on going since the Jive new update.
    Your bookmarks etc are under the more link on your profile.

  • When creating a fillable form and saving it as a pdf, the default color of the data fields is a light blue. How do I change the color to something else that will copy better, e.g. a light yellow?

    When creating a fillable form and saving it as a pdf, the default color of the data fields is a light blue. How do I change the color to something else that will copy better, e.g. a light yellow?

    It's probably the fields highlight color of the application, which you can change via Edit - Preferences - Forms.

  • Edit a png file... change colors and text and then export to gif?

    First I want to state that I am VERY new to Fireworks and I am trying to figure out how this works!  I typically use Photoshop.
    I was sent a PNG file (from a friend).  The file has many buttons on it that I believe are somehow saved or exported out as gif images to be buttons on her website.  All of the buttons are basic rectangles that are gray with black text.  She was told she could edit all of the buttons quickly in Fireworks (change their color, font color, etc) and it would change them all together.  Then save them all out so we would have the individual gif files for the buttons to save to the directory.
    So... I am able to open the png file in Fireworks and I can select each button or all of them, but I cannot see how to change their color and font, etc.  I know this must be very simple!  Can someone help me?
    Thank you!
    Sharlyn

    Have a look in the ocument Library panel to see if the buttons are Symbols. If yes, then double click on one of the buttons to open it in the symbol editor where you can easily make changes in all of them at once.

  • Kinect Explorer WPF C# read depth data from the file and conversion to skeleton

    Hello,
    I am using Kinect sensor to do some research on biometrics. Since it is impossible to find people to collect some samples, I would like to use samples from the TUM - GAID database, where there exist Color View and Depth View (in .raw format) samples. Therefore,
    I need to read these samples from the file and do a batch processing, instead of performing real-time collecting of samples (where I can take automatically the Skeleton view using the Kinect SDK). So, I need help on
    1. Reading the data from the file (instead of activating the Kinect sensor) and give this data as an input for conversion to a skeleton
    2. Read the .raw files 
    Thank you very much
    Kind regards

    Hiya,
     I doubt this forum, C Sharp, will provide much help. You are asking about the Kinects system not C#
    language. However, you can try this link; http://kinectforwindows.codeplex.com/
    Hope this help. Thanks :)

  • Correct way copying depth data or color data to opencvMat

    Hello,
    I want to collect synchronized IR data, depth data and color data from the kinect v2. Following the pattern from the sample, CoordinateMapper, I am stuck on the section below:
    if (imageFormat == ColorImageFormat_Bgra)
    hr = pColorFrame-AccessRawUnderlyingBuffer(&nColorBufferSize, reinterpret_cast<BYTE**>(&pColorBuffer));
    else if (m_pColorRGBX)
    pColorBuffer = m_pColorRGBX;
    nColorBufferSize = cColorWidth * cColorHeight * sizeof(RGBQUAD);
    hr = pColorFrame<CopyConvertedFrameDataToArray(nColorBufferSize, reinterpret_cast<BYTE*>(pColorBuffer), ColorImageFormat_Bgra);
    In particular,
    1) why is there a copy from the underlying buffer and
    2) what is m_pColorRGBX (initialization for the color image buffer perharps?)
    3) how would I copy the resulting color image to an opencv cv::Mat array in a memory safe fashion?
    Any help is greatly appreciated.

    Hi Carmine Sirignano,
    thank you for the information. 
    So, if I understand correctly, the code above says,
    if the imageFormat of the incoming frame is already in BGRA, THEN->,
    Copy the underlying buffer to the colorBuffer
    BUT if the m_pColorRGBX is initialized, THEN ->
    Initialize the color buffer, and copy into the buffer
    I understand the first condition, but I am unclear as to why we have the second condition for m_pColorRGBX. Can you explain why this is?
    Finally, I would like to copy the buffer data into a cv::Mat. Can you give any guidelines on how to do this in a safe fashion?

Maybe you are looking for

  • Issue with minidisplay adapter and wifi

    I'm not sure if anyone else is having this issue, but my gf is having an issue when she connects her 13" macbook pro to her monitor via the minidisplay dvi adapter. When she connects it her wifi disconnects and has no internet access at all, but when

  • SQ02 Infoset Query

    Hi When I'm trying to create an infoset query by using the trasaction SQ02 , while generating it's throwing the error " Error in Parameter PYPARAID     Statement concluding with "---Type" ended unexpectedly". Can anyone pl help me in creating a query

  • Linking listbox to frames

    ok basicly i have a listbox which gets data striaght from my sql database and i was wondering how i could link each value with in the list box to each frame  so that when a item is selected in the list box it goes to a frame like how  button uses got

  • Multiple sales order  with single invoice

    Hi ! For the same dealer can we make single Invoice dispatching  with multiple sales order ???  and How ? Thanks.

  • Exporting Image from Acrobat

    I have an InDesign document that has two imbedded JPG images. One image still retains the link to the original file, the second image is no longer linked to the original file and does not exist. Let say image one is of a tree and the second image tha