Compare commits
	
		
			No commits in common. "9f42b813e77d6ee086291f11eb2b50c5ec2db2be" and "a5d4e5cc98b8db4a2be6cd3353ae8ee475eb7807" have entirely different histories.
		
	
	
		
			9f42b813e7
			...
			a5d4e5cc98
		
	
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -36,4 +36,3 @@ tools/png2fimg | |||||||
| tools/addtga2fimg | tools/addtga2fimg | ||||||
| tools/addpnm2fimg | tools/addpnm2fimg | ||||||
| tools/cumulfimgs | tools/cumulfimgs | ||||||
| tools/fimgops |  | ||||||
|  | |||||||
| @ -41,11 +41,6 @@ composante, mais c'est loin d'être le cas général. | |||||||
| J'ai donc souhaité aller plus loin, et coder chaque canal de | J'ai donc souhaité aller plus loin, et coder chaque canal de | ||||||
| chaque pixel en virgule flottante sur 32bits, le type | chaque pixel en virgule flottante sur 32bits, le type | ||||||
| \texttt{float}\index{float} du langage C. | \texttt{float}\index{float} du langage C. | ||||||
| \vspace{1em} |  | ||||||
| 
 |  | ||||||
| Attention, tout le code que nous allons voir ensemble est en |  | ||||||
| perpétuelle évolution\footnote{voir page \pageref{TODO}}, |  | ||||||
| et sa fiablité reste à démontrer\index{valgrind}. |  | ||||||
| 
 | 
 | ||||||
| % ------------------------------------------------------------------- | % ------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| @ -55,13 +50,6 @@ et sa fiablité reste à démontrer\index{valgrind}. | |||||||
| % ------------------------------------------------------------------- | % ------------------------------------------------------------------- | ||||||
| \section{Premier example}\index{example}\label{example} | \section{Premier example}\index{example}\label{example} | ||||||
| 
 | 
 | ||||||
| \textsc{FloatImg} a débuté sous la forme de quelques fonctions |  | ||||||
| basiques en C, gérant la structure des données d'image en mémoire |  | ||||||
| et sur disque. |  | ||||||
| Nous allons donc directement rentrer au cœur du problème. |  | ||||||
| 
 |  | ||||||
| \vspace{1em} |  | ||||||
| 
 |  | ||||||
| Pour commencer par quelques chose de simple,  | Pour commencer par quelques chose de simple,  | ||||||
| nous allons créer une image RGB\index{RGB} complètement noire, | nous allons créer une image RGB\index{RGB} complètement noire, | ||||||
| puis l'enregistrer dans un fichier \texttt{.fimg}\index{.fimg}, | puis l'enregistrer dans un fichier \texttt{.fimg}\index{.fimg}, | ||||||
| @ -82,7 +70,7 @@ en mémoire centrale, initialisations des valeurs de pixel à 0.0, | |||||||
| et pour conclure, enregistrement dans un fichier. | et pour conclure, enregistrement dans un fichier. | ||||||
| 
 | 
 | ||||||
| \begin{verbatim} | \begin{verbatim} | ||||||
| foo = fimg_create(&fimg, width, height, FIMG_TYPE_RGB); | foo = fimg_create(&fimg, width, height, 3); | ||||||
| if (foo) { | if (foo) { | ||||||
|         fprintf(stderr, "create floatimg -> %d\n", foo); |         fprintf(stderr, "create floatimg -> %d\n", foo); | ||||||
|         exit(1); |         exit(1); | ||||||
| @ -114,36 +102,24 @@ mean values: | |||||||
| max value     0.000000 | max value     0.000000 | ||||||
| \end{verbatim} | \end{verbatim} | ||||||
| 
 | 
 | ||||||
| Nous avons donc sous la main une mécanique qui ne demande qu'à |  | ||||||
| faire des trucs futiles et des images qui clignotent. |  | ||||||
| La suite vers la page \pageref{codaz}.  |  | ||||||
| 
 |  | ||||||
| \vspace{1em} |  | ||||||
| 
 |  | ||||||
| Vous trouverez dans le répertoire \texttt{tools/}\index{tools/} | Vous trouverez dans le répertoire \texttt{tools/}\index{tools/} | ||||||
| d'autres exemples de mise en œuvre des fonctions disponibles | d'autres exemples de mise en œuvre des fonctions disponibles | ||||||
| sous formes d'outils en ligne de commande, | sous formes d'outils en ligne de commande, décrits page \pageref{outils}. | ||||||
| décrits en page \pageref{outils}. |  | ||||||
| 
 | 
 | ||||||
| % ------------------------------------------------------------------- | % ------------------------------------------------------------------- | ||||||
| \section{Installation} | \section{Installation} | ||||||
| 
 | 
 | ||||||
| \subsection{Prérequis} | \subsection{Prérequis} | ||||||
| 
 | 
 | ||||||
| Vous devez, en dehors des outils classiques (bash, gcc, make\dots),  | Vous devez, en dehors des outils classiques (gcc, make\dots),  | ||||||
| avoir quelques bibliothèques installées\footnote{Les \texttt{-dev} | avoir quelques bibliothèques installées\footnote{Les \texttt{-dev} | ||||||
| pour Debain et dérivées}~: libv4l2, libpnglite, libtiff, et | pour Debain et dérivées}~: libv4l2, libpnglite, libtiff, et | ||||||
| probablement d'autres choses. Être familier avec l'utilisation du | probablement d'autres choses. | ||||||
| shell\index{shell} sera un plus. |  | ||||||
| 
 | 
 | ||||||
| \subsection{Compilation} | \subsection{Compilation} | ||||||
| 
 | 
 | ||||||
| Un script \texttt{build.sh} permet de construire approximativement  | Un script \texttt{build.sh} permet de construire approximativement  | ||||||
| le bouzin. Il est loin d'être parfait\footnote{Il doit être possible | le bouzin. Il est loin d'être parfait. | ||||||
| de faire un Makefile récursif, mais\dots}. |  | ||||||
| Dans chacun des |  | ||||||
| répertoires à traiter, ce script devrait trouver un Makefile et un fichier |  | ||||||
| \texttt{t.c} source de la cible par défaut du make. |  | ||||||
| \vspace{1em} | \vspace{1em} | ||||||
| 
 | 
 | ||||||
| Pour le moment, la procédure d'installation est un peu rude, | Pour le moment, la procédure d'installation est un peu rude, | ||||||
| @ -155,7 +131,7 @@ approprié, par exemple | |||||||
| \texttt{/usr/local/include} et \texttt{/usr/local/lib}. | \texttt{/usr/local/include} et \texttt{/usr/local/lib}. | ||||||
| 
 | 
 | ||||||
| % ------------------------------------------------------------------- | % ------------------------------------------------------------------- | ||||||
| \section{Utilisation coté codeur}\label{codaz} | \section{Utilisation coté codeur} | ||||||
| 
 | 
 | ||||||
| Classiquement, il y a un fichier à inclure, \texttt{floatimg.h}, | Classiquement, il y a un fichier à inclure, \texttt{floatimg.h}, | ||||||
| contenant un certain nombre de | contenant un certain nombre de | ||||||
| @ -284,20 +260,12 @@ l'on peut assimiler à un noir absolu\index{absolu}. | |||||||
| Affichage de quelques valeurs calculées à partir d'un fichier | Affichage de quelques valeurs calculées à partir d'un fichier | ||||||
| \texttt{.fimg}\index{.fimg}. | \texttt{.fimg}\index{.fimg}. | ||||||
| 
 | 
 | ||||||
| \begin{verbatim} |  | ||||||
| usage : fimgstats [options] file.fimg |  | ||||||
|         -c      make a machinable csv |  | ||||||
|         -v      increase verbosity |  | ||||||
| \end{verbatim} |  | ||||||
| 
 |  | ||||||
| \subsection{fimgops}\index{fimgops}\label{fimgops} | \subsection{fimgops}\index{fimgops}\label{fimgops} | ||||||
| 
 | 
 | ||||||
| Operations diverses sur ou entre des images. | Operations diverses sur ou entre des images. | ||||||
| 
 | 
 | ||||||
| \begin{verbatim} | Syntaxe CLI\index{CLI} à définir. | ||||||
| Usage: | 
 | ||||||
|         fimgops [options] A.fimg B.fimg operator D.fimg |  | ||||||
| \end{verbatim} |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| \subsection{fimg2png, fimg2pnm, fimg2tiff} | \subsection{fimg2png, fimg2pnm, fimg2tiff} | ||||||
| @ -333,26 +301,6 @@ Il reste plein de choses à faire pour que ce soit vraiment utilisable. | |||||||
| \ | \ | ||||||
| \end{itemize} | \end{itemize} | ||||||
| 
 | 
 | ||||||
| % ------------------------------------------------------------------- |  | ||||||
| \section{Exemples pour yusers}\index{example} |  | ||||||
| 
 |  | ||||||
| \begin{verbatim} |  | ||||||
| #!/bin/bash |  | ||||||
| 
 |  | ||||||
| ACCU="quux.fimg" |  | ||||||
| TMPF="tmp.fimg" |  | ||||||
| DIMS="640 480" |  | ||||||
| 
 |  | ||||||
| mkfimg ${ACCU} ${DIMS} |  | ||||||
| 
 |  | ||||||
| for i in {0..100} |  | ||||||
| do |  | ||||||
|         fname=$( printf "f%04d.pnm" $i ) |  | ||||||
|         echo $fname |  | ||||||
|         mkfimg -t drand48 ${TMPF} ${DIMS} |  | ||||||
| done |  | ||||||
| \end{verbatim} |  | ||||||
| 
 |  | ||||||
| % ------------------------------------------------------------------- | % ------------------------------------------------------------------- | ||||||
| \section{Video for Linux}\index{v4l2} | \section{Video for Linux}\index{v4l2} | ||||||
| 
 | 
 | ||||||
| @ -386,10 +334,6 @@ options : | |||||||
|         -v              increase verbosity |         -v              increase verbosity | ||||||
| \end{verbatim} | \end{verbatim} | ||||||
| 
 | 
 | ||||||
| \subsection{video-infos}\index{video-infos}\label{video-infos} |  | ||||||
| 
 |  | ||||||
| Que contient, que peut faire mon périphérique \textsl{àlc} ? |  | ||||||
| 
 |  | ||||||
| % ------------------------------------------------------------------- | % ------------------------------------------------------------------- | ||||||
| \section{Et pour la suite ?} | \section{Et pour la suite ?} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ DEPS = ../floatimg.h  ../libfloatimg.a Makefile | |||||||
| # 			----------
 | # 			----------
 | ||||||
| 
 | 
 | ||||||
| all:	fimg2pnm mkfimg png2fimg fimgstats fimg2png	\ | all:	fimg2pnm mkfimg png2fimg fimgstats fimg2png	\ | ||||||
| 	addpnm2fimg cumulfimgs fimgops | 	addpnm2fimg cumulfimgs | ||||||
| 
 | 
 | ||||||
| fimgstats:	fimgstats.c $(DEPS) | fimgstats:	fimgstats.c $(DEPS) | ||||||
| 	gcc $(COPT) $< ../libfloatimg.a -o $@  | 	gcc $(COPT) $< ../libfloatimg.a -o $@  | ||||||
| @ -20,9 +20,6 @@ cumulfimgs:	cumulfimgs.c $(DEPS) | |||||||
| mkfimg:		mkfimg.c  $(DEPS) | mkfimg:		mkfimg.c  $(DEPS) | ||||||
| 	gcc $(COPT) $< ../libfloatimg.a -o $@  | 	gcc $(COPT) $< ../libfloatimg.a -o $@  | ||||||
| 
 | 
 | ||||||
| fimgops:		fimgops.c  $(DEPS) |  | ||||||
| 	gcc $(COPT) $< ../libfloatimg.a -o $@  |  | ||||||
| 
 |  | ||||||
| fimg2pnm:	fimg2pnm.c  $(DEPS) | fimg2pnm:	fimg2pnm.c  $(DEPS) | ||||||
| 	gcc $(COPT) $< ../libfloatimg.a -o $@  | 	gcc $(COPT) $< ../libfloatimg.a -o $@  | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,81 +0,0 @@ | |||||||
| #include  <stdio.h> |  | ||||||
| #include  <string.h> |  | ||||||
| #include  <stdlib.h> |  | ||||||
| #include  <unistd.h> |  | ||||||
| 
 |  | ||||||
| #include  "../floatimg.h" |  | ||||||
| 
 |  | ||||||
| int		verbosity; |  | ||||||
| 
 |  | ||||||
| /* --------------------------------------------------------------------- */ |  | ||||||
| #define		OP_ADD		1 |  | ||||||
| #define		OP_MUL		2 |  | ||||||
| typedef struct { |  | ||||||
| 	int	code; |  | ||||||
| 	char	*op; |  | ||||||
| 	} Opcode; |  | ||||||
| 
 |  | ||||||
| Opcode opcodes[] = { |  | ||||||
| 	{ OP_ADD,		"add"		}, |  | ||||||
| 	{ OP_MUL,		"mul"		}, |  | ||||||
| 	{ 0,			NULL		} |  | ||||||
| 	}; |  | ||||||
| static void pr_opcodes(void) |  | ||||||
| { |  | ||||||
| Opcode *optr; |  | ||||||
| puts("operators:"); |  | ||||||
| for (optr = opcodes; optr->code; optr++) { |  | ||||||
| 	printf("\t%-20s %d\n", optr->op, optr->code);  |  | ||||||
| 	}  |  | ||||||
| } |  | ||||||
| static int look_opcodes(char *txt) |  | ||||||
| { |  | ||||||
| Opcode *optr; |  | ||||||
| 
 |  | ||||||
| for (optr = opcodes; optr->code; optr++) { |  | ||||||
| 	if (!strcmp(txt, optr->op)) { |  | ||||||
| 		printf("found %s as %d\n", optr->op, optr->code); |  | ||||||
| 		return optr->code; |  | ||||||
| 		} |  | ||||||
| 	}  |  | ||||||
| return -1; |  | ||||||
| } |  | ||||||
| /* --------------------------------------------------------------------- */ |  | ||||||
| static void help(int lj) |  | ||||||
| { |  | ||||||
| 
 |  | ||||||
| puts("usage:\n\tfimgops [options] A.fimg B.fimg operator D.fimg"); |  | ||||||
| pr_opcodes(); |  | ||||||
| if (verbosity) fimg_print_version(1); |  | ||||||
| exit(0); |  | ||||||
| } |  | ||||||
| /* --------------------------------------------------------------------- */ |  | ||||||
| int main(int argc, char *argv[]) |  | ||||||
| { |  | ||||||
| int		foo, opt; |  | ||||||
| float		fvalue; |  | ||||||
| 
 |  | ||||||
| FloatImg	fimg; |  | ||||||
| 
 |  | ||||||
| while ((opt = getopt(argc, argv, "hk:v")) != -1) { |  | ||||||
| 	switch(opt) { |  | ||||||
| 		case 'h':	help(0);			break; |  | ||||||
| 		case 'k':	fvalue = atof(optarg);		break; |  | ||||||
| 		case 'v':	verbosity++;			break; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| #if DEBUG_LEVEL |  | ||||||
| fprintf(stderr, "argc %d optind %d\n", argc, optind); |  | ||||||
| for (foo=0; foo<argc; foo++) |  | ||||||
| 	fprintf(stderr, "%3d  %s\n", foo, argv[foo]); |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| if (4 != argc-optind) { |  | ||||||
| 	fprintf(stderr, "%s need some arguments...\n", argv[0]); |  | ||||||
| 	exit(1); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| return 0; |  | ||||||
| } |  | ||||||
| /* --------------------------------------------------------------------- */ |  | ||||||
| @ -1,5 +1,4 @@ | |||||||
| #include  <stdio.h> | #include  <stdio.h> | ||||||
| #include  <string.h> |  | ||||||
| #include  <stdlib.h> | #include  <stdlib.h> | ||||||
| #include  <unistd.h> | #include  <unistd.h> | ||||||
| 
 | 
 | ||||||
| @ -8,27 +7,9 @@ | |||||||
| int		verbosity; | int		verbosity; | ||||||
| 
 | 
 | ||||||
| /* --------------------------------------------------------------------- */ | /* --------------------------------------------------------------------- */ | ||||||
| #define		T_BLACK		0 | void help(int lj) | ||||||
| #define		T_DRAND48	1 |  | ||||||
| #define		T_RGB_0		2 |  | ||||||
| static int get_type(char *name) |  | ||||||
| { | { | ||||||
| 
 | fimg_print_version(1); | ||||||
| fprintf(stderr, ">>> %s ( '%s' )\n", __func__, name); |  | ||||||
| 
 |  | ||||||
| #define TEST(str)	( ! strcmp(name, str) ) |  | ||||||
| if TEST("black")	return T_BLACK; |  | ||||||
| if TEST("drand48")	return T_DRAND48; |  | ||||||
| 
 |  | ||||||
| return -1; |  | ||||||
| } |  | ||||||
| /* --------------------------------------------------------------------- */ |  | ||||||
| static void help(int lj) |  | ||||||
| { |  | ||||||
| 
 |  | ||||||
| puts("Usage:\n\tmkfimg [options]  quux.fimg width height\n"); |  | ||||||
| 
 |  | ||||||
| if (verbosity) fimg_print_version(1); |  | ||||||
| 
 | 
 | ||||||
| exit(0); | exit(0); | ||||||
| } | } | ||||||
| @ -39,45 +20,32 @@ int		foo, opt; | |||||||
| int		width, height; | int		width, height; | ||||||
| char		*fname; | char		*fname; | ||||||
| float		fvalue; | float		fvalue; | ||||||
| int		type = 0; |  | ||||||
| 
 | 
 | ||||||
| FloatImg	fimg; | FloatImg	fimg; | ||||||
| 
 | 
 | ||||||
| while ((opt = getopt(argc, argv, "ht:v")) != -1) { | while ((opt = getopt(argc, argv, "ho:v")) != -1) { | ||||||
| 	switch(opt) { | 	switch(opt) { | ||||||
| 		case 'h':	help(0);			break; | 		case 'h':	help(0);			break; | ||||||
| 		case 't':	type = get_type(optarg);	break; |  | ||||||
| 		case 'v':	verbosity++;			break; | 		case 'v':	verbosity++;			break; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| #if DEBUG_LEVEL | if (4 != argc) { | ||||||
| fprintf(stderr, "argc %d optind %d\n", argc, optind); | 	fimg_print_version(1); | ||||||
| for (foo=0; foo<argc; foo++) | 	fprintf(stderr, "Usage:\n\t%s quux.fimg width height\n", argv[0]); | ||||||
| 	fprintf(stderr, "%3d  %s\n", foo, argv[foo]); |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| if (3 != argc-optind) { |  | ||||||
| 	fprintf(stderr, "%s need filename, width & height\n", argv[0]); |  | ||||||
| 	exit(1); | 	exit(1); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| fname = argv[optind]; | fname = argv[optind]; | ||||||
| width = atoi(argv[optind+1]);	height = atoi(argv[optind+2]);	 | width = atoi(argv[optind+1]);	height = atoi(argv[optind+2]);	 | ||||||
| 
 | fprintf(stderr, "making  '%s'  %d x %d\n", fname, width, height); | ||||||
| if (verbosity) fprintf(stderr, "making  '%s'  %d x %d\n", fname, width, height); |  | ||||||
| 
 | 
 | ||||||
| foo = fimg_create(&fimg, width, height, 3); | foo = fimg_create(&fimg, width, height, 3); | ||||||
| if (foo) { | if (foo) { | ||||||
| 	fprintf(stderr, "create floatimg -> %d\n", foo); | 	fprintf(stderr, "create floatimg -> %d\n", foo); | ||||||
| 	exit(1); | 	exit(1); | ||||||
| 	} | 	} | ||||||
| 
 | fimg_clear(&fimg); | ||||||
| switch(type) { |  | ||||||
| 	default: |  | ||||||
| 	case T_BLACK:		fimg_clear(&fimg);		break; |  | ||||||
| 	case T_DRAND48:		fimg_drand48(&fimg, 1.0);	break; |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| foo = fimg_dump_to_file(&fimg, fname, 0); | foo = fimg_dump_to_file(&fimg, fname, 0); | ||||||
| if (foo) { | if (foo) { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user