From b2d2c45be172eefab0b68d6327b546fad2351694 Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 26 May 2021 11:31:52 +0200 Subject: [PATCH] planomuxer: step 1 --- .gitignore | 1 + experiment/Makefile | 9 ++-- experiment/muxplanes.c | 97 ++++++++++++++++++++++++++++++++++++++++++ experiment/tripla.sh | 22 ++++++++++ 4 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 experiment/muxplanes.c create mode 100755 experiment/tripla.sh diff --git a/.gitignore b/.gitignore index 07b608f..36c902e 100644 --- a/.gitignore +++ b/.gitignore @@ -84,4 +84,5 @@ experiment/extracteur experiment/*.fimg experiment/*.pnm experiment/*.o +experiment/muxplanes diff --git a/experiment/Makefile b/experiment/Makefile index 708d9c8..67dd901 100644 --- a/experiment/Makefile +++ b/experiment/Makefile @@ -6,10 +6,13 @@ COPT = -Wall -fpic -g -DDEBUG_LEVEL=1 -lm DEPS = ../floatimg.h ../libfloatimg.a Makefile LIBS = -ltiff -lpnglite -lcfitsio -all: assemblage extracteur +all: assemblage extracteur muxplanes assemblage: assemblage.c ${DEPS} - gcc $(COPT) $< ../libfloatimg.a $(LIBS) -o $@ + gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@ extracteur: extracteur.c ${DEPS} - gcc $(COPT) $< ../libfloatimg.a $(LIBS) -o $@ + gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@ + +muxplanes: muxplanes.c ${DEPS} + gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@ diff --git a/experiment/muxplanes.c b/experiment/muxplanes.c new file mode 100644 index 0000000..bd01e54 --- /dev/null +++ b/experiment/muxplanes.c @@ -0,0 +1,97 @@ +/* + * another ugly experiment + */ +#include +#include +#include +#include +#include + +#include "../floatimg.h" + +int verbosity; + +/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */ + +int triplane_muxer(FloatImg *sr, FloatImg *sg, FloatImg *sb, + FloatImg *dst, int flages) +{ +int foo; +int sz; + +if (FIMG_TYPE_RGB != dst->type) { + fprintf(stderr, "%s: dst picz must be RGB, was %d\n", + __func__, dst->type); + return -99; + } + +if ( fimg_images_not_compatible(sr, sg) || + fimg_images_not_compatible(sr, sb) || + fimg_images_not_compatible(sr, dst) ) { + fprintf(stderr, "%s: compatibility error\n", __func__); + return -2; + } + +sz = sr->width * sr->height * sizeof(float); + +memcpy(dst->R, sr->R, sz); +memcpy(dst->G, sg->G, sz); +memcpy(dst->B, sb->B, sz); + +return 0; +} +/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */ +int try_this_muxplane(char *fr, char *fg, char *fb, char *dst, int flags) +{ +int foo; +FloatImg imr, img, imb, dest; + +fprintf(stderr, "muxing: %s %s %s --> %s\n", fr, fg, fb, dst); + +foo = fimg_create_from_dump(fr, &imr); +if (foo) { + fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr); + return -1; + } +foo = fimg_create_from_dump(fg, &img); +if (foo) { + fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr); + return -1; + } +foo = fimg_create_from_dump(fb, &imb); +if (foo) { + fprintf(stderr, "%s: err %d loading %s\n", __func__, foo, fr); + return -1; + } + +fimg_clone(&imr, &dest, 0); + +foo = triplane_muxer(&imr, &img, &imb, &dest, 0); +if (foo) { + fprintf(stderr, "%s: err %d\n", __func__, foo); + return foo; + } + +fimg_export_picture(&dest, dst, 0); + +return 0; +} +/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */ +int main(int argc, char *argv[]) +{ +int foo; + +if (5 != argc) { + fprintf(stderr, "ERROR: %s need four fimg files arguments\n", argv[0]); + return 1; + } + +foo = try_this_muxplane(argv[1], argv[2], argv[3], argv[4], 0); +if (foo) { + fprintf(stderr, "oups %d\n", foo); + exit(1); + } + +return 0; +} +/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */ diff --git a/experiment/tripla.sh b/experiment/tripla.sh new file mode 100755 index 0000000..e04184d --- /dev/null +++ b/experiment/tripla.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +GRABOPT=" -v -d /dev/video0 -n 1 -u " +SPOOL=${HOME}/TMP + +for capture in red green blue +do + grabvidseq "${GRABOPT}" -o "${SPOOL}/${capture}.fimg" + # sleep 1 +done + +ls -rtl "${SPOOL}" + +./muxplanes "${SPOOL}/red.fimg" \ + "${SPOOL}/green.fimg" \ + "${SPOOL}/blue.fimg" \ + yo.fimg + +echo $0 "got a" $? + +fimgstats -v yo.fimg +