diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/v4l.cc | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -97,11 +97,11 @@ static void process_image(const void *p, int size) fprintf(stderr, "[%d]", size); fflush(stdout); - FILE *fp = fopen("out.data", "w"); + FILE *fp = fopen("out.jpg", "w"); fwrite(p, size, 1, fp); fclose(fp); exit(0); - */ + */ } static int read_frame(void) @@ -515,8 +515,8 @@ static void init_device(void) if (true || force_format) { fmt.fmt.pix.width = 640; fmt.fmt.pix.height = 480; - fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32; - // fmt.fmt.pix.field = V4L2_FIELD_NONE; + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_JPEG; + // fmt.fmt.pix.field = V4L2_FIELD_NONE; if (-1 == xioctl(fd, VIDIOC_S_FMT, &fmt)) errno_exit("VIDIOC_S_FMT"); @@ -726,11 +726,8 @@ void V4L::run() void V4L::processImage(const void *p, int size) { - int width = 640; - int height = 480; - printf("processImage(%d, should be %d)\n", size, width * height * 4); - uchar *i = (uchar *)malloc(size); - memcpy(i, p, size); - QImage img(i, width, height, QImage::Format_RGB32); - emit newImage(img); + QImage img; + bool res = img.loadFromData((const uchar *)p, size, "JPG"); + printf("processImage() => %s\n", res?"true":"false"); + if(res) emit newImage(img); } |