random patchys...

This commit is contained in:
tonton Th
2020-04-02 14:49:10 +02:00
parent 14256b1476
commit dd9ac7c948
12 changed files with 100 additions and 18 deletions

32
v4l2/README.md Normal file
View File

@@ -0,0 +1,32 @@
# Images en virgule flottante, video 4 linux
## grabvidseq
```
tth@lubitel:~/Devel/FloatImg/v4l2$ ./grabvidseq -h
options :
-d /dev/? select video device
-g convert to gray
-n NNN how many frames ?
-O ./ set Output dir
-o bla.xxx set output filename
-p NN.N period in seconds
-r 90 rotate picture
-s WxH size of capture
-c mode contrast enhancement
-u try upscaling...
-v increase verbosity
```
## video-infos
```
Options :
-e N examine that, please
-d select the video device
-K set the K parameter
-l list video devices
-T bla add a title
-v increase verbosity
```

View File

@@ -2,10 +2,6 @@
capture video
-------------
------------------------------------------------------------------------
<paulk-leonov> tth: en faisant de la revue de patch sur V4L2, j'apprends
@@ -13,3 +9,5 @@
le premier concerne le champ flags de la structure de l'ioctl enum_fmt
et le second le champ flag de la structure de g_fmt.
------------------------------------------------------------------------

12
v4l2/essai.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
# -----------------------------------------------------
TMPF="tmp.fimg"
CAM="/dev/video0"
# -----------------------------------------------------
./grabvidseq -d $CAM -n 10000 -vv -p 0 -r 90
# -----------------------------------------------------

View File

@@ -100,27 +100,28 @@ int r, fd = -1;
unsigned int i, n_buffers;
char *dev_name = "/dev/video0";
FILE *fout;
// XXX FILE *fout;
struct buffer *buffers;
int foo, bar;
double period = 10.0; /* delai entre les captures */
int nbre_capt = 1; /* nombre de captures */
int foo;
double period = 10.0; /* delai entre les captures */
int nbre_capt = 1; /* nombre de captures */
int opt;
int width = 640;
int height = 480;
double t_final, maxvalue;
int to_gray = 0;
int upscaling = 0;
int contrast = 0;
char *dest_dir = "."; /* no trailing slash */
int contrast = CONTRAST_NONE;
int rotfactor = 0; /* only 0 or 90 here */
char *dest_dir = "."; /* no trailing slash */
char *outfile = "out.pnm";
#if SAVE_AS_CUMUL
FloatImg cumul;
FloatImg cumul, tmpfimg, *to_save;
#endif
while ((opt = getopt(argc, argv, "c:d:ghn:o:O:p:s:uv")) != -1) {
while ((opt = getopt(argc, argv, "c:d:ghn:o:O:p:r:s:uv")) != -1) {
switch(opt) {
case 'c': contrast = fimg_id_contraste(optarg);
if (contrast < 0) {
@@ -143,10 +144,15 @@ while ((opt = getopt(argc, argv, "c:d:ghn:o:O:p:s:uv")) != -1) {
}
period *= 1e6;
break;
case 'r': rotfactor = atoi(optarg); break;
case 's': parse_WxH(optarg, &width, &height);
break;
case 'u': upscaling = 1; break;
case 'v': verbosity++; break;
default:
fprintf(stderr, "option '%c' is wtf\n", opt);
exit(1);
}
}
@@ -155,6 +161,7 @@ if (verbosity > 1) {
fprintf(stderr, "grabing %d picz\n", nbre_capt);
fprintf(stderr, "period is %.3f milliseconds\n", period/1e3);
fprintf(stderr, "framesize is %dx%d\n", width, height);
fprintf(stderr, "destdir is '%s'\n", dest_dir);
if (upscaling) fprintf(stderr, "upscaling is on\n");
}
@@ -233,6 +240,8 @@ else {
fimg_clear(&cumul);
cumul.fval = 255.0;
cumul.count = 0;
to_save = &cumul;
#endif
@@ -327,6 +336,7 @@ if (to_gray) {
foo = fimg_to_gray(&cumul);
}
#if SAVE_AS_CUMUL
// save cumul to file
if (verbosity) fprintf(stderr, "saving cumul to '%s'\n", outfile);
@@ -357,6 +367,18 @@ switch (contrast) {
break;
}
/* XXX warning, new from coronahome 26 mars 2020 */
if (90 == rotfactor) {
memset(&tmpfimg, 0, sizeof(FloatImg));
foo = fimg_rotate_90(&cumul, &tmpfimg, 0);
if (verbosity > 1) {
fprintf(stderr, "dump rot90 %p\n", &tmpfimg);
foo = fimg_save_as_png(&tmpfimg, "rot90.png", 0);
}
to_save = &tmpfimg;
}
foo = format_from_extension(outfile);
switch (foo) {
case FILE_TYPE_FIMG:
@@ -373,6 +395,9 @@ switch (foo) {
break;
}
// free buffers
fimg_destroy(&cumul);
#endif

View File

@@ -16,7 +16,7 @@ char *str_ctrl_type(int type);
char *str_buf_type(int type);
char *str_fourcc(uint32_t fcc); /* NOT REENTRANT */
void pr_ctrl_id(uint32_t id);
void pr_ctrl_id(uint32_t id); /* bit dissector */
/* --------------------------------------------------------------------- */