Compare commits

...

2 Commits

Author SHA1 Message Date
tth
85c6e943f3 version UDAMA 2019-10-30 20:09:32 +01:00
tth
cf70ca6b81 parsing filename for filetype 2019-10-30 15:49:53 +01:00
5 changed files with 100 additions and 10 deletions

View File

@ -406,6 +406,9 @@ do
done done
\end{verbatim} \end{verbatim}
En fait, je n'ai pas la moindre idée de ce que peut bien
faire ce code\dots
% ------------------------------------------------------------------- % -------------------------------------------------------------------
\section{Video for Linux}\index{v4l2} \section{Video for Linux}\index{v4l2}
@ -433,15 +436,41 @@ options :
-n NNN how many frames ? -n NNN how many frames ?
-O ./ set Output dir -O ./ set Output dir
-o bla set output filename -o bla set output filename
-p NN.N period in seconds -p NN.N delay between frames
-s WxH size of capture -s WxH size of capture
-u try upscaling... -u try upscaling...
-v increase verbosity -v increase verbosity
\end{verbatim} \end{verbatim}
La plupart de ces options ont un usage quasi-évidents.
L'option \texttt{-s} doit correspondre à une des
résolutions possible de votre capteur.
\subsubsection{Upscaling}\index{upscaling}\label{upscaling}
La fonction que j'ai appelée \textsl{upscaling} est un petit
hack qui permet de doubler artificiellement la résolution
de l'image, en profitant du fait que l'on est capable
de prendre $N$ images en rafale.
Pour être rigoureux dans la prise de vue, ce $N$ doit
être un multiple de 4.
\subsection{video-infos}\index{video-infos}\label{video-infos} \subsection{video-infos}\index{video-infos}\label{video-infos}
Que contient, que peut faire mon périphérique \textsl{àlc} ? Que contient, que peut faire mon périphérique \textsl{àlc} ?
Quelles sont ses possibilités de réglage ?
\begin{verbatim}
tth@debian:~/Devel/FloatImg$ v4l2/video-infos -h
Options :
-d select the video device
-K set the K parameter
-l list video devices
-T bla add a title
-v increase verbosity
\end{verbatim}
% ------------------------------------------------------------------- % -------------------------------------------------------------------
\section{Et pour la suite ?} \section{Et pour la suite ?}

View File

@ -32,6 +32,10 @@ typedef struct {
#define FIMG_TYPE_RGB 3 #define FIMG_TYPE_RGB 3
#define FIMG_TYPE_RGBA 4 #define FIMG_TYPE_RGBA 4
#define FILE_TYPE_FIMG 1
#define FILE_TYPE_PNM 2
#define FILE_TYPE_PNG 3
/* /*
* core module * core module
*/ */
@ -91,6 +95,8 @@ int fimg_draw_something(FloatImg *fimg);
int parse_WxH(char *str, int *pw, int *ph); int parse_WxH(char *str, int *pw, int *ph);
int parse_double(char *str, double *dptr); int parse_double(char *str, double *dptr);
int format_from_extension(char *fname);

View File

@ -9,7 +9,7 @@
#include "../floatimg.h" #include "../floatimg.h"
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int main(int argc, char *argv[]) int essai_parse_double(void)
{ {
int foo; int foo;
double dval; double dval;
@ -34,3 +34,29 @@ printf("%-10s -> %3d %g\n", str, foo, dval);
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int essai_detect_type(void)
{
int foo;
char *fname;
foo = format_from_extension(fname="foo.fimg");
printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.pNm");
printf("%-10s %d\n\n", fname, foo);
foo = format_from_extension(fname="foo.xyzzy");
printf("%-10s %d\n\n", fname, foo);
return 0;
}
/* --------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
foo = essai_detect_type();
return 0;
}
/* --------------------------------------------------------------------- */

View File

@ -1,7 +1,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -42,3 +42,24 @@ if (1 == foo) {
return -1; return -1;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int format_from_extension(char *fname)
{
char *cptr;
cptr = rindex(fname, '.');
if (NULL==cptr) {
fprintf(stderr, "do dot in %s\n", fname);
return -1;
}
#if DEBUG_LEVEL
fprintf(stderr, "[%s] --> [%s]\n", fname, cptr);
#endif
if (!strcasecmp(cptr, ".pnm")) return FILE_TYPE_PNM;
if (!strcasecmp(cptr, ".fimg")) return FILE_TYPE_FIMG;
if (!strcasecmp(cptr, ".png")) return FILE_TYPE_PNG;
return -1;
}
/* --------------------------------------------------------------------- */

View File

@ -301,22 +301,30 @@ for (i = 0; i < nbre_capt; i++) {
puts(""); fflush(stdout); puts(""); fflush(stdout);
t_final = fimg_timer_get(0); if (verbosity) {
fprintf(stderr, "pid %d : elapsed %g s -> %.2f fps\n", getpid(), t_final = fimg_timer_get(0);
fprintf(stderr, "pid %d : elapsed %g s -> %.2f fps\n", getpid(),
t_final, (double)nbre_capt / t_final); t_final, (double)nbre_capt / t_final);
}
#if SAVE_AS_CUMUL
if (to_gray) { if (to_gray) {
if (verbosity) fputs("converting to gray\n", stderr); if (verbosity) fputs("converting to gray\n", stderr);
foo = fimg_to_gray(&cumul); foo = fimg_to_gray(&cumul);
} }
#if SAVE_AS_CUMUL
// save cumul to file // save cumul to file
if (verbosity) fprintf(stderr, "saving to '%s'\n", outfile); if (verbosity) fprintf(stderr, "saving cumul to '%s'\n", outfile);
foo = fimg_save_as_pnm(&cumul, outfile, 1);
foo = format_from_extension(outfile);
switch (foo) {
case FILE_TYPE_FIMG:
foo = fimg_dump_to_file(&cumul, outfile, 0);
break;
case FILE_TYPE_PNM:
foo = fimg_save_as_pnm(&cumul, outfile, 1);
break;
}
// free buffers // free buffers
fimg_destroy(&cumul); fimg_destroy(&cumul);
#endif #endif