2

I am using the ThermoVision SDK in Qt to communicate with a FLIR A320 IR Camera. The ThermoVision SDK is ActiveX based. I am having trouble retrieving an image from the camera with the GetImage method, which according to the manual can be used in the following way:

Image = Object.GetImage(imageType)

Image is of type VARIANT and contains either a 2-dimensional array with image pixels or an error code (short). imageType determines the type of the pixels (16-bit unsigned integers, single-precision floats or 8-bit unsigned integers).

I am working in Qt so I created a wrapper for the ActiveX component by means of dumpcpp.exe. Unfortunately the GetImage method now returns a QVariant rather than a VARIANT:

inline QVariant LVCam::GetImage(int imageType)
{
    QVariant qax_result;
    void *_a[] = {(void*)&qax_result, (void*)&imageType};
    qt_metacall(QMetaObject::InvokeMetaMethod, 46, _a);
    return qax_result;
}

I call the GetImage method as follows:

QVariant vaIm = m_ircam->GetImage(20 + 3);

How can I access the pixels in the QVariant, e.g. by converting it to a two-dimensional array of floats? I tried using methods like QVariant::toFloat(), QVariant::toByteArray(), QVariant::toList(), but none of them seemed to return the image data.

Any help will be appreciated.

Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
Fré
  • 21
  • 1
  • Hi, have you tryed to do a simple qDebug() << vaIm, just to check how the QVariant is organized? I mean: a QVariant can "contain" quite every kind of cointainer, so I would start by "inpsecting" it. – pragmanomos Sep 26 '14 at 10:11

1 Answers1

0

The function returns a memory address, you will need get the values from memory, so will need to know the exact size of the image.

Try this:

auto width = m_ircam->GetCameraProperty(66).toInt();
auto height = m_ircam->GetCameraProperty(67).toInt();

auto hMem = reinterpret_cast<HGLOBAL>(m_ircam->GetImage(20 + 3).toInt());
auto pSrc = reinterpret_cast<float*>(GlobalLock(hMem));

for(auto i = 0; i < width; ++i)
{
   for(auto j = 0; j < height; ++j)
   {
       arr[i][j] = pSrc[j * width + i]; //Assuming arr is a float[][]
   }
}

GlobalUnlock(hMem);
Caio Belfort
  • 535
  • 2
  • 10