<?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 Jpeg encoder problem with CMemBuffOutput in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/Jpeg-encoder-problem-with-CMemBuffOutput/m-p/957438#M19243</link>
    <description>&lt;P&gt;I am having problems with encoding a bytestream into Jpeg when the output is memory (CMemBuffOutput) but no problems at all when the output is a file (CStdFileOutput).&lt;/P&gt;
&lt;P&gt;The encoding code is called from C# using pinvoke.&lt;/P&gt;
&lt;P&gt;[csharp]&lt;/P&gt;
&lt;P&gt;public static class FrameEncoder&lt;BR /&gt;{&lt;BR /&gt;public static MemoryStream EncodeJPG(IntPtr data, int width, int height, int stride, int pxFormat, bool needFlipY, int size)&lt;BR /&gt;{&lt;BR /&gt;var jpeg = new byte[size];&lt;BR /&gt;MyDll.EncodeJpg(data, jpeg, size, 3, width, height, stride);&lt;BR /&gt;var stream = new MemoryStream(jpeg, 0, size, false, true);&lt;BR /&gt;return stream;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;[DllImport("encoderDll.dll")]&lt;BR /&gt;private static extern int encodeJpeg(IntPtr input, byte[] output, int length, int numChannels, int width,&lt;BR /&gt;int height, int step);&lt;/P&gt;
&lt;P&gt;public static int EncodeJpg(IntPtr input, byte[] output, int length, int numChannels, int width, int height,&lt;BR /&gt;int step)&lt;BR /&gt;{&lt;BR /&gt;return encodeJpeg(input, output, length, numChannels, width, height, step);&lt;BR /&gt;}&lt;BR /&gt;[/csharp]&lt;/P&gt;
&lt;P&gt;[cpp]&lt;BR /&gt;int WINAPI encodeJpeg(unsigned char* input, unsigned char* output, int length, int numChannels, int width, int height, int step)&lt;BR /&gt;{&lt;/P&gt;
&lt;P&gt;//copied from UIC sample&lt;BR /&gt;CMemBuffOutput out;&lt;BR /&gt;UIC::Point origin;&lt;BR /&gt;UIC::RectSize size;&lt;BR /&gt;UIC::Rect refGrid;&lt;BR /&gt;UIC::Image imgCn;&lt;BR /&gt;UIC::JPEGEncoder encoder;&lt;BR /&gt;UIC::ImageDataPtr dataPtr;&lt;BR /&gt;UIC::ImageColorSpec colorSpec;&lt;BR /&gt;UIC::ImageDataOrder dataOrder;&lt;BR /&gt;UIC::ImageSamplingGeometry geo;&lt;BR /&gt;UIC::ExcStatus status;&lt;/P&gt;
&lt;P&gt;if(!BaseStream::IsOk(out.Open(output, length)))&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;// test&lt;BR /&gt;/*char* outputFile = "test.jpg";&lt;BR /&gt;CStdFileOutput outputF;*/&lt;BR /&gt;/*if(!BaseStream::IsOk(outputF.Open(outputFile)))&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}*/&lt;/P&gt;
&lt;P&gt;status = encoder.Init();&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;status = encoder.AttachStream(out);&lt;BR /&gt;//status = encoder.AttachStream(outputF);&lt;BR /&gt;dataOrder.SetDataType(UIC::ImageDataType::T8u);&lt;BR /&gt;size.SetWidth(width);&lt;BR /&gt;size.SetHeight(height);&lt;BR /&gt;origin.SetX(0);&lt;BR /&gt;origin.SetY(0);&lt;BR /&gt;refGrid.SetOrigin(origin);&lt;BR /&gt;refGrid.SetSize(size);&lt;BR /&gt;geo.SetRefGridRect(refGrid);&lt;BR /&gt;geo.ReAlloc(numChannels);&lt;BR /&gt;dataOrder.ReAlloc(UIC::ImageComponentOrder::Interleaved, numChannels);&lt;BR /&gt;dataOrder.PixelStep()[0] = numChannels;&lt;BR /&gt;dataOrder.LineStep()[0] = step;&lt;BR /&gt;status = imgCn.ColorSpec().ReAlloc(numChannels);&lt;BR /&gt;imgCn.ColorSpec().SetColorSpecMethod(Enumerated);&lt;BR /&gt;imgCn.ColorSpec().SetComponentToColorMap(Direct);&lt;/P&gt;
&lt;P&gt;for(int i = 0; i &amp;lt; numChannels; i++)&lt;BR /&gt;{&lt;BR /&gt;imgCn.ColorSpec().DataRange()&lt;I&gt;.SetAsRange8u(255);&lt;BR /&gt;}&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;imgCn.ColorSpec().SetEnumColorSpace(UIC::ImageEnumColorSpace::RGB);&lt;/P&gt;
&lt;P&gt;dataPtr.p8u = input;&lt;BR /&gt;status = imgCn.Buffer().Attach(&amp;amp;dataPtr, dataOrder, geo);&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;status = encoder.AttachImage(imgCn);&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;status = encoder.SetParams(JMODE::JPEG_BASELINE, JCOLOR::JC_RGB, JSS::JS_444, 0, 0, 75);&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;status = encoder.WriteHeader();&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;status = encoder.WriteData();&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;BR /&gt;[/cpp]&lt;/P&gt;
&lt;P&gt;When output is CMemBuffOutput, the values in output are always the same, even when the input data (the camera captured image) has changed. For instance if i cover the camera (total black) the input data values reflect this but output values don't change.&lt;/P&gt;
&lt;P&gt;Any idea what i'm doing wrong?&lt;/P&gt;</description>
    <pubDate>Wed, 16 Oct 2013 08:52:14 GMT</pubDate>
    <dc:creator>cks2k2</dc:creator>
    <dc:date>2013-10-16T08:52:14Z</dc:date>
    <item>
      <title>Jpeg encoder problem with CMemBuffOutput</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Jpeg-encoder-problem-with-CMemBuffOutput/m-p/957438#M19243</link>
      <description>&lt;P&gt;I am having problems with encoding a bytestream into Jpeg when the output is memory (CMemBuffOutput) but no problems at all when the output is a file (CStdFileOutput).&lt;/P&gt;
&lt;P&gt;The encoding code is called from C# using pinvoke.&lt;/P&gt;
&lt;P&gt;[csharp]&lt;/P&gt;
&lt;P&gt;public static class FrameEncoder&lt;BR /&gt;{&lt;BR /&gt;public static MemoryStream EncodeJPG(IntPtr data, int width, int height, int stride, int pxFormat, bool needFlipY, int size)&lt;BR /&gt;{&lt;BR /&gt;var jpeg = new byte[size];&lt;BR /&gt;MyDll.EncodeJpg(data, jpeg, size, 3, width, height, stride);&lt;BR /&gt;var stream = new MemoryStream(jpeg, 0, size, false, true);&lt;BR /&gt;return stream;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;[DllImport("encoderDll.dll")]&lt;BR /&gt;private static extern int encodeJpeg(IntPtr input, byte[] output, int length, int numChannels, int width,&lt;BR /&gt;int height, int step);&lt;/P&gt;
&lt;P&gt;public static int EncodeJpg(IntPtr input, byte[] output, int length, int numChannels, int width, int height,&lt;BR /&gt;int step)&lt;BR /&gt;{&lt;BR /&gt;return encodeJpeg(input, output, length, numChannels, width, height, step);&lt;BR /&gt;}&lt;BR /&gt;[/csharp]&lt;/P&gt;
&lt;P&gt;[cpp]&lt;BR /&gt;int WINAPI encodeJpeg(unsigned char* input, unsigned char* output, int length, int numChannels, int width, int height, int step)&lt;BR /&gt;{&lt;/P&gt;
&lt;P&gt;//copied from UIC sample&lt;BR /&gt;CMemBuffOutput out;&lt;BR /&gt;UIC::Point origin;&lt;BR /&gt;UIC::RectSize size;&lt;BR /&gt;UIC::Rect refGrid;&lt;BR /&gt;UIC::Image imgCn;&lt;BR /&gt;UIC::JPEGEncoder encoder;&lt;BR /&gt;UIC::ImageDataPtr dataPtr;&lt;BR /&gt;UIC::ImageColorSpec colorSpec;&lt;BR /&gt;UIC::ImageDataOrder dataOrder;&lt;BR /&gt;UIC::ImageSamplingGeometry geo;&lt;BR /&gt;UIC::ExcStatus status;&lt;/P&gt;
&lt;P&gt;if(!BaseStream::IsOk(out.Open(output, length)))&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;// test&lt;BR /&gt;/*char* outputFile = "test.jpg";&lt;BR /&gt;CStdFileOutput outputF;*/&lt;BR /&gt;/*if(!BaseStream::IsOk(outputF.Open(outputFile)))&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}*/&lt;/P&gt;
&lt;P&gt;status = encoder.Init();&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;status = encoder.AttachStream(out);&lt;BR /&gt;//status = encoder.AttachStream(outputF);&lt;BR /&gt;dataOrder.SetDataType(UIC::ImageDataType::T8u);&lt;BR /&gt;size.SetWidth(width);&lt;BR /&gt;size.SetHeight(height);&lt;BR /&gt;origin.SetX(0);&lt;BR /&gt;origin.SetY(0);&lt;BR /&gt;refGrid.SetOrigin(origin);&lt;BR /&gt;refGrid.SetSize(size);&lt;BR /&gt;geo.SetRefGridRect(refGrid);&lt;BR /&gt;geo.ReAlloc(numChannels);&lt;BR /&gt;dataOrder.ReAlloc(UIC::ImageComponentOrder::Interleaved, numChannels);&lt;BR /&gt;dataOrder.PixelStep()[0] = numChannels;&lt;BR /&gt;dataOrder.LineStep()[0] = step;&lt;BR /&gt;status = imgCn.ColorSpec().ReAlloc(numChannels);&lt;BR /&gt;imgCn.ColorSpec().SetColorSpecMethod(Enumerated);&lt;BR /&gt;imgCn.ColorSpec().SetComponentToColorMap(Direct);&lt;/P&gt;
&lt;P&gt;for(int i = 0; i &amp;lt; numChannels; i++)&lt;BR /&gt;{&lt;BR /&gt;imgCn.ColorSpec().DataRange()&lt;I&gt;.SetAsRange8u(255);&lt;BR /&gt;}&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;imgCn.ColorSpec().SetEnumColorSpace(UIC::ImageEnumColorSpace::RGB);&lt;/P&gt;
&lt;P&gt;dataPtr.p8u = input;&lt;BR /&gt;status = imgCn.Buffer().Attach(&amp;amp;dataPtr, dataOrder, geo);&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;status = encoder.AttachImage(imgCn);&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;status = encoder.SetParams(JMODE::JPEG_BASELINE, JCOLOR::JC_RGB, JSS::JS_444, 0, 0, 75);&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;status = encoder.WriteHeader();&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;status = encoder.WriteData();&lt;BR /&gt;if(status == ExcStatusFail)&lt;BR /&gt;{&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;BR /&gt;[/cpp]&lt;/P&gt;
&lt;P&gt;When output is CMemBuffOutput, the values in output are always the same, even when the input data (the camera captured image) has changed. For instance if i cover the camera (total black) the input data values reflect this but output values don't change.&lt;/P&gt;
&lt;P&gt;Any idea what i'm doing wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2013 08:52:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Jpeg-encoder-problem-with-CMemBuffOutput/m-p/957438#M19243</guid>
      <dc:creator>cks2k2</dc:creator>
      <dc:date>2013-10-16T08:52:14Z</dc:date>
    </item>
    <item>
      <title>Hello,</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Jpeg-encoder-problem-with-CMemBuffOutput/m-p/957439#M19244</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;It is not easy to catch some error from the code piece. You may possiblly debug into the following function, see find why the write is actually not happenning.&lt;/P&gt;
&lt;P&gt;JERRCODE CMemBuffOutput::Write(void* buf,uic_size_t len,uic_size_t* cnt) {....}&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Chao&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2013 06:52:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Jpeg-encoder-problem-with-CMemBuffOutput/m-p/957439#M19244</guid>
      <dc:creator>Chao_Y_Intel</dc:creator>
      <dc:date>2013-10-18T06:52:42Z</dc:date>
    </item>
    <item>
      <title>I am also facing the same</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Jpeg-encoder-problem-with-CMemBuffOutput/m-p/957440#M19245</link>
      <description>&lt;P&gt;I am also facing the same issue.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;did you found the solution for it?. If so could you please share it.&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Sathish&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jan 2015 06:06:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Jpeg-encoder-problem-with-CMemBuffOutput/m-p/957440#M19245</guid>
      <dc:creator>Sathish_S_</dc:creator>
      <dc:date>2015-01-19T06:06:18Z</dc:date>
    </item>
  </channel>
</rss>

