Skip to content

Commit

Permalink
Add '-tuningfile' parameter to set the tuning file path
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-ard authored and ArduCAM committed May 17, 2024
1 parent 888dc3d commit 99097c8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion mjpg-streamer-experimental/plugins/input_libcamera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ Usage
[-gain ]...............: Set gain (integer)
[-afmode]..............: Control to set the mode of the AF (autofocus) algorithm.(manual, auto, continuous)
[-afrange].............: Set the range of focus distances that is scanned.(normal, macro, full)
[-lensposition]........: Set the lens to a particular focus position, expressed as a reciprocal distance (0 moves the lens to infinity), or "default" for the hyperfocal distance ---------------------------------------------------------------
[-lensposition]........: Set the lens to a particular focus position, expressed as a reciprocal distance (0 moves the lens to infinity), or "default" for the hyperfocal distance
[-tuningfile]..........: Name of camera tuning file to use, omit this option for libcamera default behaviour
---------------------------------------------------------------
```

Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ typedef struct {
lensposition_set, lensposition,
camera_set, camera,
rotation_set, rotation;
char tuningfile[100];
} context_settings;

typedef struct {
Expand Down Expand Up @@ -114,7 +115,8 @@ static void help() {
" [-gain ]...............: Set gain (integer)\n"
" [-afmode]..............: Control to set the mode of the AF (autofocus) algorithm.(manual, auto, continuous)\n"
" [-afrange].............: Set the range of focus distances that is scanned.(normal, macro, full)\n"
" [-lensposition]........: Set the lens to a particular focus position, expressed as a reciprocal distance (0 moves the lens to infinity), or \"default\" for the hyperfocal distance"
" [-lensposition]........: Set the lens to a particular focus position, expressed as a reciprocal distance (0 moves the lens to infinity), or \"default\" for the hyperfocal distance\n"
" [-tuningfile]..........: Name of camera tuning file to use, omit this option for libcamera default behaviour\n"
" ---------------------------------------------------------------\n\n"\
);
}
Expand All @@ -127,7 +129,7 @@ static context_settings* init_settings() {
IPRINT("error allocating context");
exit(EXIT_FAILURE);
}

settings->quality = 80;
return settings;
}
Expand Down Expand Up @@ -207,6 +209,7 @@ int input_init(input_parameter *param, int plugin_no)
{"lensposition", required_argument, 0, 0}, // 19
{"camera", required_argument, 0, 0}, // 20
{"rotation", required_argument, 0, 0}, // 21
{"tuningfile", required_argument, 0, 0}, // 22
{0, 0, 0, 0}
};

Expand Down Expand Up @@ -273,13 +276,18 @@ int input_init(input_parameter *param, int plugin_no)
break;
OPTION_INT(21, rotation)
break;
OPTION_STRING(22, tuningfile)
break;
default:
help();
return 1;
}
}

IPRINT("Desired Resolution: %i x %i\n", width, height);
IPRINT("tuning file path: %s\n", settings->tuningfile);
if (settings->tuningfile != "")
setenv("LIBCAMERA_RPI_TUNING_FILE", settings->tuningfile, 1);

if (!settings->buffercount) {
settings->buffercount = 4;
Expand Down
8 changes: 8 additions & 0 deletions mjpg-streamer-experimental/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ void daemon_mode(void);
} \
settings->v##_set = 1;

#define OPTION_STRING(idx, v) \
case idx: \
DBG("case " #idx); \
if (sscanf(optarg, "%s", &settings->v) != 1) { \
fprintf(stderr, "Invalid value '%s' for -" #v " (string required)\n", optarg); \
exit(EXIT_FAILURE); \
}

/* 1 is true, 0 is false */
#define OPTION_BOOL(idx, v) \
case idx: \
Expand Down

0 comments on commit 99097c8

Please sign in to comment.