From ccd324749ecd993c7c03abc6c6d1b9cfc4c9ead6 Mon Sep 17 00:00:00 2001 From: tTh Date: Sat, 8 Jan 2022 17:48:18 +0100 Subject: [PATCH 1/5] first external contrib --- .gitignore | 3 ++ README.md | 4 +++ contrib/Makefile | 7 ++++ contrib/README.md | 4 +++ contrib/fimg2povhf.c | 82 ++++++++++++++++++++++++++++++++++++++++++++ floatimg.h | 2 +- v4l2/funcs.c | 1 + 7 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 contrib/Makefile create mode 100644 contrib/README.md create mode 100644 contrib/fimg2povhf.c diff --git a/.gitignore b/.gitignore index b3ae1751..d3d75320 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ lib/*.gif *.a gmon.out +*.swp + *.pnm *.fimg essai @@ -88,4 +90,5 @@ experiment/muxplanes experiment/movepixels experiment/tcache +contrib/fimg2povhf diff --git a/README.md b/README.md index 13992452..e38f08b9 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,10 @@ apt install libv4l2-dev apt install libcfitsio-dev apt install libnetpbm-dev ``` +Il est probable que j'en oublient. Ensuite, j'ai dans l'idée de construire +um met-packet à la sauce Debian pour installer facilement tout ce +qui sert à faire fonctionner ce kluge. Ensuite, j'irais voir du +coté de pkg-config. Certains outils externes sont aussi utiles : diff --git a/contrib/Makefile b/contrib/Makefile new file mode 100644 index 00000000..bbb489b4 --- /dev/null +++ b/contrib/Makefile @@ -0,0 +1,7 @@ + +DBGL = '-DDEBUG_LEVEL=1' + +fimg2povhf: fimg2povhf.c Makefile + gcc -Wall $(DBGL) $< -limage -lfloatimg -lm -o $@ + + diff --git a/contrib/README.md b/contrib/README.md new file mode 100644 index 00000000..e3bba648 --- /dev/null +++ b/contrib/README.md @@ -0,0 +1,4 @@ +# Contributions + +Need some external garbage, sorry. + diff --git a/contrib/fimg2povhf.c b/contrib/fimg2povhf.c new file mode 100644 index 00000000..d667a234 --- /dev/null +++ b/contrib/fimg2povhf.c @@ -0,0 +1,82 @@ +/* + * convertir une image flottante en champ d'altitude + * + * nouveau 64 ernest renan - 20220108 + */ + +#include +#include + +#include "tthimage.h" +#include "floatimg.h" + +int verbosity; + +/* ------------------------------------------------------------------ */ +int This_is_the_real_conversion(FloatImg *fimg, Image_Desc *hf, int k) +{ +FloatImg mixed; +int foo; +float minmax[6]; + + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, fimg, hf, k); +#endif + +foo = fimg_get_minmax_rgb(fimg, minmax); +fimg_print_minmax(minmax, "source"); + +return FULL_NUCKED; +} +/* ------------------------------------------------------------------ */ +int Convertir_Fimg_to_Povhf(char *fimgname, char *hfname, int k) +{ +FloatImg fimg; +Image_Desc *hf; +int wid, hei; +int foo; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %s %s %d )\n", __func__, fimgname, hfname, k); +#endif + +foo = fimg_create_from_dump(fimgname, &fimg); +fprintf(stderr, "load of %s --> %d\n", fimgname, foo); +if (foo) { + return foo; + } + +wid = fimg.width; hei = fimg.height; // nice alias +fprintf(stderr, "picture size %dx%d\n", wid, hei); + +hf = Image_alloc(wid, hei, IMAGE_RGB); +fprintf(stderr, "hf alloc -> %p\n", hf); +if (NULL == hf) { + return NULL_POINTER; + } + +foo = This_is_the_real_conversion(&fimg, hf, k); +fprintf(stderr, "real conversion -> %d\n", foo); + +return FULL_NUCKED; +} +/* ------------------------------------------------------------------ */ + +int main(int argc, char *argv[]) +{ +int foo; + +verbosity = 1; + +Image_print_version(3); +fimg_print_version(3); + + +foo = Convertir_Fimg_to_Povhf("foo.fimg", "out.tga", 0); +fprintf(stderr, "retour conversion was %d\n", foo); + +return 0; +} + +/* ------------------------------------------------------------------ */ diff --git a/floatimg.h b/floatimg.h index ac73feec..9450db25 100644 --- a/floatimg.h +++ b/floatimg.h @@ -4,7 +4,7 @@ * http://la.buvette.org/photos/cumul */ -#define FIMG_VERSION 164 +#define FIMG_VERSION 166 /* * in memory descriptor diff --git a/v4l2/funcs.c b/v4l2/funcs.c index a4474523..9fe97e60 100644 --- a/v4l2/funcs.c +++ b/v4l2/funcs.c @@ -5,6 +5,7 @@ #include #include #include +#include #include /* low-level i/o */ #include From a8d1e18650f35d8a6c3d35ff0a28570c0118688d Mon Sep 17 00:00:00 2001 From: tTh Date: Sat, 8 Jan 2022 21:51:31 +0100 Subject: [PATCH 2/5] Ok, this writz is working --- .gitignore | 5 ++++- contrib/Makefile | 2 +- contrib/README.md | 8 +++++++ contrib/fimg2povhf.c | 50 +++++++++++++++++++++++++++++++++++++------- contrib/raytrace.sh | 30 ++++++++++++++++++++++++++ contrib/scene.pov | 40 +++++++++++++++++++++++++++++++++++ 6 files changed, 125 insertions(+), 10 deletions(-) create mode 100755 contrib/raytrace.sh create mode 100644 contrib/scene.pov diff --git a/.gitignore b/.gitignore index d3d75320..b8315fe9 100644 --- a/.gitignore +++ b/.gitignore @@ -91,4 +91,7 @@ experiment/movepixels experiment/tcache contrib/fimg2povhf - +contrib/*.tga +contrib/pov.stderr +contrib/*.png +contrib/*.gif diff --git a/contrib/Makefile b/contrib/Makefile index bbb489b4..4e8f418c 100644 --- a/contrib/Makefile +++ b/contrib/Makefile @@ -1,5 +1,5 @@ -DBGL = '-DDEBUG_LEVEL=1' +DBGL = '-DDEBUG_LEVEL=1 -g ' fimg2povhf: fimg2povhf.c Makefile gcc -Wall $(DBGL) $< -limage -lfloatimg -lm -o $@ diff --git a/contrib/README.md b/contrib/README.md index e3bba648..b4be3318 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -1,4 +1,12 @@ # Contributions +## fimg2povhf + Need some external garbage, sorry. +Try to compile this really old code: + http://la.buvette.org/devel/libimage/libimage.html + +Use the code, frtk ! + + diff --git a/contrib/fimg2povhf.c b/contrib/fimg2povhf.c index d667a234..b5762a66 100644 --- a/contrib/fimg2povhf.c +++ b/contrib/fimg2povhf.c @@ -5,6 +5,7 @@ */ #include +#include #include #include "tthimage.h" @@ -15,17 +16,33 @@ int verbosity; /* ------------------------------------------------------------------ */ int This_is_the_real_conversion(FloatImg *fimg, Image_Desc *hf, int k) { -FloatImg mixed; int foo; float minmax[6]; - +int x, y, h; +float rgb[6], cumul; +float maxi; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, fimg, hf, k); #endif foo = fimg_get_minmax_rgb(fimg, minmax); -fimg_print_minmax(minmax, "source"); +// fimg_print_minmax(minmax, "source"); + +maxi = 0.0; + +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { + foo = fimg_get_rgb(fimg, x, y, rgb); + /* non-magic nuabmer spotted */ + cumul = 1.732 * (rgb[1] + rgb[3] + rgb[5]); + if (cumul > maxi) maxi = cumul; + h = (int)cumul; + foo = Image_hf15_plot(hf, x, y, h); + } + } + +fprintf(stderr, "--- the critical maximum is %f\n", maxi); return FULL_NUCKED; } @@ -36,7 +53,6 @@ FloatImg fimg; Image_Desc *hf; int wid, hei; int foo; - #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( %s %s %d )\n", __func__, fimgname, hfname, k); #endif @@ -48,7 +64,7 @@ if (foo) { } wid = fimg.width; hei = fimg.height; // nice alias -fprintf(stderr, "picture size %dx%d\n", wid, hei); +fprintf(stderr, " source picture size %dx%d\n", wid, hei); hf = Image_alloc(wid, hei, IMAGE_RGB); fprintf(stderr, "hf alloc -> %p\n", hf); @@ -59,9 +75,18 @@ if (NULL == hf) { foo = This_is_the_real_conversion(&fimg, hf, k); fprintf(stderr, "real conversion -> %d\n", foo); +foo = Image_TGA_save(hfname, hf, 0); +fprintf(stderr, "export as tga -> %d\n", foo); + return FULL_NUCKED; } /* ------------------------------------------------------------------ */ +void help(int nu) +{ +printf("usage :\n"); +printf("\t$ fimg2povhf src.fimg dst.tga\n"); +} +/* ------------------------------------------------------------------ */ int main(int argc, char *argv[]) { @@ -69,13 +94,22 @@ int foo; verbosity = 1; -Image_print_version(3); -fimg_print_version(3); +// printf("%s: argc = %d\n", argv[0], argc); +if (3 != argc) { + help(0); + exit(0); + } -foo = Convertir_Fimg_to_Povhf("foo.fimg", "out.tga", 0); +if (verbosity > 1) { + Image_print_version(3); + fimg_print_version(3); + } + +foo = Convertir_Fimg_to_Povhf(argv[1], argv[2], 0); fprintf(stderr, "retour conversion was %d\n", foo); +fprintf(stderr, "end\n\n"); return 0; } diff --git a/contrib/raytrace.sh b/contrib/raytrace.sh new file mode 100755 index 00000000..b18fe4eb --- /dev/null +++ b/contrib/raytrace.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +src="/dev/shm/foo.fimg" +dst="hf.tga" + +POVOPT="-w512 -h342 +q9 -a " + +rm /tmp/hf???.png + +for idx in $(seq 0 24) +do + + echo "========================== " $idx + + grabvidseq -v \ + -d /dev/video0 -s 640x480 \ + -n 20 -p 0 \ + -o ${src} + + ./fimg2povhf $src $dst + + out=$(printf "/tmp/hf%03d.png" $idx) + echo "raytracing " ${POVOPT} $out + povray -iscene.pov ${POVOPT} -o${out} 2> pov.stderr + # tail -15 pov.stderr + +done + +convert -delay 10 -colors 240 /tmp/hf???.png foo.gif + diff --git a/contrib/scene.pov b/contrib/scene.pov new file mode 100644 index 00000000..1703c7a0 --- /dev/null +++ b/contrib/scene.pov @@ -0,0 +1,40 @@ + +/* scene demo conversion floatimg -> height field */ + +#version 3.7; + +global_settings { + ambient_light rgb <0.07, 0.07, 0.07> + assumed_gamma 1.0 + } + +#include "colors.inc" + +height_field { + tga "hf.tga" + smooth + pigment { color Orange*0.5 } + translate <-0.5, 0, -0.5> + scale 2 + translate y*0.01 + } + +camera { + location <-0.86, 3, -6.20> + look_at <0, 0, 0> + angle 14 + } + +plane { + <0, 1, 0>, 0 + pigment { + hexagon + pigment { color Gray20 }, + pigment { color Gray10 }, + pigment { color Gray30 } + } + scale 0.27 + } + + +light_source { <-9, 2, -3> color White } From 4c38ff032acb873980e4a50a3bbdb3664592d5d8 Mon Sep 17 00:00:00 2001 From: tTh Date: Sun, 9 Jan 2022 09:32:39 +0100 Subject: [PATCH 3/5] fine tuning the 3d contrib --- contrib/raytrace.sh | 11 ++++++----- contrib/scene.pov | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/contrib/raytrace.sh b/contrib/raytrace.sh index b18fe4eb..2c9f3114 100755 --- a/contrib/raytrace.sh +++ b/contrib/raytrace.sh @@ -2,29 +2,30 @@ src="/dev/shm/foo.fimg" dst="hf.tga" +TMPDIR=${HOME}/TMP POVOPT="-w512 -h342 +q9 -a " -rm /tmp/hf???.png +rm $TMPDIR/hf???.png -for idx in $(seq 0 24) +for idx in $(seq 0 60) do echo "========================== " $idx grabvidseq -v \ -d /dev/video0 -s 640x480 \ - -n 20 -p 0 \ + -n 60 -p 1.0 \ -o ${src} ./fimg2povhf $src $dst - out=$(printf "/tmp/hf%03d.png" $idx) + out=$(printf "%s/hf%03d.png" $TMPDIR $idx) echo "raytracing " ${POVOPT} $out povray -iscene.pov ${POVOPT} -o${out} 2> pov.stderr # tail -15 pov.stderr done -convert -delay 10 -colors 240 /tmp/hf???.png foo.gif +convert -delay 10 -colors 240 $TMPDIR/hf???.png foo.gif diff --git a/contrib/scene.pov b/contrib/scene.pov index 1703c7a0..adb74eca 100644 --- a/contrib/scene.pov +++ b/contrib/scene.pov @@ -13,14 +13,14 @@ global_settings { height_field { tga "hf.tga" smooth - pigment { color Orange*0.5 } + pigment { color Orange*0.7 } translate <-0.5, 0, -0.5> - scale 2 - translate y*0.01 + // scale 2 + translate y*0.002 } camera { - location <-0.86, 3, -6.20> + location <-0.86, 4, -6.20> look_at <0, 0, 0> angle 14 } @@ -37,4 +37,5 @@ plane { } -light_source { <-9, 2, -3> color White } +light_source { <-9, 2, 3> color White } + From e7e3713972fc635e02e51372187f35166d481167 Mon Sep 17 00:00:00 2001 From: tTh Date: Tue, 11 Jan 2022 10:00:29 +0100 Subject: [PATCH 4/5] calm down a non essential message --- funcs/filtrage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/funcs/filtrage.c b/funcs/filtrage.c index 28b55061..47015fe7 100644 --- a/funcs/filtrage.c +++ b/funcs/filtrage.c @@ -63,7 +63,7 @@ if (fimg_images_not_compatible(src, dst)) { return -98; } -if (verbosity) { +if (verbosity > 1) { fimg_show_filter("essai", filtr); } From c61251ad53e2b379dde2d441a55d3db0d93adf85 Mon Sep 17 00:00:00 2001 From: tTh Date: Fri, 21 Jan 2022 14:43:52 +0100 Subject: [PATCH 5/5] adding -ln --- experiment/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/experiment/Makefile b/experiment/Makefile index 829cf74b..0dd4f03f 100644 --- a/experiment/Makefile +++ b/experiment/Makefile @@ -5,7 +5,7 @@ COPT = -Wall -fpic -g -DDEBUG_LEVEL=1 -lm DEPS = ../floatimg.h ../libfloatimg.a Makefile -LIBS = ../libfloatimg.a -ltiff -lpnglite -lcfitsio +LIBS = ../libfloatimg.a -ltiff -lpnglite -lcfitsio -lm all: assemblage extracteur muxplanes movepixels