[video_capture] recovered saving of exif information (#1914)

* [video_capture] recovered saving of exif information

* [video_capture] added exif define to docs

* [video_capture] updated documentation of video_exif usage
This commit is contained in:
Wilco Schoneveld
2016-11-02 13:22:27 +01:00
committed by Felix Ruess
parent 56a2eb21e0
commit 201649dffa
2 changed files with 20 additions and 6 deletions
+5 -1
View File
@@ -3,11 +3,15 @@
<module name="video_capture" dir="computer_vision">
<doc>
<description>
Capture images from video device on the internal memory (JPEG, full size, best quality)
Capture images from video device on the internal memory (JPEG, full size, best quality). Images can be saved by
pressing the strip button, using the GCS settings panel or with the 'video_capture_shoot' function.
Additional data (GPS location) can be included in the Exif header by including the video_exif module.
</description>
<define name="VIDEO_CAPTURE_CAMERA" value="front_camera|bottom_camera" description="Video device to use"/>
<define name="VIDEO_CAPTURE_PATH" value="/data/video/images" description="Location to save images"/>
<define name="VIDEO_CAPTURE_JPEG_QUALITY" value="99" description="JPEG quality of images"/>
</doc>
<settings>
@@ -32,6 +32,12 @@
#include "lib/encoding/jpeg.h"
// Note: this define is set automatically when the video_exif module is included,
// and exposes functions to write data in the image exif headers.
#if JPEG_WITH_EXIF_HEADER
#include "lib/exif/exif_module.h"
#endif
#ifndef VIDEO_CAPTURE_PATH
#define VIDEO_CAPTURE_PATH /data/video/images
#endif
@@ -101,6 +107,14 @@ void video_capture_save(struct image_t *img)
printf("[video_capture] Saving image to %s.\n", save_name);
// Create jpg image from raw frame
struct image_t img_jpeg;
image_create(&img_jpeg, img->w, img->h, IMAGE_JPEG);
jpeg_encode_image(img, &img_jpeg, VIDEO_CAPTURE_JPEG_QUALITY, true);
#if JPEG_WITH_EXIF_HEADER
write_exif_jpeg(save_name, img_jpeg.buf, img_jpeg.buf_size, img_jpeg.w, img_jpeg.h);
#else
// Open file
FILE *fp = fopen(save_name, "w");
if (fp == NULL) {
@@ -108,14 +122,10 @@ void video_capture_save(struct image_t *img)
break;
}
// Create jpg image from raw frame
struct image_t img_jpeg;
image_create(&img_jpeg, img->w, img->h, IMAGE_JPEG);
jpeg_encode_image(img, &img_jpeg, VIDEO_CAPTURE_JPEG_QUALITY, true);
// Save it to the file and close it
fwrite(img_jpeg.buf, sizeof(uint8_t), img_jpeg.buf_size, fp);
fclose(fp);
#endif
// Free image
image_free(&img_jpeg);