0

我在通过以下方式传递给TangoService_connectOnFrameAvailable()的回调中复制 YV12 帧:

uint8_t* dest_buffer = destination_tango_image->data;
int src_offset = buffer->stride;
int dest_offset = 0;
// copy Y channel
static const int height = buffer->height;
static const int width = buffer->width;
static const int stride = buffer->stride;
for(int i = 0; i < height; i++) {
  memcpy(dest_buffer + dest_offset, buffer->data + src_offset, width);
  src_offset += stride;
  dest_offset += width;
}
// copy V channel
static const int half_width = width / 2;
static const int half_height = height / 2;
static const int half_stride = stride / 2;
for(int i = 0; i < half_height; i++) {
  memcpy(dest_buffer + dest_offset, buffer->data + src_offset, half_width);
  src_offset += half_stride;
  dest_offset += half_width;
}
// copy U channel
for(int i = 0; i < half_height; i++) {
  memcpy(dest_buffer + dest_offset, buffer->data + src_offset, half_width);
  src_offset += half_stride;
  dest_offset += half_width;
}

完成此操作后,我尝试在vooya中显示 YV12 图像,并转换为 RGBA 后显示它(按照之前的答案)。但是,在这两种情况下,我都在图像的左上角和整个底部看到了一些伪影。这是一个例子:

图像伪影

我如何复制数据有问题吗?或者这是TangoService_connectOnFrameAvailable()的问题?还是平板电脑的摄像头有问题?

4

1 回答 1

0

You did nothing wrong on parsing the image, the artifacts you see here is actually the meta data stored in the image, which is used in the lower stack in the Tango Service.

于 2015-02-09T21:49:40.067 回答