Front camera metadata and auto exposure switch

This commit is contained in:
Martijn Braam 2020-09-27 17:25:31 +02:00
parent cca7e6a823
commit 9cbebee116
5 changed files with 26 additions and 5 deletions

View File

@ -25,3 +25,6 @@ height=600
rate=30
fmt=BGGR8
rotate=90
focallength=2.6
cropfactor=12.7
fnumber=2.8

View File

@ -25,3 +25,6 @@ height=600
rate=30
fmt=BGGR8
rotate=90
focallength=2.6
cropfactor=12.7
fnumber=2.8

View File

@ -25,3 +25,6 @@ height=600
rate=30
fmt=BGGR8
rotate=90
focallength=2.6
cropfactor=12.7
fnumber=2.8

View File

@ -25,3 +25,6 @@ height=600
rate=30
fmt=BGGR8
rotate=90
focallength=2.6
cropfactor=12.7
fnumber=2.8

19
main.c
View File

@ -84,6 +84,8 @@ static cairo_surface_t *surface = NULL;
static int preview_width = -1;
static int preview_height = -1;
static char *last_path = NULL;
static int auto_exposure = 1;
static int auto_gain = 1;
// Widgets
GtkWidget *preview;
@ -265,11 +267,18 @@ init_sensor(char *fn, int width, int height, int mbus, int rate)
fmt.format.width, fmt.format.height,
fmt.format.code);
// Placeholder, default is also 1
//v4l2_ctrl_set(fd, V4L2_CID_AUTOGAIN, 0);
//v4l2_ctrl_set(fd, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL);
//v4l2_ctrl_set(fd, V4L2_CID_EXPOSURE, height/24);
//v4l2_ctrl_set(fd, V4L2_CID_GAIN, 0);
if (auto_exposure) {
v4l2_ctrl_set(fd, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_AUTO);
} else {
v4l2_ctrl_set(fd, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL);
v4l2_ctrl_set(fd, V4L2_CID_EXPOSURE, height/2);
}
if (auto_gain) {
v4l2_ctrl_set(fd, V4L2_CID_AUTOGAIN, 1);
} else {
v4l2_ctrl_set(fd, V4L2_CID_AUTOGAIN, 0);
v4l2_ctrl_set(fd, V4L2_CID_GAIN, 0);
}
close(current.fd);
current.fd = fd;
}