planomuxer: step 1

This commit is contained in:
tth 2021-05-26 11:31:52 +02:00
parent 468b5feb74
commit b2d2c45be1
4 changed files with 126 additions and 3 deletions

1
.gitignore vendored
View File

@ -84,4 +84,5 @@ experiment/extracteur
experiment/*.fimg experiment/*.fimg
experiment/*.pnm experiment/*.pnm
experiment/*.o experiment/*.o
experiment/muxplanes

View File

@ -6,10 +6,13 @@ COPT = -Wall -fpic -g -DDEBUG_LEVEL=1 -lm
DEPS = ../floatimg.h ../libfloatimg.a Makefile DEPS = ../floatimg.h ../libfloatimg.a Makefile
LIBS = -ltiff -lpnglite -lcfitsio LIBS = -ltiff -lpnglite -lcfitsio
all: assemblage extracteur all: assemblage extracteur muxplanes
assemblage: assemblage.c ${DEPS} assemblage: assemblage.c ${DEPS}
gcc $(COPT) $< ../libfloatimg.a $(LIBS) -o $@ gcc $(COPT) $< ../libfloatimg.a ${LIBS} -o $@
extracteur: extracteur.c ${DEPS} 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 $@

97
experiment/muxplanes.c Normal file
View File

@ -0,0 +1,97 @@
/*
* another ugly experiment
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <strings.h>
#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;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */

22
experiment/tripla.sh Executable file
View File

@ -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