Change burst length depending on gain

The burst_length is now calculated before taking the first picture
by increasing the number of frames when the sensor gain is raised.
This commit is contained in:
Martijn Braam
2022-02-15 17:29:12 +01:00
parent 3c4aaf9fb5
commit 899748df46
2 changed files with 12 additions and 3 deletions

View File

@@ -9,6 +9,7 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <glib.h> #include <glib.h>
#include <math.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
@@ -343,14 +344,22 @@ static void
capture(MPPipeline *pipeline, const void *data) capture(MPPipeline *pipeline, const void *data)
{ {
struct camera_info *info = &cameras[camera->index]; struct camera_info *info = &cameras[camera->index];
uint32_t gain;
captures_remaining = burst_length; float gain_norm;
// Disable the autogain/exposure while taking the burst // Disable the autogain/exposure while taking the burst
mp_camera_control_set_int32(info->camera, V4L2_CID_AUTOGAIN, 0); mp_camera_control_set_int32(info->camera, V4L2_CID_AUTOGAIN, 0);
mp_camera_control_set_int32( mp_camera_control_set_int32(
info->camera, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL); info->camera, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL);
// Get current gain to calculate a burst length;
// with low gain there's 2, with the max automatic gain of the ov5640
// the value seems to be 248 which creates a 5 frame burst
// for manual gain you can go up to 11 frames
gain = mp_camera_control_get_int32(info->camera, V4L2_CID_GAIN);
gain_norm = (float)gain / (float)info->gain_max;
burst_length = (int)(sqrt(gain_norm) * 10) + 1;
// Change camera mode for capturing // Change camera mode for capturing
mp_process_pipeline_sync(); mp_process_pipeline_sync();
mp_camera_stop_capture(info->camera); mp_camera_stop_capture(info->camera);

View File

@@ -65,7 +65,7 @@ static char last_path[260] = "";
static MPZBarScanResult *zbar_result = NULL; static MPZBarScanResult *zbar_result = NULL;
static int burst_length = 3; static int burst_length = 0;
// Widgets // Widgets
GtkWidget *preview; GtkWidget *preview;