Compare commits
	
		
			3 Commits
		
	
	
		
			ea0945ab98
			...
			69d94f59d3
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 69d94f59d3 | ||
|   | 0208ee3b2d | ||
|   | 8386c852a9 | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -52,6 +52,7 @@ v4l2/nc-camcontrol | ||||
| tools/fimg2png | ||||
| tools/fimg2pnm | ||||
| tools/fimg2tiff | ||||
| tools/fimg2text | ||||
| tools/fimgstats | ||||
| tools/mkfimg | ||||
| tools/png2fimg | ||||
|  | ||||
| @ -69,10 +69,11 @@ for (idx=0; idx<nbre; idx++) { | ||||
| 	if (preloaded) { | ||||
| 		fimg_copy_data(&blank, image); | ||||
| 		} | ||||
| 	/* XXX
 | ||||
| 	else { | ||||
| 		fimg_hdeg_a(image, fval); | ||||
| 		} | ||||
| 
 | ||||
| 		*/ | ||||
| 	if ((foo=traite_une_image(image, pproc, 1, outd))) { | ||||
| 		fprintf(stderr, "%s : err %d from 'traite_une_image'\n", | ||||
| 				__func__, foo); | ||||
| @ -219,7 +220,7 @@ int		blanks = 20; | ||||
| char		*InFchain  = "0"; | ||||
| char		*OutFchain = "0"; | ||||
| 
 | ||||
| fprintf(stderr, "%s\n\tcompiled %s, %s, pid %d\n", | ||||
| fprintf(stderr, "*** %s\n\tcompiled %s, %s, pid %d\n", | ||||
| 			argv[0], __DATE__, __TIME__, getpid()); | ||||
| fimg_print_version(2); | ||||
| 
 | ||||
|  | ||||
| @ -301,6 +301,13 @@ if (foo) { | ||||
| 	exit(1); | ||||
| 	} | ||||
| 
 | ||||
| if (verbosity) { | ||||
| 	fprintf(stderr, "\tinput glob        '%s'\n", argv[optind]); | ||||
| 	fprintf(stderr, "\toutput dir        '%s'\n", argv[optind+1]); | ||||
| 	fprintf(stderr, "\tsrc filter        '%s'\n", InFchain); | ||||
| 	fprintf(stderr, "\tout filter        '%s'\n", OutFchain); | ||||
| 	} | ||||
| 
 | ||||
| if (verbosity > 1) { | ||||
| 	puts("========================="); | ||||
| 	filterstack_list(0, __FILE__); | ||||
|  | ||||
| @ -8,8 +8,8 @@ DEPS = ../floatimg.h  ../libfloatimg.a Makefile | ||||
| 
 | ||||
| # 			----------
 | ||||
| 
 | ||||
| all:	fimg2pnm mkfimg png2fimg fimgstats fimg2png	\ | ||||
| 	fimg2tiff					\
 | ||||
| all:	fimg2pnm mkfimg png2fimg fimgstats fimg2png		\ | ||||
| 	fimg2tiff fimg2text					\
 | ||||
| 	addpnm2fimg cumulfimgs fimgops fimgfx | ||||
| 
 | ||||
| fimgstats:	fimgstats.c $(DEPS) | ||||
| @ -33,6 +33,9 @@ fimg2pnm:	fimg2pnm.c  $(DEPS) | ||||
| fimg2png:	fimg2png.c  $(DEPS) | ||||
| 	gcc $(COPT) $< ../libfloatimg.a -lpnglite -lz -o $@  | ||||
| 
 | ||||
| fimg2text:	fimg2text.c  $(DEPS) | ||||
| 	gcc $(COPT) $< ../libfloatimg.a  -o $@  | ||||
| 
 | ||||
| fimg2tiff:	fimg2tiff.c  $(DEPS) | ||||
| 	gcc $(COPT) $< ../libfloatimg.a -ltiff -o $@ | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										123
									
								
								tools/fimg2text.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								tools/fimg2text.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,123 @@ | ||||
| /*
 | ||||
|  *	converting a floatimg to a machinable text file | ||||
|  */ | ||||
| 
 | ||||
| #include  <stdio.h> | ||||
| #include  <stdlib.h> | ||||
| #include  <unistd.h> | ||||
| #include  <string.h> | ||||
| 
 | ||||
| #include  "../floatimg.h" | ||||
| 
 | ||||
| int		verbosity; | ||||
| 
 | ||||
| /* ------------------------------------------------------------------------- */ | ||||
| int export_as_machinable(FloatImg *src, char *fname, int flags) | ||||
| { | ||||
| FILE		*fp; | ||||
| int		x, y, idx; | ||||
| 
 | ||||
| #if DEBUG_LEVEL | ||||
| fprintf(stderr, ">>> %25s ( %p '%s' %d )\n", __func__, | ||||
| 			src, fname, flags); | ||||
| #endif | ||||
| 
 | ||||
| fp = NULL;					/* molly guard */ | ||||
| if (strcmp("-", fname)) {			/* real file */ | ||||
| 	fprintf(stderr, "real file\n"); | ||||
| 	} | ||||
| 	else { | ||||
| 	fprintf(stderr, "kitchen sink\n"); | ||||
| 	} | ||||
| 
 | ||||
| idx = 0; | ||||
| fp = stdout;					/* XXX */ | ||||
| for (y=0; y<src->height; y++) { | ||||
| 	for (x=0; x<src->width; x++) { | ||||
| 
 | ||||
| 		fprintf(fp, "%d %d %d ", x, y, idx); | ||||
| 		fprintf(fp, " %f %f %f\n", src->R[idx], src->G[idx], src->B[idx]); | ||||
| 		idx++; | ||||
| 
 | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| return 0; | ||||
| } | ||||
| /* ------------------------------------------------------------------------- */ | ||||
| int convertir_fimg_en_machinable(char *srcname, char *dstname, int grisaille) | ||||
| { | ||||
| int		foo, infos[3]; | ||||
| FloatImg	fimg; | ||||
| 
 | ||||
| #if DEBUG_LEVEL | ||||
| fprintf(stderr, ">>> %25s ( '%s' '%s' %d )\n", __func__, | ||||
| 			srcname, dstname, notused); | ||||
| #endif | ||||
| 
 | ||||
| foo = fimg_fileinfos(srcname, infos); | ||||
| if (foo) { | ||||
| 	fprintf(stderr, "'%s' get dims -> %d\n", srcname, foo); | ||||
| 	return foo; | ||||
| 	} | ||||
| 
 | ||||
| if (verbosity) { | ||||
| 	fprintf(stderr, "%s: image '%s' is %d x %d  %s\n",  | ||||
| 				__func__, | ||||
| 				srcname, infos[0], infos[1], | ||||
| 				fimg_str_type(infos[2])); | ||||
| 	} | ||||
| 
 | ||||
| foo = fimg_create_from_dump(srcname, &fimg); | ||||
| if (foo) { | ||||
| 	fprintf(stderr, "create fimg from '%s' -> %d\n", srcname, foo); | ||||
| 	return -1; | ||||
| 	} | ||||
| 
 | ||||
| if (verbosity) { | ||||
| 	fimg_describe(&fimg, srcname); | ||||
| 	} | ||||
| 
 | ||||
| foo = export_as_machinable(&fimg, dstname, 0); | ||||
| 
 | ||||
| fimg_destroy(&fimg); | ||||
| 
 | ||||
| return 0; | ||||
| } | ||||
| /* ------------------------------------------------------------------------- */ | ||||
| void help(int k) | ||||
| { | ||||
| 
 | ||||
| puts("usage:\n\tfimg2text [options] foo.fimg > bar.csv"); | ||||
| puts("options:"); | ||||
| puts("\t-v\tincrease verbosity"); | ||||
| if (verbosity) fimg_print_version(1); | ||||
| 
 | ||||
| exit(0); | ||||
| } | ||||
| /* ------------------------------------------------------------------------- */ | ||||
| 
 | ||||
| int main(int argc, char *argv[]) | ||||
| { | ||||
| int		foo, opt; | ||||
| 
 | ||||
| while ((opt = getopt(argc, argv, "ghv")) != -1) { | ||||
| 	switch(opt) { | ||||
| 		case 'v':	verbosity++;		break; | ||||
| 		case 'h':	help(1);		exit(1); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| if (1 != argc-optind) { | ||||
| 	fprintf(stderr, "error: %s need two filenames\n", argv[0]); | ||||
| 	exit(1); | ||||
| 	} | ||||
| 
 | ||||
| foo = convertir_fimg_en_machinable(argv[optind], "-", 0); | ||||
| if (foo) | ||||
| 	fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo); | ||||
| 
 | ||||
| return 0; | ||||
| } | ||||
| /* ------------------------------------------------------------------------- */ | ||||
| 
 | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user