metadata boilerplane, first milestone reached

This commit is contained in:
tth 2022-03-19 01:21:58 +01:00
parent 7ea77cc882
commit 039d4cb77b
20 changed files with 105 additions and 4 deletions

View File

@ -10,6 +10,7 @@
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -4,7 +4,7 @@
* http://la.buvette.org/photos/cumul * http://la.buvette.org/photos/cumul
*/ */
#define FIMG_VERSION 171 #define FIMG_VERSION 174
/* /*
* in memory descriptor * in memory descriptor
@ -28,6 +28,16 @@ typedef struct {
char magic[8]; char magic[8];
int32_t w, h, t; int32_t w, h, t;
} FimgFileHead; } FimgFileHead;
/*
* new 11 mars 2022
*/
typedef struct {
char magic[8];
struct timeval timestamp;
int32_t count;
float fval;
char idcam[32];
} FimgMetaData;
/* /*
* we MUST look at packing and endianess problems NOW */ * we MUST look at packing and endianess problems NOW */
@ -207,11 +217,14 @@ int fimg_displacement_0(FloatImg *psrc, FloatImg *pdst, int flags);
int fimg_hdeg_a(FloatImg *img, double dcoef); int fimg_hdeg_a(FloatImg *img, double dcoef);
int fimg_vdeg_a(FloatImg *img, double dcoef); int fimg_vdeg_a(FloatImg *img, double dcoef);
/* FIMG files module */ /* FIMG native file module */
int fimg_fileinfos(char *fname, int *datas); int fimg_fileinfos(char *fname, int *datas);
int fimg_dump_to_file(FloatImg *head, char *fname, int notused); int fimg_dump_to_file(FloatImg *head, char *fname, int notused);
int fimg_load_from_dump(char *fname, FloatImg *where); int fimg_load_from_dump(char *fname, FloatImg *where);
int fimg_create_from_dump(char *fname, FloatImg *head); int fimg_create_from_dump(char *fname, FloatImg *head);
/* FIMG metadata module */
int fimg_show_metadata(FimgMetaData *pmd, char *title, int notused);
int fimg_default_metadata(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);
int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags); int fimg_save_G_as_fits(FloatImg *src, char *outname, int flags);

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -9,6 +9,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include <fitsio.h> #include <fitsio.h>

View File

@ -8,6 +8,7 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -6,6 +6,7 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -4,6 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -6,6 +6,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -7,6 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -6,6 +6,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -10,6 +10,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -9,6 +9,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h>
#include "../floatimg.h" #include "../floatimg.h"

View File

@ -6,7 +6,8 @@ COPT = -Wall -Wextra -fpic -g -no-pie -DDEBUG_LEVEL=0
OBJS = fimg-core.o fimg-pnm.o fimg-file.o fimg-math.o \ OBJS = fimg-core.o fimg-pnm.o fimg-file.o fimg-math.o \
fimg-timers.o operators.o fimg-2gray.o \ fimg-timers.o operators.o fimg-2gray.o \
interpolate.o fimg-compare.o contrast.o interpolate.o fimg-compare.o contrast.o \
metadata.o
DEPS = Makefile ../floatimg.h DEPS = Makefile ../floatimg.h
@ -35,6 +36,9 @@ fimg-2gray.o: fimg-2gray.c $(DEPS)
operators.o: operators.c $(DEPS) operators.o: operators.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<
metadata.o: metadata.c $(DEPS)
gcc $(COPT) -c $<
contrast.o: contrast.c $(DEPS) contrast.o: contrast.c $(DEPS)
gcc $(COPT) -c $< gcc $(COPT) -c $<

View File

@ -46,6 +46,11 @@ if (memcmp(filehead.magic, "FIMG", 4)) {
return -3; return -3;
} }
/* XXX preparer la gestion des metadata */
if ('a' == filehead.magic[4]) {
fprintf(stderr,"****** %s have metadata\n", fname);
}
datas[0] = filehead.w; datas[0] = filehead.w;
datas[1] = filehead.h; datas[1] = filehead.h;
datas[2] = filehead.t; datas[2] = filehead.t;
@ -143,6 +148,11 @@ if ( (filehead.w != where->width) ||
return -17; return -17;
} }
/* XXX preparer la gestion des metadata */
if ('a' == filehead.magic[4]) {
fprintf(stderr,"****** %s have metadata\n", fname);
}
nbre = filehead.w * filehead.h; /* number of pixels per frame */ nbre = filehead.w * filehead.h; /* number of pixels per frame */
foo = fread(where->R, sizeof(float), nbre, fp); foo = fread(where->R, sizeof(float), nbre, fp);
if (nbre != foo) { if (nbre != foo) {

42
lib/metadata.c Normal file
View File

@ -0,0 +1,42 @@
/*
* metadata.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include "string.h"
#include "../floatimg.h"
extern int verbosity; /* must be declared around main() */
/* ---------------------------------------------------------------- */
int fimg_show_metadata(FimgMetaData *pmd, char *title, int notused)
{
fprintf(stderr, ">>> %s ( %p '%s' 0x%08x )\n", __func__,
pmd, title, notused);
fprintf(stderr, "sizeof metadata = %ld\n", sizeof(FimgMetaData));
fprintf(stderr, "magic = '%8s'\n", pmd->magic);
/* TIMESTAMP HERE */
fprintf(stderr, "counter = %d\n", pmd->count);
fprintf(stderr, "float value = %.3f\n", pmd->fval);
fprintf(stderr, "id camera = '%s'\n", pmd->idcam);
return -1;
}
/* ---------------------------------------------------------------- */
int fimg_default_metadata(FimgMetaData *pmd)
{
memcpy(pmd->magic, "metadata", 8);
pmd->count = 0;
pmd->fval = 255.0;
strcpy(pmd->idcam, "unknow");
return -1;
}
/* ---------------------------------------------------------------- */

19
lib/t.c
View File

@ -14,6 +14,20 @@
int verbosity; int verbosity;
/* ---------------------------------------------------------------- */
int essai_metadata(char *fname)
{
FimgMetaData Md;
int foo;
fprintf(stderr, "-------- %s ( %s ) --------\n", __func__, fname);
foo = fimg_default_metadata(&Md);
foo = fimg_show_metadata(&Md, "from t.c", 0);
return -1;
}
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
int essai_save_plane(int wot) int essai_save_plane(int wot)
{ {
@ -300,9 +314,12 @@ if (verbosity) {
fimg_print_sizeof(); fimg_print_sizeof();
} }
foo = essai_save_plane(0); foo = essai_metadata("foo.fimg");
fprintf(stderr, "retour essai -> %d\n", foo); fprintf(stderr, "retour essai -> %d\n", foo);
// foo = essai_save_plane(0);
// fprintf(stderr, "retour essai -> %d\n", foo);
// foo = essai_clone_et_copy(0); // foo = essai_clone_et_copy(0);
// fprintf(stderr, "retour essai clone'n'copy -> %d\n", foo); // fprintf(stderr, "retour essai clone'n'copy -> %d\n", foo);