ARCONTROLLER_Frame_t to OpenCV Mat


#1

Product: Bebop
Product version: Software version v2.0.29
SDK version: ARSDK3_version_3_14_0
Use of libARController: Yes
SDK platform: UNIX
Reproductible with the official app: NO

I have been trying to convert an ARCONTROLLER_Frame_t to a cv::Mat using Unix and OpenCV 3.3.0 on C++, I have currently managed to get the frame on OpenCV, the problem I have is that I am not decoding its data correctly, I used the BebopSample program as my base, removed the MPlayer and IHN interfaces, made an ARCONTROLLER_Frame_t buffer to be sent to the C++ code.

I currently get the following image:

I previously used this to try to decode it, assuming it was on an RGB format, this image reacts to interaction with the camera, so I assume it is the correct dataa:

void rawToMat(Mat &destImage, ARCONTROLLER_Frame_t &sourceImage) {
  if (sourceImage.used == 0) {
    return;
  }
  uchar *pointerImage = destImage.ptr(0);

  for (int i = 0; i < 480 * 856; i++) {
    pointerImage[3 * i] = sourceImage.data[3 * i + 2];
    pointerImage[3 * i + 1] = sourceImage.data[3 * i + 1];
    pointerImage[3 * i + 2] = sourceImage.data[3 * i];
  }
}

But I found out this provided the same output:

ARCONTROLLER_Frame_t newFrame = getCurrentFrame();
Mat currentImage = Mat(480, 856, CV_8UC3, newFrame.data);

Does someone know a way to get an actual image from this?