Compare commits
7 Commits
776c3e9dbd
...
f0c704a818
Author | SHA1 | Date | |
---|---|---|---|
f0c704a818 | |||
cc6dd330ed | |||
7157ce47a3 | |||
d65b93fc66 | |||
7abdf7b43e | |||
144498d68e | |||
74496aa439 |
@ -200,10 +200,9 @@ dans \texttt{floatimg.h}. Les codes d'erreur sont disparates
|
||||
et non documenté.
|
||||
\vspace{1em}
|
||||
|
||||
|
||||
Bon, vous avez une image latente, et
|
||||
vous souhaité dessiner dessus (ou dedans ?) avec vos encres
|
||||
flottantes ?
|
||||
Bon, vous avez une image latente, et vous souhaitez dessiner dessus
|
||||
(ou dedans ?) avec vos encres flottantes ?
|
||||
Il y a une fonction pour ça.
|
||||
|
||||
\subsection{funcs/}\index{funcs/}\label{funcs}
|
||||
|
||||
|
27
essai.c
27
essai.c
@ -14,21 +14,11 @@
|
||||
int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
void fait_un_dessin(char *fname)
|
||||
void fait_un_dessin(FloatImg *dessin)
|
||||
{
|
||||
FloatImg dessin;
|
||||
double tb;
|
||||
|
||||
puts("");
|
||||
fimg_timer_set(0);
|
||||
fimg_create(&dessin, 3200, 2400, 3);
|
||||
fimg_draw_something(&dessin);
|
||||
fimg_dump_to_file(&dessin, "dessin.fimg", 0);
|
||||
fimg_destroy(&dessin);
|
||||
tb = fimg_timer_get(0);
|
||||
fprintf(stderr, "%s = %f seconds\n", __func__, tb);
|
||||
fimg_draw_something(dessin);
|
||||
|
||||
puts("");
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
void help(int k)
|
||||
@ -60,10 +50,17 @@ if (verbosity) fimg_print_version(0);
|
||||
fimg_create(&fimgA, W, H, 3);
|
||||
fimg_create(&fimgB, W, H, 3);
|
||||
|
||||
fimg_timer_set(0);
|
||||
fimg_drand48(&fimgB, 100.0);
|
||||
fimg_drand48(&fimgA, 100.0);
|
||||
fimg_add(&fimgA, &fimgB, &fimgA);
|
||||
fimg_timer_set(0);
|
||||
#define NBP 500
|
||||
for (foo=0; foo<NBP; foo++) {
|
||||
if (verbosity) {
|
||||
printf("%5d / %5d\n", foo, NBP);
|
||||
}
|
||||
fait_un_dessin(&fimgB);
|
||||
fimg_add(&fimgA, &fimgB, &fimgA);
|
||||
fimg_mul(&fimgA, &fimgB, &fimgA);
|
||||
}
|
||||
tb = fimg_timer_get(0);
|
||||
fprintf(stderr, "%s = %f seconds\n", __func__, tb);
|
||||
foo = fimg_save_as_pnm(&fimgA, "drand48.pnm", 0);
|
||||
|
@ -9,4 +9,11 @@
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
int essai_ecrire_tiff(FloatImg *src, char *fname)
|
||||
{
|
||||
|
||||
/* bon, tout cela semble bien tortueux ! */
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
@ -2,7 +2,7 @@
|
||||
# building the base library
|
||||
#
|
||||
|
||||
COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0
|
||||
COPT = -Wall -fpic -g -no-pie -pg -DDEBUG_LEVEL=0
|
||||
OBJS = fimg-core.o fimg-pnm.o fimg-file.o fimg-math.o \
|
||||
fimg-timers.o operators.o fimg-2gray.o
|
||||
DEPS = Makefile ../floatimg.h
|
||||
|
@ -117,9 +117,16 @@ int nbre, idx;
|
||||
fprintf(stderr, ">>> %s ( %p %g )\n", __func__, fi, kmul);
|
||||
#endif
|
||||
|
||||
nbre = fi->width * fi->height * fi->type;
|
||||
if (fi->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s : type %d invalide\n",
|
||||
__func__, fi->type);
|
||||
return;
|
||||
}
|
||||
nbre = fi->width * fi->height;
|
||||
for (idx=0; idx<nbre; idx++) {
|
||||
fi->R[idx] = drand48() * kmul;
|
||||
fi->G[idx] = drand48() * kmul;
|
||||
fi->B[idx] = drand48() * kmul;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ fimg2pnm: fimg2pnm.c $(DEPS)
|
||||
fimg2png: fimg2png.c $(DEPS)
|
||||
gcc $(COPT) $< ../libfloatimg.a -o $@
|
||||
|
||||
addtga2fimg: addtga2fimg.c $(DEPS)
|
||||
gcc $(COPT) $< ../libfloatimg.a -limageSO -lm -o $@
|
||||
# addtga2fimg: addtga2fimg.c $(DEPS)
|
||||
# gcc $(COPT) $< ../libfloatimg.a -limageSO -lm -o $@
|
||||
|
||||
addpnm2fimg: addpnm2fimg.c $(DEPS)
|
||||
gcc $(COPT) $< ../libfloatimg.a -lm -o $@
|
||||
|
@ -36,9 +36,6 @@
|
||||
#define SAVE_AS_PNM 0
|
||||
#define SAVE_AS_FIMG 0
|
||||
|
||||
#define WIDTH 1920
|
||||
#define HEIGHT 1080
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
||||
@ -74,10 +71,12 @@ if (verbosity) {
|
||||
}
|
||||
puts("options :");
|
||||
puts("\t-d /dev/?\tselect video device");
|
||||
puts("\t-g\t\tconvert to gray");
|
||||
puts("\t-n NNN\t\thow many frames ?");
|
||||
puts("\t-O ./\t\tset Output dir");
|
||||
puts("\t-o bla\t\tset output filename");
|
||||
puts("\t-p NNN\t\tperiod in seconds");
|
||||
puts("\t-s WxH\t\tsize of capture");
|
||||
puts("\t-v\t\tincrease verbosity");
|
||||
exit(0);
|
||||
}
|
||||
@ -102,7 +101,10 @@ int foo, bar;
|
||||
double period = 10.0; /* delai entre les captures */
|
||||
int nbre_capt = 1; /* nombre de captures */
|
||||
int opt;
|
||||
int width = 640;
|
||||
int height = 480;
|
||||
double t_final;
|
||||
int to_gray = 0;
|
||||
char *dest_dir = "."; /* no trailing slash */
|
||||
char *outfile = "out.pnm";
|
||||
|
||||
@ -110,14 +112,16 @@ char *outfile = "out.pnm";
|
||||
FloatImg grab, cumul;
|
||||
#endif
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:hn:o:O:p:v")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "d:ghn:o:O:p:s:v")) != -1) {
|
||||
switch(opt) {
|
||||
case 'd': dev_name = optarg; break;
|
||||
case 'g': to_gray = 1; break;
|
||||
case 'h': help(0); break;
|
||||
case 'n': nbre_capt = atoi(optarg); break;
|
||||
case 'O': dest_dir = optarg; break;
|
||||
case 'o': outfile = optarg; break;
|
||||
case 'p': period = 1e6*atof(optarg); break;
|
||||
case 's': parse_WxH(optarg, &width, &height); break;
|
||||
case 'v': verbosity++; break;
|
||||
}
|
||||
}
|
||||
@ -125,6 +129,7 @@ while ((opt = getopt(argc, argv, "d:hn:o:O:p:v")) != -1) {
|
||||
if (verbosity) {
|
||||
fprintf(stderr, "running %s pid=%d\n", argv[0], getpid());
|
||||
fprintf(stderr, "period is %.3f microseconds\n", period);
|
||||
fprintf(stderr, "framesize is %dx%d\n", width, height);
|
||||
}
|
||||
|
||||
fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0);
|
||||
@ -135,16 +140,17 @@ if (fd < 0) {
|
||||
|
||||
CLEAR(fmt);
|
||||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
fmt.fmt.pix.width = WIDTH;
|
||||
fmt.fmt.pix.height = HEIGHT;
|
||||
fmt.fmt.pix.width = width;
|
||||
fmt.fmt.pix.height = height;
|
||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
|
||||
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
|
||||
xioctl(fd, VIDIOC_S_FMT, &fmt);
|
||||
if (fmt.fmt.pix.pixelformat != V4L2_PIX_FMT_RGB24) {
|
||||
/* are others formats usable ? */
|
||||
printf("Libv4l didn't accept RGB24 format. Can't proceed.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((fmt.fmt.pix.width != WIDTH) || (fmt.fmt.pix.height != HEIGHT)) {
|
||||
if ((fmt.fmt.pix.width != width) || (fmt.fmt.pix.height != height)) {
|
||||
printf("Warning: driver is sending image at %dx%d\n",
|
||||
fmt.fmt.pix.width, fmt.fmt.pix.height);
|
||||
}
|
||||
@ -195,11 +201,10 @@ foo = fimg_create(&cumul,
|
||||
FIMG_TYPE_RGB);
|
||||
fimg_clear(&cumul);
|
||||
cumul.fval = 255.0;
|
||||
cumul.count = 0;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
xioctl(fd, VIDIOC_STREAMON, &type);
|
||||
|
||||
@ -280,6 +285,10 @@ fprintf(stderr, "pid %d : elapsed time %g s\n", getpid(), t_final);
|
||||
fprintf(stderr, "\t%.2f fps\n", (double)nbre_capt / t_final);
|
||||
|
||||
#if SAVE_AS_CUMUL
|
||||
if (to_gray) {
|
||||
if (verbosity) fputs("converting to gray\n", stderr);
|
||||
foo = fimg_to_gray(&cumul);
|
||||
}
|
||||
// save cumul to file
|
||||
foo = fimg_save_as_pnm(&cumul, outfile, 0);
|
||||
// free buffers
|
||||
|
@ -19,6 +19,38 @@
|
||||
|
||||
int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/*
|
||||
* this code was written from a strace output :)
|
||||
*/
|
||||
int enum_image_framesizes(int fd, char *txt, int k)
|
||||
{
|
||||
int foo, idx;
|
||||
struct v4l2_frmsizeenum fmtsz;
|
||||
|
||||
printf("-- image framesizes enumeration (%s)\n", txt);
|
||||
|
||||
for (idx=0; ; idx++) {
|
||||
memset(&fmtsz, 0, sizeof(fmtsz));
|
||||
fmtsz.index = idx;
|
||||
foo = ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &fmtsz);
|
||||
|
||||
if (foo) {
|
||||
if (EINVAL==errno) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
perror(__func__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%4d %4d %4d\n", idx, fmtsz.pixel_format, fmtsz.type);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int enum_image_formats(int fd, char *txt, int k)
|
||||
{
|
||||
@ -61,7 +93,7 @@ int index, foo;
|
||||
struct v4l2_input input;
|
||||
char ligne[50];
|
||||
|
||||
printf("-- inputs enumeration '%s'\n", txt);
|
||||
printf("-- inputs enumeration (%s)\n", txt);
|
||||
|
||||
index = 0;
|
||||
for(;;) {
|
||||
@ -219,6 +251,7 @@ foo = enum_controls(vfd, "is that working ?", 0);
|
||||
|
||||
foo = enum_extended_controls(vfd, "looking for extended", 0);
|
||||
|
||||
enum_image_framesizes(vfd, "code pas fini", 0);
|
||||
|
||||
close(vfd);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user