diff --git a/.gitignore b/.gitignore index ccdc97c..1709557 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ v4l2/capture v4l2/grabvidseq v4l2/*.o v4l2/*.ppm +v4l2/*.png v4l2/video-infos v4l2/nc-camcontrol diff --git a/doc/the_floatimg_hack.tex b/doc/the_floatimg_hack.tex index 25a6ed9..63a12c7 100644 --- a/doc/the_floatimg_hack.tex +++ b/doc/the_floatimg_hack.tex @@ -233,8 +233,8 @@ par défaut du make. Pour le moment, la procédure d'installation est un peu rude, pour ne pas dire clairement sommaire. Si le résultat de l'étape compilation vous semble correct, -vous pouvez copier les deux fichiers \texttt{floatimg.h} et \texttt{libfloatimg.a} -dans un emplacement approprié, par exemple +vous pouvez copier les deux fichiers \texttt{floatimg.h} et +\texttt{libfloatimg.a} dans un emplacement approprié, par exemple \texttt{/usr/local/include} et \texttt{/usr/local/lib}. Le script \texttt{install.sh}, à la racine du projet, est censé @@ -353,6 +353,14 @@ documentés dans ce document, et les autres sont dangereux à toucher. Les types d'images actuellement gérés sont les trois grands classiques : gray, rgb et rgba. et expliquées quelques lignes plus haut. +Comme vous allez le voir plus loin, il y a plein de fonctions qui +prennent en argument deux images: une source et une destination. + +\begin{lstlisting} +int fimg_images_compatible(FloatImg *a, FloatImg *b); +\end{lstlisting} + + C'est bien beau d'être enfin résident en mémoire centrale, mais pouvoir aussi exister à long terme en étant stocké dans la matrice est tout aussi pertinent. Il y a deux opérations qui supportent le diff --git a/floatimg.h b/floatimg.h index 91ed52f..b6bdfda 100644 --- a/floatimg.h +++ b/floatimg.h @@ -2,7 +2,7 @@ * floatimg.h */ -#define FIMG_VERSION 97 +#define FIMG_VERSION 98 /* * in memory descriptor diff --git a/install.sh b/install.sh index ca6cd2b..18b61bf 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -v cp libfloatimg.a /usr/local/lib cp floatimg.h /usr/local/include diff --git a/lib/fimg-2gray.c b/lib/fimg-2gray.c index 05c3822..02f66d6 100644 --- a/lib/fimg-2gray.c +++ b/lib/fimg-2gray.c @@ -13,7 +13,7 @@ extern int verbosity; /* must be declared around main() */ /* --------------------------------------------------------------------- */ /* - * floating imgs MUST be allocated before calling this func. + * floating resultat img MUST be allocated before calling this func. */ int fimg_mk_gray_from(FloatImg *src, FloatImg *dst, int k) { diff --git a/lib/fimg-compare.c b/lib/fimg-compare.c index e89e234..8576e38 100644 --- a/lib/fimg-compare.c +++ b/lib/fimg-compare.c @@ -13,6 +13,9 @@ extern int verbosity; /* must be declared around main() */ /* ---------------------------------------------------------------- */ +/* + * return 0 if images are compatibles + */ int fimg_images_compatible(FloatImg *a, FloatImg *b) { #if DEBUG_LEVEL > 1 diff --git a/tools/fimg2pnm.c b/tools/fimg2pnm.c index 0bfb480..a8a393b 100644 --- a/tools/fimg2pnm.c +++ b/tools/fimg2pnm.c @@ -77,6 +77,9 @@ if (flag) { } puts("usage :"); puts("\tfimg2pnm [flags] infile.fimg outfile.pnm"); +puts("flags :"); +puts("\t-g\tconvert to gray"); +puts("\t-v\tenhance your verbosity"); } /* --------------------------------------------------------------------- */ int main(int argc, char *argv[]) diff --git a/v4l2/README.md b/v4l2/README.md new file mode 100644 index 0000000..21d28dd --- /dev/null +++ b/v4l2/README.md @@ -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 +``` + diff --git a/v4l2/README.txt b/v4l2/README.txt index e502c14..05b9326 100644 --- a/v4l2/README.txt +++ b/v4l2/README.txt @@ -2,10 +2,6 @@ capture video ------------- - - - - ------------------------------------------------------------------------ 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. +------------------------------------------------------------------------ + diff --git a/v4l2/essai.sh b/v4l2/essai.sh new file mode 100755 index 0000000..9a824b5 --- /dev/null +++ b/v4l2/essai.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# ----------------------------------------------------- + +TMPF="tmp.fimg" +CAM="/dev/video0" + +# ----------------------------------------------------- + +./grabvidseq -d $CAM -n 10000 -vv -p 0 -r 90 + +# ----------------------------------------------------- diff --git a/v4l2/grabvidseq.c b/v4l2/grabvidseq.c index 2936551..724905a 100644 --- a/v4l2/grabvidseq.c +++ b/v4l2/grabvidseq.c @@ -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 diff --git a/v4l2/v4l2_pr_structs.h b/v4l2/v4l2_pr_structs.h index 320ec25..862fc34 100644 --- a/v4l2/v4l2_pr_structs.h +++ b/v4l2/v4l2_pr_structs.h @@ -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 */ /* --------------------------------------------------------------------- */