<?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 Canon EDSDK decoding Evf Memory Stream data C++ (not working) vs Python (working) in Camera Software</title>
    <link>https://community.usa.canon.com/t5/Camera-Software/Canon-EDSDK-decoding-Evf-Memory-Stream-data-C-not-working-vs/m-p/598716#M25061</link>
    <description>&lt;P&gt;I actually have what I want working in Python with PySide and edsdk-python, however I am trying to get this working in C++ and stumbling on the decoding of the memory stream data.&lt;/P&gt;&lt;P&gt;Here is the relevant code from my C++ project. Please note, the actual code I'm compiling has error checking, and I've checked every return value in practice, and there are no explicit error codes which could be handled to resolve this problem. I simply did not include the error checks here because when I posted this before, it was very apparent that their presence (and occasional irrelevant ommision) was distracting anyone who might care to look from the actual, substantive differences in following code segments:&lt;/P&gt;&lt;PRE&gt;dsStreamRef evfStream;
EdsEvfImageRef evfImage;
uchar * image_data;
QImage qimg;
EdsUInt64 stream_length;
EdsUInt32 evfMode = 1;
EdsUInt32 outDev = 2;

EdsOpenSession(selected_cam);

EdsSetPropertyData(selected_cam, kEdsPropID_Evf_Mode, 0, sizeof(evfMode), &amp;amp;evfMode);
EdsSetPropertyData(selected_cam, kEdsPropID_Evf_OutputDevice, 0, sizeof(outDev), &amp;amp;outDev);

EdsCreateMemoryStream(0, &amp;amp;evfStream);
EdsCreateEvfImageRef(evfStream, &amp;amp;evfImage);

QThread::usleep(1000 * 750);

EdsGetLength(evfStream, &amp;amp;stream_length);
qDebug() &amp;lt;&amp;lt; "length" &amp;lt;&amp;lt; stream_length;

EdsDownloadEvfImage(selected_cam, evfImage);

EdsGetLength(evfStream, &amp;amp;stream_length);
qDebug() &amp;lt;&amp;lt; "length" &amp;lt;&amp;lt; stream_length;

image_data = new uchar[stream_length];
EdsGetPointer(evfStream, (EdsVoid**) image_data);
qimg.loadFromData(image_data, stream_length, "JPG");
qDebug() &amp;lt;&amp;lt; "download ok" &amp;lt;&amp;lt; qimg.format();&lt;/PRE&gt;&lt;P&gt;So, the first print of stream_length is 0, and the second is ~280000, suggesting that the download worked. However, the decode did not, because the last debug statement prints&amp;nbsp;download ok QImage::Format_Invalid.&lt;/P&gt;&lt;P&gt;Here's the Python version, which works quite nicely:&lt;/P&gt;&lt;PRE&gt;qimg = QImage()

edsdk.OpenSession(selected_cam)

edsdk.SetPropertyData(selected_cam, PropID.Evf_Mode, 0, 1)
edsdk.SetPropertyData(selected_cam, PropID.Evf_OutputDevice, 0, 2)

image_data = bytes(960*640*3)
mem_stream = edsdk.CreateMemoryStreamFromPointer(image_data)
evfImage = edsdk.CreateEvfImageRef(mem_stream)

time.sleep(.75)

edsdk.DownloadEvfImage(selected_cam, image)
qimg.loadFromData(image_data, "JPEG")
pixmap = QPixmap.fromImage(qimg)
mainWindow.imageLabel.setPixmap(pixmap)&lt;/PRE&gt;&lt;P&gt;(If I do the C++ version using CreateMemoryStreamFromPointer as in the Python version, I get a bunch of "bogus DQT" messages from loadFromData.)&lt;/P&gt;&lt;P&gt;Once again, you can ignore the error checks. No function is returning anything but ERR_OK in the C++ version, and no exceptions are being raised in Python.&lt;/P&gt;&lt;P&gt;I'm fairly certain the problem is in my handling of the memory stream, or the data pointer, or how it's being presented to QImage.loadFromData.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jun 2026 11:15:19 GMT</pubDate>
    <dc:creator>adibabu</dc:creator>
    <dc:date>2026-06-11T11:15:19Z</dc:date>
    <item>
      <title>Canon EDSDK decoding Evf Memory Stream data C++ (not working) vs Python (working)</title>
      <link>https://community.usa.canon.com/t5/Camera-Software/Canon-EDSDK-decoding-Evf-Memory-Stream-data-C-not-working-vs/m-p/598716#M25061</link>
      <description>&lt;P&gt;I actually have what I want working in Python with PySide and edsdk-python, however I am trying to get this working in C++ and stumbling on the decoding of the memory stream data.&lt;/P&gt;&lt;P&gt;Here is the relevant code from my C++ project. Please note, the actual code I'm compiling has error checking, and I've checked every return value in practice, and there are no explicit error codes which could be handled to resolve this problem. I simply did not include the error checks here because when I posted this before, it was very apparent that their presence (and occasional irrelevant ommision) was distracting anyone who might care to look from the actual, substantive differences in following code segments:&lt;/P&gt;&lt;PRE&gt;dsStreamRef evfStream;
EdsEvfImageRef evfImage;
uchar * image_data;
QImage qimg;
EdsUInt64 stream_length;
EdsUInt32 evfMode = 1;
EdsUInt32 outDev = 2;

EdsOpenSession(selected_cam);

EdsSetPropertyData(selected_cam, kEdsPropID_Evf_Mode, 0, sizeof(evfMode), &amp;amp;evfMode);
EdsSetPropertyData(selected_cam, kEdsPropID_Evf_OutputDevice, 0, sizeof(outDev), &amp;amp;outDev);

EdsCreateMemoryStream(0, &amp;amp;evfStream);
EdsCreateEvfImageRef(evfStream, &amp;amp;evfImage);

QThread::usleep(1000 * 750);

EdsGetLength(evfStream, &amp;amp;stream_length);
qDebug() &amp;lt;&amp;lt; "length" &amp;lt;&amp;lt; stream_length;

EdsDownloadEvfImage(selected_cam, evfImage);

EdsGetLength(evfStream, &amp;amp;stream_length);
qDebug() &amp;lt;&amp;lt; "length" &amp;lt;&amp;lt; stream_length;

image_data = new uchar[stream_length];
EdsGetPointer(evfStream, (EdsVoid**) image_data);
qimg.loadFromData(image_data, stream_length, "JPG");
qDebug() &amp;lt;&amp;lt; "download ok" &amp;lt;&amp;lt; qimg.format();&lt;/PRE&gt;&lt;P&gt;So, the first print of stream_length is 0, and the second is ~280000, suggesting that the download worked. However, the decode did not, because the last debug statement prints&amp;nbsp;download ok QImage::Format_Invalid.&lt;/P&gt;&lt;P&gt;Here's the Python version, which works quite nicely:&lt;/P&gt;&lt;PRE&gt;qimg = QImage()

edsdk.OpenSession(selected_cam)

edsdk.SetPropertyData(selected_cam, PropID.Evf_Mode, 0, 1)
edsdk.SetPropertyData(selected_cam, PropID.Evf_OutputDevice, 0, 2)

image_data = bytes(960*640*3)
mem_stream = edsdk.CreateMemoryStreamFromPointer(image_data)
evfImage = edsdk.CreateEvfImageRef(mem_stream)

time.sleep(.75)

edsdk.DownloadEvfImage(selected_cam, image)
qimg.loadFromData(image_data, "JPEG")
pixmap = QPixmap.fromImage(qimg)
mainWindow.imageLabel.setPixmap(pixmap)&lt;/PRE&gt;&lt;P&gt;(If I do the C++ version using CreateMemoryStreamFromPointer as in the Python version, I get a bunch of "bogus DQT" messages from loadFromData.)&lt;/P&gt;&lt;P&gt;Once again, you can ignore the error checks. No function is returning anything but ERR_OK in the C++ version, and no exceptions are being raised in Python.&lt;/P&gt;&lt;P&gt;I'm fairly certain the problem is in my handling of the memory stream, or the data pointer, or how it's being presented to QImage.loadFromData.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2026 11:15:19 GMT</pubDate>
      <guid>https://community.usa.canon.com/t5/Camera-Software/Canon-EDSDK-decoding-Evf-Memory-Stream-data-C-not-working-vs/m-p/598716#M25061</guid>
      <dc:creator>adibabu</dc:creator>
      <dc:date>2026-06-11T11:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Canon EDSDK decoding Evf Memory Stream data C++ (not working) vs Python (working)</title>
      <link>https://community.usa.canon.com/t5/Camera-Software/Canon-EDSDK-decoding-Evf-Memory-Stream-data-C-not-working-vs/m-p/598724#M25062</link>
      <description>&lt;P&gt;&lt;a href="https://community.usa.canon.com/t5/user/viewprofilepage/user-id/271897"&gt;@adibabu&lt;/a&gt;&amp;nbsp;Welcome to Canon.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For development, programming and SDK questions, you should visit the Canon Developers Community.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Canon Developer Community &lt;A href="https://share.google/CW8A1Ji8nphOzf7eq" target="_blank"&gt;https://share.google/CW8A1Ji8nphOzf7eq&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2026 13:07:31 GMT</pubDate>
      <guid>https://community.usa.canon.com/t5/Camera-Software/Canon-EDSDK-decoding-Evf-Memory-Stream-data-C-not-working-vs/m-p/598724#M25062</guid>
      <dc:creator>shadowsports</dc:creator>
      <dc:date>2026-06-11T13:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Canon EDSDK decoding Evf Memory Stream data C++ (not working) vs Python (working)</title>
      <link>https://community.usa.canon.com/t5/Camera-Software/Canon-EDSDK-decoding-Evf-Memory-Stream-data-C-not-working-vs/m-p/599020#M25071</link>
      <description>&lt;P&gt;@&lt;A href="https://www.jewellok.com/" target="_self"&gt;jewellok&lt;/A&gt; thanks for information, Marked Accept as solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jun 2026 08:37:30 GMT</pubDate>
      <guid>https://community.usa.canon.com/t5/Camera-Software/Canon-EDSDK-decoding-Evf-Memory-Stream-data-C-not-working-vs/m-p/599020#M25071</guid>
      <dc:creator>adibabu</dc:creator>
      <dc:date>2026-06-14T08:37:30Z</dc:date>
    </item>
  </channel>
</rss>

