Compare commits

...

5 Commits

Author SHA1 Message Date
tth
e224ab83b6 start of the fake colors module 2022-05-18 11:55:01 +02:00
tth
3c551b6c7c cosmetic 2022-05-18 10:27:15 +02:00
tth
fe9a14e2b5 small tuning... 2022-05-18 10:26:29 +02:00
tth
11082c0d08 add multiformat output to fimgfx 2022-05-17 08:30:20 +02:00
tth
615321eca8 a big commit of garbage 2022-05-14 20:49:59 +02:00
22 changed files with 269 additions and 43 deletions

View File

@ -212,6 +212,20 @@ ret = fimg_decomp_rgbz_color(img, &tmp, k);
fimg_copy_data(&tmp, img); fimg_copy_data(&tmp, img);
fimg_destroy(&tmp); fimg_destroy(&tmp);
return ret;
}
/* -------------------------------------------------------------- */
/* nouveau 14 mai 2022 */
static int run_gr2popcol(FloatImg *img, int k)
{
FloatImg tmp;
int ret;
memset(&tmp, 0, sizeof(FloatImg));
fimg_clone(img, &tmp, 0);
ret = graylevel2popcolors(img, &tmp, k);
fimg_copy_data(&tmp, img);
fimg_destroy(&tmp);
return ret; return ret;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
@ -424,6 +438,11 @@ switch (idFx) {
retval = fimg_highlight_color(image, image, 'R', 1.717); retval = fimg_highlight_color(image, image, 'R', 1.717);
break; break;
case CR_gr2popcol:
// fprintf(stderr, "******* TO BE DONE ********\n");
retval = run_gr2popcol(image, -1);
break;
default : default :
fprintf(stderr, "%s : effect #%d invalid\n", fprintf(stderr, "%s : effect #%d invalid\n",
__func__, idFx); __func__, idFx);

View File

@ -41,5 +41,6 @@
49 splitlevel 1 1 49 splitlevel 1 1
50 decrgbzc 1 99 50 decrgbzc 1 99
51 decrgbzg 1 99 51 decrgbzg 1 99
60 gr2popcol 1 99
99 message 1 1.0 99 message 1 1.0
-1 end 1 1.0 -1 end 1 1.0

View File

@ -21,6 +21,42 @@
*/ */
extern int verbosity; extern int verbosity;
/* -------------------------------------------------------------- */
/* nouveau 14 mai 2022 rue Ernest Renan */
int graylevel2popcolors(FloatImg *src, FloatImg *dst, int k)
{
int x, y;
float rgb[3];
float theoric_maxval, real_maxv;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, k);
#endif
theoric_maxval = src->fval * src->count;
real_maxv = fimg_get_maxvalue(src);
#if DEBUG_LEVEL
fprintf(stderr, "maxval: theoric= %.3f real= %.3f\n", \
theoric_maxval, real_maxv);
#endif
fimg_clear(dst);
for (y=0; y<src->height; y++) {
for (x=0; x<src->width; x++)
{
fimg_get_rgb(src, x, y, rgb);
rgb[0] = real_maxv * fabs(cos(21.0 * rgb[0] / real_maxv));
rgb[1] = real_maxv * fabs(cos(31.0 * rgb[1] / real_maxv));
rgb[2] = real_maxv * fabs(cos(11.0 * rgb[2] / real_maxv));
fimg_put_rgb(dst, x, y, rgb);
}
}
return 0;
}
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/* /*
* please, add some parameters ! * please, add some parameters !

View File

@ -3,6 +3,8 @@
* --------------------------------------------------- * ---------------------------------------------------
*/ */
int graylevel2popcolors(FloatImg *src, FloatImg *dst, int k);
int incrustation_vignette(FloatImg *src, FloatImg *dst, int k); int incrustation_vignette(FloatImg *src, FloatImg *dst, int k);

View File

@ -166,19 +166,19 @@ int experiment(void)
int foo; int foo;
FloatImg image, dest; FloatImg image, dest;
fprintf(stderr, "EXPERIMENT\n"); fprintf(stderr, "--------- EXPERIMENT ------------\n");
foo = fimg_create_from_dump("01137.fimg", &image); foo = fimg_create_from_dump("mire.fimg", &image);
if (foo) { if (foo) {
fprintf(stderr, "%s: err %d on create_from_dump\n", fprintf(stderr, "%s: err %d on create_from_dump\n",
__func__, foo); __func__, foo);
return -1; return -1;
} }
foo = fimg_clone(&image, &dest, 1); foo = fimg_clone(&image, &dest, 0);
foo = fimg_copy_data(&image, &dest);
incrustation_vignette(&image, &dest, 0); foo = graylevel2popcolors(&image, &dest, 0);
fprintf(stderr, "POP COLOR- -> %d\n", foo);
fimg_export_picture(&dest, "foo.png", 0); fimg_export_picture(&dest, "foo.png", 0);

View File

@ -5,7 +5,7 @@
* https://git.tetalab.org/tTh/FloatImg * https://git.tetalab.org/tTh/FloatImg
*/ */
#define FIMG_VERSION (182) #define FIMG_VERSION (187)
#define RELEASE_NAME ("noname") #define RELEASE_NAME ("noname")
/* /*
* in memory descriptor * in memory descriptor
@ -45,7 +45,9 @@ typedef struct {
} FimgMetaData; } FimgMetaData;
/* /*
* we MUST look at packing and endianess problems NOW */ * we MUST look at packing and endianess problems NOW
* and we can thing about a fised size of this datablock
*/
#define MAGIC_AREA51 0xA5EA0051 #define MAGIC_AREA51 0xA5EA0051
@ -187,6 +189,9 @@ int fimg_mix_rgb_gray(FloatImg *img, float mix);
int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]); int fimg_shift_to_zero(FloatImg *s, FloatImg *d, float coefs[6]);
int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d); int fimg_auto_shift_to_zero(FloatImg *s, FloatImg *d);
/* funcs/falsecolors.c */
int fimg_falsecolors_0(FloatImg *src, FloatImg *dst, int k, float valf);
/* --> funcs/plasmas.c */ /* --> funcs/plasmas.c */
int fimg_prototype_plasma(FloatImg *img, double time, int type); int fimg_prototype_plasma(FloatImg *img, double time, int type);
@ -233,7 +238,7 @@ int fimg_create_from_dump(char *fname, FloatImg *head);
/* FIMG metadata module */ /* FIMG metadata module */
int fimg_show_metadata(FimgMetaData *pmd, char *title, int notused); int fimg_show_metadata(FimgMetaData *pmd, char *title, int notused);
int fimg_default_metadata(FimgMetaData *pmd); int fimg_default_metadata(FimgMetaData *pmd, int bla);
int fimg_get_metadata_from_file(char *fname, FimgMetaData *pmd); int fimg_get_metadata_from_file(char *fname, FimgMetaData *pmd);
int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags); int fimg_save_R_as_fits(FloatImg *src, char *outname, int flags);

View File

@ -9,6 +9,7 @@ DEPS = ../floatimg.h Makefile
OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \
fimg-libpnm.o rampes.o rectangle.o \ fimg-libpnm.o rampes.o rectangle.o \
sfx0.o sfx1.o sfx2.o sfx3.o sfx4.o \ sfx0.o sfx1.o sfx2.o sfx3.o sfx4.o \
falsecolors.o \
geometry.o rotate.o fimg-openexr.o \ geometry.o rotate.o fimg-openexr.o \
equalize.o fimg-fits.o saturation.o histogram.o \ equalize.o fimg-fits.o saturation.o histogram.o \
fimg-dicom.o \ fimg-dicom.o \
@ -137,6 +138,9 @@ qsortrgb.o: qsortrgb.c $(DEPS)
exporter.o: exporter.c $(DEPS) exporter.o: exporter.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
falsecolors.o: falsecolors.c $(DEPS)
gcc $(COPT) -c $<
hsv.o: hsv.c $(DEPS) hsv.o: hsv.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<

39
funcs/falsecolors.c Normal file
View File

@ -0,0 +1,39 @@
/*
* FloatImg library from tTh - really ugly code inside
*/
#include <stdio.h>
#include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h"
/* -------------------------------------------------------------- */
/* this is a global vars exported from main */
extern int verbosity;
/* -------------------------------------------------------------- */
/* -------------------------------------------------------------- */
/* nouveau 18 mai 2022 */
int fimg_falsecolors_0(FloatImg *src, FloatImg *dst, int k, float valf)
{
int x, y;
fprintf(stderr, ">>> %s ( %p %p %d %f )\n", __func__,
src, dst, k, valf);
for (y=0; y<src->height, y++) {
for (x=0; x<src->width, x++) {
/***********************/
/* DO SOMETHING HERE ! */
/***********************/
}
}
return -1;
}
/* -------------------------------------------------------------- */

View File

@ -25,7 +25,7 @@ enum nCmd { Equalize=1, Rotate, Sfx0, F3x3, MIRE, Wfits, Wpng, Wtiff,
Displace, ReadPNG, Plasmas, Hilight, OpenEXR, Displace, ReadPNG, Plasmas, Hilight, OpenEXR,
Geometrie, FileType, Mirror, KillRGB, Geometrie, FileType, Mirror, KillRGB,
Pixelize,SplitLevel, DecompRgbz, DecompRgbg, Pixelize,SplitLevel, DecompRgbz, DecompRgbg,
Rectangle, Dicom }; Rectangle, Dicom, Fakolor0, Fakolor3 };
typedef struct { typedef struct {
char *name; char *name;
int Cmd; int Cmd;
@ -60,6 +60,8 @@ Command commands[] = {
{ "decomprgbg", DecompRgbg }, { "decomprgbg", DecompRgbg },
{ "rectangle", Rectangle }, { "rectangle", Rectangle },
{ "dicom", Dicom }, { "dicom", Dicom },
{ "fakolor0", Fakolor0 },
{ "fakolor3", Fakolor3 },
{ NULL, 0 } { NULL, 0 }
} ; } ;
@ -248,7 +250,9 @@ switch(opt) {
case Dicom: case Dicom:
foo = essai_dicom(filename, outfile, 0); foo = essai_dicom(filename, outfile, 0);
break; break;
case Fakolor0:
foo = essai_0_fausses_couleurs(outfile, 0);
break;
default: default:
fprintf(stderr, "'%s' is a bad command\n", command); fprintf(stderr, "'%s' is a bad command\n", command);
exit(1); exit(1);
@ -256,7 +260,7 @@ switch(opt) {
} }
if (foo) { if (foo) {
fprintf(stderr, "******* Essai --> %d\n", foo); fprintf(stderr, "******* essai --> %d\n\n", foo);
} }
fprintf(stderr, "++++++++++++ end of '%s' pid %d\n", command, getpid()); fprintf(stderr, "++++++++++++ end of '%s' pid %d\n", command, getpid());

View File

@ -18,6 +18,26 @@
extern int verbosity; extern int verbosity;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* nouveau 18 mai 2022 */
int essai_0_fausses_couleurs(char *dstfile, int type)
{
FloatImg src, dst;
int foo;
#define W 1024
#define H 768
fprintf(stderr, "\nEssais fausses couleurs (type %d) -> '%s'\n", type, dstfile);
foo = fimg_create(&src, W, H, FIMG_TYPE_RGB);
foo = fimg_hdeg_a(&src, 12e3);
foo = fimg_clone(&src, &dst, 0);
foo = fimg_clear(&dst);
foo = fimg_falsecolors_0(&src, &dst, type, 3.141592654);
foo= fimg_export_picture(&dst, dstfile, 0);
return -1;
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int essai_dicom(char *inf, char *outf, int k) int essai_dicom(char *inf, char *outf, int k)
{ {
@ -41,6 +61,10 @@ FloatImg img;
int foo; int foo;
int rect[4]; int rect[4];
if (0 != k) {
fprintf(stderr, "in %s, k muste be 0, was %d\n", __func__, k);
}
foo = fimg_create(&img, 320, 240, FIMG_TYPE_RGB); foo = fimg_create(&img, 320, 240, FIMG_TYPE_RGB);
fimg_drand48(&img, 1.0); fimg_drand48(&img, 1.0);
@ -741,6 +765,10 @@ int essai_geometrie(char *infile, int notused)
FloatImg fimg, result; FloatImg fimg, result;
int foo; int foo;
if (0 != notused) {
fprintf(stderr, "in %s, k must be 0, was %d\n", __func__, notused);
}
if (NULL != infile) { if (NULL != infile) {
fprintf(stderr, "loading %s\n", infile); fprintf(stderr, "loading %s\n", infile);
foo = fimg_create_from_dump(infile, &fimg); foo = fimg_create_from_dump(infile, &fimg);
@ -879,13 +907,17 @@ int essai_mire(char *outname, int notused)
FloatImg fimg; FloatImg fimg;
int re, foo; int re, foo;
if (0 != notused) {
fprintf(stderr, "in %s, k must be 0, was %d\n", __func__, notused);
}
fimg_create(&fimg, 1280, 960, FIMG_TYPE_RGB); fimg_create(&fimg, 1280, 960, FIMG_TYPE_RGB);
re = fimg_test_pattern(&fimg, 9, 1.0); re = fimg_test_pattern(&fimg, 9, 1.0);
if (re) { if (re) {
fprintf(stderr, "fimg_test_pattern -> %d\n", re); fprintf(stderr, "fimg_test_pattern -> %d\n", re);
} }
foo = fimg_export_picture(&fimg, "mire.pnm", 0); foo = fimg_export_picture(&fimg, outname, 0);
fprintf(stderr, "in %s, export give a %d value\n", __func__, foo); fprintf(stderr, "in %s, export give a %d value\n", __func__, foo);
return 0; return 0;

View File

@ -28,6 +28,7 @@ int essai_geometrie(char *infile, int notused);
int essai_detect_type(void); int essai_detect_type(void);
int fimg_essai_histo(FloatImg *src, char *outpic, int k); /* histogram.c */ int fimg_essai_histo(FloatImg *src, char *outpic, int k); /* histogram.c */
int essai_histogramme(char *fname, int k); int essai_histogramme(char *fname, int k);
int essai_0_fausses_couleurs(char *dstfile, int type);
int essai_lecture_png(char *fname, char *outfile, int notused); int essai_lecture_png(char *fname, char *outfile, int notused);

View File

@ -48,7 +48,7 @@ if (memcmp(filehead.magic, "FIMG", 4)) {
/* XXX preparer la gestion des metadata */ /* XXX preparer la gestion des metadata */
if ('a' == filehead.magic[4]) { if ('a' == filehead.magic[4]) {
fprintf(stderr,"****** %s have metadata\n", fname); fprintf(stderr,"\n\t****** %s have metadata\n\n", fname);
} }
datas[0] = filehead.w; datas[0] = filehead.w;
@ -67,6 +67,7 @@ int fimg_dumpmd_to_file(FloatImg *fimg, char *fname, \
FILE *fp; FILE *fp;
int foo, nbre; int foo, nbre;
FimgFileHead filehead; FimgFileHead filehead;
FimgMetaData fakemd;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p '%s' %p %d )\n", __func__, fimg, fprintf(stderr, ">>> %s ( %p '%s' %p %d )\n", __func__, fimg,
@ -83,6 +84,20 @@ if (FIMG_TYPE_RGB != fimg->type) {
return -8; return -8;
} }
/* OK, we have to make a fake metadata chunk, if the caller
* don't have one. Ugly, and nice */
if (NULL == pmd) {
fprintf(stderr, ">>> %s making faked metadata\n", __func__);
foo = fimg_default_metadata(&fakemd, 3);
fprintf(stderr, "fakemd is at %p\n", &fakemd);
pmd = &fakemd;
}
else {
/* OK, get some funky metadatas */
fprintf(stderr, "OK %s get funky metadatas\n", __func__);
fprintf(stderr, "acquisition values %f %d\n", pmd->fval, pmd->count);
}
fp = fopen(fname, "w"); fp = fopen(fname, "w");
if (NULL==fp) { if (NULL==fp) {
perror(fname); perror(fname);
@ -96,7 +111,7 @@ filehead.t = fimg->type;
/* XXX metadata */ /* XXX metadata */
if (NULL != pmd) { if (NULL != pmd) {
fprintf(stderr, "ok, %s give an 'a' flag\n", __func__);
filehead.magic[4] = 'a'; filehead.magic[4] = 'a';
} }
@ -108,8 +123,9 @@ if (1 != foo) {
return -2; return -2;
} }
/* XXX metadata */ /* we have metadata, put them on tape */
if (NULL != pmd) { if (NULL != pmd) {
fprintf(stderr, ">>> %s write metadata %p\n", __func__, pmd);
foo = fwrite(pmd, sizeof(FimgMetaData), 1, fp); foo = fwrite(pmd, sizeof(FimgMetaData), 1, fp);
if (1 != foo) { if (1 != foo) {
perror(fname); perror(fname);
@ -236,6 +252,12 @@ if ( (filehead.w != where->width) ||
/* XXX preparer la gestion des metadata */ /* XXX preparer la gestion des metadata */
if ('a' == filehead.magic[4]) { if ('a' == filehead.magic[4]) {
fprintf(stderr,"****** %s have metadata\n", fname); fprintf(stderr,"****** %s have metadata\n", fname);
foo = fseek(fp, (long)sizeof(FimgMetaData), SEEK_CUR);
if (foo) {
fprintf(stderr, "%s: seek error\n", __func__);
perror(fname);
exit(1);
}
} }
nbre = filehead.w * filehead.h; /* number of pixels per frame */ nbre = filehead.w * filehead.h; /* number of pixels per frame */
@ -274,7 +296,7 @@ fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, fname, head);
/* /*
* may be we can crash coredump here if the head * may be we can crash coredump here if the head
* descriptor is not blank ? * descriptor from calleris not blank ?
*/ */
fp = fopen(fname, "r"); fp = fopen(fname, "r");
@ -301,6 +323,19 @@ if (foo) {
return foo; return foo;
} }
/* bugfix Sat 14 May 2022 07:02:53 PM CEST */
/*
* Oh boy, we have to skeep the metadata chunck
*/
if ('a' == filehead.magic[4]) {
fprintf(stderr, "OMG %s metadata !!!\n", __func__);
foo = fseek(fp, (long)sizeof(FimgMetaData), SEEK_CUR);
if (foo) {
fprintf(stderr, "%s : shit hit the fan\n", __func__);
abort();
}
}
size = filehead.w * filehead.h; size = filehead.w * filehead.h;
nbread = 0; nbread = 0;
nbread += fread(head->R, sizeof(float), size, fp); nbread += fread(head->R, sizeof(float), size, fp);

View File

@ -37,6 +37,10 @@ fprintf(stderr, ">>> %s ( %p '%s' 0x%08x )\n", __func__,
pmd, title, notused); pmd, title, notused);
#endif #endif
if (NULL != title) {
fprintf(stderr, "==== metadate for %s\n", title);
}
if (verbosity) { if (verbosity) {
fprintf(stderr, "sizeof(metadata) = %ld\n", \ fprintf(stderr, "sizeof(metadata) = %ld\n", \
sizeof(FimgMetaData)); sizeof(FimgMetaData));
@ -49,8 +53,8 @@ doubletime = (double)pmd->timestamp.tv_sec + \
(double)pmd->timestamp.tv_usec / 1e6; (double)pmd->timestamp.tv_usec / 1e6;
fprintf(stderr, "dtime of day = %e\n", doubletime); fprintf(stderr, "dtime of day = %e\n", doubletime);
fprintf(stderr, "creator pid = %ld\n", pmd->cpid); fprintf(stderr, "creator pid = %ld\n", pmd->cpid);
fprintf(stderr, "counter = %d\n", pmd->count);
fprintf(stderr, "float value = %.3f\n", pmd->fval); fprintf(stderr, "float value = %.3f\n", pmd->fval);
fprintf(stderr, "counter = %d\n", pmd->count);
fprintf(stderr, "id camera = '%s'\n", pmd->idcam); fprintf(stderr, "id camera = '%s'\n", pmd->idcam);
fprintf(stderr, "origin = 0x%x\n", pmd->origin); fprintf(stderr, "origin = 0x%x\n", pmd->origin);
@ -63,7 +67,7 @@ fputc('\n', stderr);
return 0; return 0;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int fimg_default_metadata(FimgMetaData *pmd) int fimg_default_metadata(FimgMetaData *pmd, int bla)
{ {
int foo; int foo;
struct timeval tvl; struct timeval tvl;
@ -80,18 +84,20 @@ if (foo) {
perror("omg"); perror("omg");
} }
else { else {
if (verbosity) { if (verbosity > 1) {
fprintf(stderr, "Time of day %12ld %12ld\n", \ fprintf(stderr, " set TimeOfDay to %12ld , %8ld\n", \
tvl.tv_sec, tvl.tv_usec); tvl.tv_sec, tvl.tv_usec);
} }
memcpy(&(pmd->timestamp), &tvl, sizeof(struct timeval)); memcpy(&(pmd->timestamp), &tvl, sizeof(struct timeval));
} }
pmd->cpid = getpid(); pmd->cpid = getpid(); // we are the creator, no ?
pmd->count = 0; pmd->count = 1; // mmmm...
pmd->fval = 255.0; pmd->fval = 255.0; // Ok
strcpy(pmd->idcam, "<unknow>"); strcpy(pmd->idcam, "<noname>");
pmd->origin = 0xdeadbeef; pmd->origin = 0xdeadbeef; // classic joke, sorry
pmd->reserved[0] = bla;
pmd->reserved[7] = 0x55445544; // magic number is a crime
return 0; return 0;
} }

View File

@ -33,7 +33,8 @@ fimgops: fimgops.c $(DEPS)
gcc $(COPT) $< ../libfloatimg.a -o $@ gcc $(COPT) $< ../libfloatimg.a -o $@
fimgfx: fimgfx.c $(DEPS) fimgfx: fimgfx.c $(DEPS)
gcc $(COPT) $< ../libfloatimg.a -lm -o $@ gcc $(COPT) $< ../libfloatimg.a \
-ltiff -lpnglite -lcfitsio -lm -o $@
fimghalfsize: fimghalfsize.c $(DEPS) fimghalfsize: fimghalfsize.c $(DEPS)
gcc $(COPT) $< ../libfloatimg.a -lm -o $@ gcc $(COPT) $< ../libfloatimg.a -lm -o $@

View File

@ -40,8 +40,10 @@ ne sont gérés que de façon très rudimentaire.
## fimg2text ## fimg2text
Nouveau de l'année 2020+1 : exfiltrer toutes des données d'une image flottante Nouveau de l'année 2020+1 : exfiltrer toutes des données d'une image flottante
afin de les rendre machinables. afin de les rendre machinables. Voir aussi *fimgmetadata*.
## fimgmetadata ## fimgmetadata
Nouveau avril 2022. Need more doc... Nouveau avril 2022. Need more doc...
Voir aussi *fimg2text*.

View File

@ -6,8 +6,18 @@
# ----------------------------------------------------- # -----------------------------------------------------
TMPF="../funcs/in.fimg" TMPF="bar.fimg"
# -----------------------------------------------------
function essai_metadata
{
echo " ____ essai metadata ________"
./mkfimg -v -m -t hdeg $TMPF 800 600
echo ; echo
./fimgstats $TMPF
echo ; echo
./fimgmetadata all $TMPF
}
# ----------------------------------------------------- # -----------------------------------------------------
function essai_rot90 function essai_rot90
{ {
@ -53,6 +63,6 @@ function essai_hilight
} }
# ----------------------------------------------------- # -----------------------------------------------------
essai_hilight essai_metadata
# ----------------------------------------------------- # -----------------------------------------------------

View File

@ -262,8 +262,8 @@ switch (action) {
} }
// foo = fimg_export_picture(&dest, dstfname, 0); foo = fimg_export_picture(&dest, dstfname, 0);
foo = fimg_dump_to_file(&dest, dstfname, 0); // foo = fimg_dump_to_file(&dest, dstfname, 0);
if (foo) { if (foo) {
fprintf(stderr, "dumping datas to file '%s' give us a %d\n", fprintf(stderr, "dumping datas to file '%s' give us a %d\n",
dstfname, foo); dstfname, foo);

View File

@ -73,7 +73,7 @@ action = lookup_cmd(command);
switch(action) { switch(action) {
case C_timestamp: case C_timestamp:
printf("ts %ld\n", metadata.timestamp.tv_sec); break; printf("timestamp %ld\n", metadata.timestamp.tv_sec); break;
case C_count: case C_count:
printf("count %d\n", metadata.count); break; printf("count %d\n", metadata.count); break;
case C_fval: case C_fval:

View File

@ -10,7 +10,6 @@
#include "../floatimg.h" #include "../floatimg.h"
int verbosity; /* global */ int verbosity; /* global */
int make_csv; int make_csv;
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
@ -108,6 +107,9 @@ fputs( "usage : fimgstats [options] file.fimg\n"
"\t-c\tmake a machinable csv\n" "\t-c\tmake a machinable csv\n"
"\t-v\tincrease verbosity\n" "\t-v\tincrease verbosity\n"
, stderr); , stderr);
if (k) {
fimg_print_version(k);
}
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int main(int argc, char *argv[]) int main(int argc, char *argv[])

View File

@ -181,7 +181,7 @@ switch(type) {
if (wrmdata) { if (wrmdata) {
// fprintf(stderr, "%s: warning, metadata is bogus\n", argv[0]); // fprintf(stderr, "%s: warning, metadata is bogus\n", argv[0]);
(void)fimg_default_metadata(&metadata); (void)fimg_default_metadata(&metadata, 9);
sprintf(metadata.idcam, "mkfimg (libv %d)", FIMG_VERSION); sprintf(metadata.idcam, "mkfimg (libv %d)", FIMG_VERSION);
foo = fimg_dumpmd_to_file(&fimg, fname, &metadata, 0); foo = fimg_dumpmd_to_file(&fimg, fname, &metadata, 0);
#if DEBUG_LEVEL #if DEBUG_LEVEL

View File

@ -2,11 +2,24 @@
# ----------------------------------------------------- # -----------------------------------------------------
TMPF="tmp.fimg" FIMG="bar.fimg"
CAM="/dev/video0" CAM="/dev/video0"
# ----------------------------------------------------- clear
./grabvidseq -d $CAM -n 10000 -vv -p 0 -r 90 # -----------------------------------------------------
SEQ=" -n 60 -p 0 "
./grabvidseq -vv -m -d $CAM $SEQ -o $FIMG
echo ; echo ================= STATS ======================
../tools/fimgstats -v $FIMG
exit
echo
echo ================ METADATA ====================
../tools/fimgmetadata -v timestamp $FIMG
echo
../tools/fimgmetadata -v all $FIMG
# ----------------------------------------------------- # -----------------------------------------------------

View File

@ -80,6 +80,7 @@ if (verbosity) {
puts("options :"); puts("options :");
puts("\t-d /dev/?\tselect video device"); puts("\t-d /dev/?\tselect video device");
puts("\t-g\t\tconvert to gray"); puts("\t-g\t\tconvert to gray");
puts("\t-m\t\ttry to add metadata");
puts("\t-n NNN\t\thow many frames ?"); puts("\t-n NNN\t\thow many frames ?");
puts("\t-O ./\t\tset Output dir"); puts("\t-O ./\t\tset Output dir");
puts("\t-o bla.xxx\tset output filename"); puts("\t-o bla.xxx\tset output filename");
@ -90,7 +91,7 @@ puts("\t-c mode\t\tcontrast enhancement");
puts("\t-u\t\ttry upscaling..."); puts("\t-u\t\ttry upscaling...");
puts("\t-v\t\tincrease verbosity"); puts("\t-v\t\tincrease verbosity");
puts("\t-Z\t\tenable systrace"); puts("\t-Z\t\tenable systrace");
if (verbosity) { if (verbosity > 1) {
puts("\n\t\tXXX list all the contrast modes, please\n"); puts("\n\t\tXXX list all the contrast modes, please\n");
} }
exit(0); exit(0);
@ -125,13 +126,15 @@ int upscaling = 0;
int contrast = CONTRAST_NONE; int contrast = CONTRAST_NONE;
int rotfactor = 0; /* only 0 or 90 here */ int rotfactor = 0; /* only 0 or 90 here */
char *dest_dir = "."; /* no trailing slash */ char *dest_dir = "."; /* no trailing slash */
char *outfile = "out.pnm"; char *outfile = "out.fimg";
int add_metadata = 0;
FimgMetaData metadata;
#if SAVE_AS_CUMUL #if SAVE_AS_CUMUL
FloatImg cumul, tmpfimg, *to_save; FloatImg cumul, tmpfimg, *to_save;
#endif #endif
while ((opt = getopt(argc, argv, "c:d:ghn:o:O:p:r:s:uvZ")) != -1) { while ((opt = getopt(argc, argv, "c:d:ghmn:o:O:p:r:s:uvZ")) != -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) {
@ -142,6 +145,7 @@ while ((opt = getopt(argc, argv, "c:d:ghn:o:O:p:r:s:uvZ")) != -1) {
case 'd': dev_name = optarg; break; case 'd': dev_name = optarg; break;
case 'g': to_gray = 1; break; case 'g': to_gray = 1; break;
case 'h': help(0); break; case 'h': help(0); break;
case 'm': add_metadata++; break;
case 'n': nbre_capt = atoi(optarg); break; case 'n': nbre_capt = atoi(optarg); break;
case 'O': dest_dir = optarg; break; case 'O': dest_dir = optarg; break;
case 'o': outfile = optarg; break; case 'o': outfile = optarg; break;
@ -386,11 +390,21 @@ if (90 == rotfactor) {
to_save = &tmpfimg; 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:
foo = fimg_dump_to_file(to_save, outfile, 0); fimg_default_metadata(&metadata, 51);
/* copy some values to mdstruct */
metadata.fval = to_save->fval;
metadata.count = to_save->count;
if (add_metadata) {
fprintf(stderr, ">>> save %s with md\n", outfile);
foo = fimg_dumpmd_to_file(to_save, outfile, \
&metadata, 0);
}
else {
foo = fimg_dump_to_file(to_save, outfile, 0);
}
break; break;
case FILE_TYPE_PNM: case FILE_TYPE_PNM:
foo = fimg_save_as_pnm(to_save, outfile, 1); foo = fimg_save_as_pnm(to_save, outfile, 1);