06-11-2026 07:15 AM
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.
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:
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), &evfMode); EdsSetPropertyData(selected_cam, kEdsPropID_Evf_OutputDevice, 0, sizeof(outDev), &outDev); EdsCreateMemoryStream(0, &evfStream); EdsCreateEvfImageRef(evfStream, &evfImage); QThread::usleep(1000 * 750); EdsGetLength(evfStream, &stream_length); qDebug() << "length" << stream_length; EdsDownloadEvfImage(selected_cam, evfImage); EdsGetLength(evfStream, &stream_length); qDebug() << "length" << stream_length; image_data = new uchar[stream_length]; EdsGetPointer(evfStream, (EdsVoid**) image_data); qimg.loadFromData(image_data, stream_length, "JPG"); qDebug() << "download ok" << qimg.format();
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 download ok QImage::Format_Invalid.
Here's the Python version, which works quite nicely:
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)
(If I do the C++ version using CreateMemoryStreamFromPointer as in the Python version, I get a bunch of "bogus DQT" messages from loadFromData.)
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.
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.
Solved! Go to Solution.
06-11-2026 09:07 AM
@adibabu Welcome to Canon.
For development, programming and SDK questions, you should visit the Canon Developers Community.
Canon Developer Community https://share.google/CW8A1Ji8nphOzf7eq
~Rick
Bay Area - CA
~R5 C (1.1.2.1), ~R50v (1.2.0) ~RF Trinity, ~RF 100 Macro, ~RF 100~400, ~RF 100~500, ~RF 200-800 +RF 1.4x TC, BG-R10, 430EX III-RT ~DxO PhotoLab Elite ~DaVinci Resolve Studio ~ImageClass MF644Cdw/MF656Cdw ~Pixel 10 ~CarePaks Are Worth It
06-11-2026 09:07 AM
@adibabu Welcome to Canon.
For development, programming and SDK questions, you should visit the Canon Developers Community.
Canon Developer Community https://share.google/CW8A1Ji8nphOzf7eq
~Rick
Bay Area - CA
~R5 C (1.1.2.1), ~R50v (1.2.0) ~RF Trinity, ~RF 100 Macro, ~RF 100~400, ~RF 100~500, ~RF 200-800 +RF 1.4x TC, BG-R10, 430EX III-RT ~DxO PhotoLab Elite ~DaVinci Resolve Studio ~ImageClass MF644Cdw/MF656Cdw ~Pixel 10 ~CarePaks Are Worth It
05/13/2026: New firmware updates are available.
EOS R5 Mark II - Version 1.3.0
EOS R6 Mark II - Version 1.7.0
03/17/2026: New firmware updates are available.
SELPHY CP1500 - Version 1.0.7.0
01/20/2026: New firmware updates are available.
10/15/2025: New firmware updates are available.
Speedlite EL-5 - Version 1.2.0
Speedlite EL-1 - Version 1.1.0
Speedlite Transmitter ST-E10 - Version 1.2.0
Canon U.S.A Inc. All Rights Reserved. Reproduction in whole or part without permission is prohibited.