<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Video frame to bitmap in Items with no label</title>
    <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479705#M4853</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't convert it back to bitmapSource. And when I try to convert to Mat I got this exception:&lt;/P&gt;&lt;P&gt;Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'&lt;/P&gt;&lt;P&gt;I can't even debug it because by only running the project it consumes 100% of my CPU. I'm using the D435 camera.&lt;/P&gt;&lt;P&gt;Any further ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinícius&lt;/P&gt;</description>
    <pubDate>Fri, 16 Mar 2018 11:27:53 GMT</pubDate>
    <dc:creator>idata</dc:creator>
    <dc:date>2018-03-16T11:27:53Z</dc:date>
    <item>
      <title>Video frame to bitmap</title>
      <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479699#M4847</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm now starting to use the d435 camera.&lt;/P&gt;&lt;P&gt;I know how to convert a video frame to BitmapSource but is there any function to convert a video frame to bitmap on C# ?&lt;/P&gt;&lt;P&gt;If not how should I approach this? I tried by doing the follow but with no success.&lt;/P&gt;&lt;P&gt;var bytes = new byte[frame.Stride * frame.Height];&lt;/P&gt;&lt;P&gt;            frame.CopyTo(bytes);&lt;/P&gt;&lt;P&gt;            Bitmap bmpRGB = null;&lt;/P&gt;&lt;P&gt;            unsafe {&lt;/P&gt;&lt;P&gt;                fixed (byte* ptr = bytes)&lt;/P&gt;&lt;P&gt;                {&lt;/P&gt;&lt;P&gt;                    using (Bitmap image = new Bitmap(frame.Width, frame.Height, frame.Stride, System.Drawing.Imaging.PixelFormat.Format24bppRgb, new IntPtr(ptr)))&lt;/P&gt;&lt;P&gt;                    {&lt;/P&gt;&lt;P&gt;                        bmpRGB = image;&lt;/P&gt;&lt;P&gt;                        &lt;/P&gt;&lt;P&gt;                    }&lt;/P&gt;&lt;P&gt;                }&lt;/P&gt;&lt;P&gt;            }&lt;/P&gt;&lt;P&gt;            return bmpRGB;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinicius&lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2018 18:44:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479699#M4847</guid>
      <dc:creator>idata</dc:creator>
      <dc:date>2018-03-08T18:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Video frame to bitmap</title>
      <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479700#M4848</link>
      <description>&lt;P&gt;Have you considered the 'Save-To-Disk' SDK 2.0 sample program that saves stream data as a PNG image file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/IntelRealSense/librealsense/tree/master/examples/save-to-disk"&gt;https://github.com/IntelRealSense/librealsense/tree/master/examples/save-to-disk&lt;/A&gt; librealsense/examples/save-to-disk at master · IntelRealSense/librealsense · GitHub &lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2018 19:06:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479700#M4848</guid>
      <dc:creator>MartyG</dc:creator>
      <dc:date>2018-03-08T19:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Video frame to bitmap</title>
      <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479701#M4849</link>
      <description>&lt;P&gt;What's the problem with what you have? Do you get an error or corrupted image? &lt;/P&gt;&lt;P&gt;Does it work if you use frame.Data instead of new IntPtr(ptr)?&lt;/P&gt;&lt;P&gt;Though I think if you do it that way, the bitmap you create will have the same lifespan as the original frame so if the frame is released the bitmap will corrupt. You could try doing "return new Bitmap(bmpRGB)" if this is an issue.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 11:15:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479701#M4849</guid>
      <dc:creator>jb455</dc:creator>
      <dc:date>2018-03-09T11:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Video frame to bitmap</title>
      <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479702#M4850</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem that I have know is that it throws me an exception.&lt;/P&gt;&lt;P&gt;I tried your suggestions.&lt;/P&gt;&lt;P&gt;In the attachments I send the project. Is the cs-tutorial-2-capture sample. Is the sample from Intel but I added the code to convert to bitmap and to display it as a bitmapSource.&lt;/P&gt;&lt;P&gt;My intention is to use the image as bitmap to process it  using OpenCVSharp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Vinícius &lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 14:10:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479702#M4850</guid>
      <dc:creator>idata</dc:creator>
      <dc:date>2018-03-12T14:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Video frame to bitmap</title>
      <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479703#M4851</link>
      <description>&lt;P&gt;Hello VCS_5,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;It would be recommended for you to use this function for saving bitmaps: "int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data);". &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;Here is an example on when this function is used: &lt;P&gt;&amp;nbsp;&lt;/P&gt; &lt;A href="https://github.com/IntelRealSense/librealsense/blob/165ae36b350ca950e4180dd6ca03ca6347bc6367/third-party/stb_image_write.h"&gt;https://github.com/IntelRealSense/librealsense/blob/165ae36b350ca950e4180dd6ca03ca6347bc6367/third-party/stb_image_write.h&lt;/A&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;Hope this function helps to clarify your problem.&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;Best Regards, &lt;P&gt;&amp;nbsp;&lt;/P&gt;Juan N.</description>
      <pubDate>Thu, 15 Mar 2018 19:29:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479703#M4851</guid>
      <dc:creator>idata</dc:creator>
      <dc:date>2018-03-15T19:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Video frame to bitmap</title>
      <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479704#M4852</link>
      <description>&lt;P&gt;This works for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;private System.Drawing.Bitmap FrameToBitmap(VideoFrame frame, System.Drawing.Imaging.PixelFormat format = System.Drawing.Imaging.PixelFormat.Format32bppArgb)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;    if (frame.Width == 0) return null;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;    return new System.Drawing.Bitmap(frame.Width, frame.Height, frame.Stride, format, frame.Data);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just realised what was probably wrong with yours: the bitmap object you create is in a using block so it gets disposed of almost as soon as it's created!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 09:55:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479704#M4852</guid>
      <dc:creator>jb455</dc:creator>
      <dc:date>2018-03-16T09:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Video frame to bitmap</title>
      <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479705#M4853</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't convert it back to bitmapSource. And when I try to convert to Mat I got this exception:&lt;/P&gt;&lt;P&gt;Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'&lt;/P&gt;&lt;P&gt;I can't even debug it because by only running the project it consumes 100% of my CPU. I'm using the D435 camera.&lt;/P&gt;&lt;P&gt;Any further ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinícius&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 11:27:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479705#M4853</guid>
      <dc:creator>idata</dc:creator>
      <dc:date>2018-03-16T11:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Video frame to bitmap</title>
      <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479706#M4854</link>
      <description>&lt;P&gt;Is that when using my code example?&lt;/P&gt;&lt;P&gt;That error suggests the bitmap data is no longer available. Make sure you're not disposing or releasing the bitmap before you use it again, and don't put a variable you'll want to use later as the subject of a using() block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What method are you using to convert the image to a mat?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 11:43:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479706#M4854</guid>
      <dc:creator>jb455</dc:creator>
      <dc:date>2018-03-16T11:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Video frame to bitmap</title>
      <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479707#M4855</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, I'm using your code see the project in the attachment.&lt;/P&gt;&lt;P&gt;To convert Bitmap to Mat I'm using a OpenCVSharp function.&lt;/P&gt;&lt;P&gt;var matImage = BitmapConverter.ToMat(image);&lt;/P&gt;&lt;P&gt;Yo run the project in the attachment you have to install OpenCVSharp 3.xxx via nugget.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinícius&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 11:58:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479707#M4855</guid>
      <dc:creator>idata</dc:creator>
      <dc:date>2018-03-16T11:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Video frame to bitmap</title>
      <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479708#M4856</link>
      <description>&lt;P&gt;Ah, it's a pixelformat issue.&lt;/P&gt;&lt;P&gt;Change the format on line 43 to Format.Bgr8, then in the call on line 59 add ", System.Drawing.Imaging.PixelFormat.Format24bppRgb". (there's either a bug or difference in endianness which causes bgr and rgb to swap)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should work now!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 12:31:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479708#M4856</guid>
      <dc:creator>jb455</dc:creator>
      <dc:date>2018-03-16T12:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Video frame to bitmap</title>
      <link>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479709#M4857</link>
      <description>&lt;P&gt;the bug is that windows uses BGR despite calling it often RGB&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jul 2018 10:34:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Items-with-no-label/Video-frame-to-bitmap/m-p/479709#M4857</guid>
      <dc:creator>PBoos1</dc:creator>
      <dc:date>2018-07-06T10:34:03Z</dc:date>
    </item>
  </channel>
</rss>

