There are two functions that they don't tell you about:
1) EdsGetPointer
2) EdsGetLength
This will give you a pointer to the beginning of the JPEG stream and the size respectively.
Once you have this use LibJPEG Turbo
to decompress, Libjpeg
just isn't fast enough.
Once you decompress, you can show the image using opencv
.
bool CanonCamera::downloadLiveViewImage()
{
EdsError err = EDS_ERR_OK;
EdsEvfImageRef image = NULL;
EdsStreamRef stream = NULL;
unsigned char* data = NULL;
unsigned long size = 0;
err = EdsCreateMemoryStream(0, &stream);
if (err != EDS_ERR_OK) {
cout << "Download Live View Image Error in Function EdsCreateMemoryStream: " << err << "\n";
return false;
}
err = EdsCreateEvfImageRef(stream, &image);
if (err != EDS_ERR_OK) {
cout << "Download Live View Image Error in Function EdsCreateEvfImageRef: " << err << "\n";
return false;
}
err = EdsDownloadEvfImage(cameraRef, image);
if (err != EDS_ERR_OK) {
cout << "Download Live View Image Error in Function EdsDownloadEvfImage: " << err << "\n";
return false;
}
err = EdsGetPointer(stream, (EdsVoid**)& data);
if (err != EDS_ERR_OK) {
cout << "Download Live View Image Error in Function EdsGetPointer: " << err << "\n";
return false;
}
err = EdsGetLength(stream, &size);
if (err != EDS_ERR_OK) {
cout << "Download Live View Image Error in Function EdsGetLength: " << err << "\n";
return false;
}
// libjpegTurbo(data, size);
// display RGB image in opencv
if (stream != NULL) {
EdsRelease(stream);
stream = NULL;
}
if (image != NULL) {
EdsRelease(image);
image = NULL;
}
data = NULL;
return true;
}