5

我正在使用设备上的其他人的代码,该设备可以将图像放入/dev/fb/0并显示在视频上,或通过网络将其发送到客户端应用程序。

我无权访问客户端应用程序的旧源,但我知道以下有关数据的信息:

  • 720x480
  • 16 位
  • RGB(我不确定是 5,5,5 还是 5,6,5)
  • RAW(没有任何标题)
  • cat-能够/dev/fb/0
  • 675kb

如何给它一个标题或将其转换为 JPEG、BMP 或 RAW 类型,然后我可以在桌面应用程序中查看?

最终,我希望它是 jpeg 并且可以在浏览器中查看,但是我现在可以用眼睛看到的任何东西都可以使用。

成功

(见下面的评论)

ffmpeg \
  -vcodec rawvideo \
  -f rawvideo \
  -pix_fmt rgb565 \
  -s 720x480 \
  -i in-buffer.raw \
  \
  -f image2 \
  -vcodec mjpeg \
  out-buffer.jpg

失败的尝试

将图像横向显示三倍,几乎没有颜色,并垂直挤压:

rawtoppm -rgb -interpixel 720 480 fb.raw > fb.ppm

显示图像,但有条纹和垂直压扁,颜色不好:

rawtoppm -rgb -interrow 720 480 fb.raw > fb.ppm

与上述类似

convert -depth 16 -size 720x480 frame_buffer.rgb fb.jpeg
4

2 回答 2

5

rgb 到 ppm:调味即可!

维护在https://github.com/coolaj86/image-examples

#include <stdio.h>

int main(int argc, char* argv[]) {

  FILE* infile; // fb.raw
  FILE* outfile; // fb.ppm
  unsigned char red, green, blue; // 8-bits each
  unsigned short pixel; // 16-bits per pixel
  unsigned int maxval; // max color val
  unsigned short width, height;
  size_t i;

  infile = fopen("./fb.raw", "r");
  outfile = fopen("./fb.ppm", "wb");
  width = 720;
  height = 480;
  maxval = 255;

  // P3 - PPM "plain" header
  fprintf(outfile, "P3\n#created with rgb2ppm\n%d %d\n%d\n", width, height, maxval);

  for (i = 0; i < width * height; i += 1) {
      fread(&pixel, sizeof(unsigned short), 1, infile);

      red = (unsigned short)((pixel & 0xF800) >> 11);  // 5
      green = (unsigned short)((pixel & 0x07E0) >> 5); // 6
      blue = (unsigned short)(pixel & 0x001F);         // 5

      // Increase intensity
      red = red << 3;
      green = green << 2;
      blue = blue << 3;

    // P6 binary
    //fwrite(&(red | green | blue), 1, sizeof(unsigned short), outfile);

    // P3 "plain"
    fprintf(outfile, "%d %d %d\n", red, green, blue);
  }
}
于 2010-09-23T20:53:36.790 回答
2

我正在开发一个 5:6:5 RGB 格式的嵌入式系统,有时我需要捕获原始帧缓冲区数据并将其转换为可视图像。为了进行实验,我编写了一些 C 代码来将原始二进制值转换为链接文本。格式很笨,但很容易阅读——因此我发现它很方便破解。然后我使用 Imagemagick显示查看并转换为 JPG。(如果我没记错的话,convert将接受原始二进制图像 - 但假设您知道所有图像参数,即 5:6:5 与 5:5:5)。

如果需要,我可以发布示例 C 代码以将 5:6:5 转换为 8:8:8 RGB。

于 2010-09-23T19:02:11.027 回答