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

1
.gitignore vendored
View File

@ -38,6 +38,7 @@ v4l2/capture
v4l2/grabvidseq v4l2/grabvidseq
v4l2/*.o v4l2/*.o
v4l2/*.ppm v4l2/*.ppm
v4l2/*.png
v4l2/video-infos v4l2/video-infos
v4l2/nc-camcontrol v4l2/nc-camcontrol

View File

@ -233,8 +233,8 @@ par défaut du make.
Pour le moment, la procédure d'installation est un peu rude, Pour le moment, la procédure d'installation est un peu rude,
pour ne pas dire clairement sommaire. pour ne pas dire clairement sommaire.
Si le résultat de l'étape compilation vous semble correct, Si le résultat de l'étape compilation vous semble correct,
vous pouvez copier les deux fichiers \texttt{floatimg.h} et \texttt{libfloatimg.a} vous pouvez copier les deux fichiers \texttt{floatimg.h} et
dans un emplacement approprié, par exemple \texttt{libfloatimg.a} dans un emplacement approprié, par exemple
\texttt{/usr/local/include} et \texttt{/usr/local/lib}. \texttt{/usr/local/include} et \texttt{/usr/local/lib}.
Le script \texttt{install.sh}, à la racine du projet, est censé 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 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. 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 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 pouvoir aussi exister à long terme en étant stocké dans la matrice
est tout aussi pertinent. Il y a deux opérations qui supportent le est tout aussi pertinent. Il y a deux opérations qui supportent le

View File

@ -2,7 +2,7 @@
* floatimg.h * floatimg.h
*/ */
#define FIMG_VERSION 97 #define FIMG_VERSION 98
/* /*
* in memory descriptor * in memory descriptor

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash -v
cp libfloatimg.a /usr/local/lib cp libfloatimg.a /usr/local/lib
cp floatimg.h /usr/local/include cp floatimg.h /usr/local/include

View File

@ -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) int fimg_mk_gray_from(FloatImg *src, FloatImg *dst, int k)
{ {

View File

@ -13,6 +13,9 @@
extern int verbosity; /* must be declared around main() */ extern int verbosity; /* must be declared around main() */
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
/*
* return 0 if images are compatibles
*/
int fimg_images_compatible(FloatImg *a, FloatImg *b) int fimg_images_compatible(FloatImg *a, FloatImg *b)
{ {
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1

View File

@ -77,6 +77,9 @@ if (flag) {
} }
puts("usage :"); puts("usage :");
puts("\tfimg2pnm [flags] infile.fimg outfile.pnm"); 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[]) int main(int argc, char *argv[])

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 capture video
------------- -------------
------------------------------------------------------------------------ ------------------------------------------------------------------------
<paulk-leonov> tth: en faisant de la revue de patch sur V4L2, j'apprends <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 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. 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; unsigned int i, n_buffers;
char *dev_name = "/dev/video0"; char *dev_name = "/dev/video0";
FILE *fout; // XXX FILE *fout;
struct buffer *buffers; struct buffer *buffers;
int foo, bar; int foo;
double period = 10.0; /* delai entre les captures */ double period = 10.0; /* delai entre les captures */
int nbre_capt = 1; /* nombre de captures */ int nbre_capt = 1; /* nombre de captures */
int opt; int opt;
int width = 640; int width = 640;
int height = 480; int height = 480;
double t_final, maxvalue; double t_final, maxvalue;
int to_gray = 0; int to_gray = 0;
int upscaling = 0; int upscaling = 0;
int contrast = 0; int contrast = CONTRAST_NONE;
char *dest_dir = "."; /* no trailing slash */ int rotfactor = 0; /* only 0 or 90 here */
char *dest_dir = "."; /* no trailing slash */
char *outfile = "out.pnm"; char *outfile = "out.pnm";
#if SAVE_AS_CUMUL #if SAVE_AS_CUMUL
FloatImg cumul; FloatImg cumul, tmpfimg, *to_save;
#endif #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) { switch(opt) {
case 'c': contrast = fimg_id_contraste(optarg); case 'c': contrast = fimg_id_contraste(optarg);
if (contrast < 0) { if (contrast < 0) {
@ -143,10 +144,15 @@ while ((opt = getopt(argc, argv, "c:d:ghn:o:O:p:s:uv")) != -1) {
} }
period *= 1e6; period *= 1e6;
break; break;
case 'r': rotfactor = atoi(optarg); break;
case 's': parse_WxH(optarg, &width, &height); case 's': parse_WxH(optarg, &width, &height);
break; break;
case 'u': upscaling = 1; break; case 'u': upscaling = 1; break;
case 'v': verbosity++; 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, "grabing %d picz\n", nbre_capt);
fprintf(stderr, "period is %.3f milliseconds\n", period/1e3); fprintf(stderr, "period is %.3f milliseconds\n", period/1e3);
fprintf(stderr, "framesize is %dx%d\n", width, height); 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"); if (upscaling) fprintf(stderr, "upscaling is on\n");
} }
@ -233,6 +240,8 @@ else {
fimg_clear(&cumul); fimg_clear(&cumul);
cumul.fval = 255.0; cumul.fval = 255.0;
cumul.count = 0; cumul.count = 0;
to_save = &cumul;
#endif #endif
@ -327,6 +336,7 @@ if (to_gray) {
foo = fimg_to_gray(&cumul); foo = fimg_to_gray(&cumul);
} }
#if SAVE_AS_CUMUL #if SAVE_AS_CUMUL
// save cumul to file // save cumul to file
if (verbosity) fprintf(stderr, "saving cumul to '%s'\n", outfile); if (verbosity) fprintf(stderr, "saving cumul to '%s'\n", outfile);
@ -357,6 +367,18 @@ switch (contrast) {
break; 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); foo = format_from_extension(outfile);
switch (foo) { switch (foo) {
case FILE_TYPE_FIMG: case FILE_TYPE_FIMG:
@ -373,6 +395,9 @@ switch (foo) {
break; break;
} }
// free buffers // free buffers
fimg_destroy(&cumul); fimg_destroy(&cumul);
#endif #endif

View File

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