Compare commits

..

4 Commits

Author SHA1 Message Date
phyto
b8d86da9a0 allons plutot boire un casanis... 2019-07-03 18:51:42 +02:00
phyto
9c845b5d04 rien n'est simple, mais il faut avancer 2019-07-03 15:29:24 +02:00
phyto
47ec3c8ab5 Oups.... 2019-07-03 14:54:23 +02:00
phyto
22a014b676 testing v4l2 pretty struct pointer 2019-07-02 22:23:12 +02:00
8 changed files with 76 additions and 16 deletions

1
.gitignore vendored
View File

@ -25,3 +25,4 @@ tools/mkfimg
tools/png2fimg
tools/addtga2fimg
tools/addpnm2fimg
tools/cumulfimgs

View File

@ -2,7 +2,7 @@
* floatimg.h
*/
#define FIMG_VERSION 60
#define FIMG_VERSION 61
/*
* in memory descriptor

View File

@ -3,34 +3,37 @@
# use with caution
#
COPT = -Wall -fpic -g -DDEBUG_LEVEL=1
COPT = -Wall -fpic -g -DDEBUG_LEVEL=0
DEPS = ../floatimg.h ../libfloatimg.a Makefile
# ----------
all: fimg2pnm addtga2fimg mkfimg png2fimg fimgstats fimg2png \
addpnm2fimg
addpnm2fimg cumulfimgs
fimgstats: fimgstats.c $(DEPS)
gcc -g $< ../libfloatimg.a -o $@
gcc $(COPT) $< ../libfloatimg.a -o $@
cumulfimgs: cumulfimgs.c $(DEPS)
gcc $(COPT) $< ../libfloatimg.a -o $@
mkfimg: mkfimg.c $(DEPS)
gcc -g $< ../libfloatimg.a -o $@
gcc $(COPT) $< ../libfloatimg.a -o $@
fimg2pnm: fimg2pnm.c $(DEPS)
gcc -g $< ../libfloatimg.a -o $@
gcc $(COPT) $< ../libfloatimg.a -o $@
fimg2png: fimg2png.c $(DEPS)
gcc -g $< ../libfloatimg.a -o $@
gcc $(COPT) $< ../libfloatimg.a -o $@
addtga2fimg: addtga2fimg.c $(DEPS)
gcc -g $< ../libfloatimg.a -limageSO -lm -o $@
gcc $(COPT) $< ../libfloatimg.a -limageSO -lm -o $@
addpnm2fimg: addpnm2fimg.c $(DEPS)
gcc -g $< ../libfloatimg.a -lm -o $@
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
# if "undefined reference to crc32" then "use -lz"
png2fimg: png2fimg.c $(DEPS)
gcc -g $< ../libfloatimg.a -lpnglite -o $@
gcc $(COPT) $< ../libfloatimg.a -lpnglite -o $@

34
tools/cumulfimgs.c Normal file
View File

@ -0,0 +1,34 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../floatimg.h"
int verbosity;
/* --------------------------------------------------------------------- */
void help(int v)
{
puts("options :");
puts("\t-v\tincrease verbosity");
puts("\t-o\tname of output file");
if (verbosity) { puts(""); fimg_print_version(1); }
}
/* --------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
int opt;
char *output_file = "noname.fimg";
while ((opt = getopt(argc, argv, "ho:v")) != -1) {
switch(opt) {
case 'h': help(0); break;
case 'o': output_file = optarg; break;
case 'v': verbosity++; break;
}
}
return 0;
}
/* --------------------------------------------------------------------- */

View File

@ -1,3 +1,7 @@
/*
* conversion vers le format PNM
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -60,3 +64,4 @@ if (foo) fprintf(stderr, "conversion -> %d\n", foo);
return 0;
}
/* --------------------------------------------------------------------- */

View File

@ -20,14 +20,13 @@ if (4 != argc) {
}
fname = argv[1];
width = atoi(argv[2]); height = atoi(argv[3]);
fprintf(stderr, "making %s %d x %d\n", fname, width, height);
fprintf(stderr, "making '%s' %d x %d\n", fname, width, height);
foo = fimg_create(&fimg, width, height, 3);
if (foo) {
fprintf(stderr, "create floatimg -> %d\n", foo);
exit(1);
}
// fimg_describe(&fimg, "just a black flimg");
fimg_clear(&fimg);
foo = fimg_dump_to_file(&fimg, fname, 0);

View File

@ -7,6 +7,7 @@
#include <unistd.h>
#include <math.h>
#include <string.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>
@ -23,6 +24,7 @@ int essai(char *dev, int k)
{
int vfd, foo;
struct v4l2_format fmt;
struct v4l2_requestbuffers reqbuf;
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, dev, k);
@ -40,6 +42,19 @@ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
pr_v4l2_format("before ioctl", &fmt);
foo = ioctl(vfd, VIDIOC_S_FMT, &fmt);
fprintf(stderr, "ioctl -> %d\n", foo);
if (foo < 0) {
perror("ioctl S_FMT");
exit(1);
}
pr_v4l2_format("after ioctl", &fmt);
/* todo V4L2_BUF_TYPE_VIDEO_CAPTURE */
memset(&reqbuf, 0, sizeof(reqbuf));
pr_v4l2_requestbuffers("after 0", &reqbuf);
return k;
}
@ -58,6 +73,9 @@ puts("\t-d\tselect the video device");
puts("\t-K\tset the K parameter");
puts("\t-l\tlist video devices");
puts("\t-v\tincrease verbosity");
if (verbosity) { puts(""); fimg_print_version(1); }
exit(0);
}
/* --------------------------------------------------------------------- */

View File

@ -52,7 +52,7 @@ return 0;
/* --------------------------------------------------------------------- */
int pr_v4l2_requestbuffers(char *txt, struct v4l2_requestbuffers *ptr)
{
fprintf(FP, "-- v4l2_requestbuffers, at %p\n", ptr);
fprintf(FP, "-- v4l2_requestbuffers, %s %p\n", txt, ptr);
fprintf(FP, " type %d\n", ptr->type); /* enum v4l2_buf_type */