Compare commits

..

7 Commits

Author SHA1 Message Date
tth
f0c704a818 cumul image can be converted to gray 2019-09-02 11:47:51 +02:00
tth
cc6dd330ed KRKRKR 2019-09-02 10:42:03 +02:00
tth
7157ce47a3 time to optimize for velocity 2019-09-02 10:07:56 +02:00
tth
d65b93fc66 size of capture is now an option 2019-09-02 04:31:27 +02:00
tth
7abdf7b43e enum_image_framesizes not working 2019-08-31 19:46:37 +02:00
tth
144498d68e enlever le truc qui compile pas facilement 2019-08-31 18:07:31 +02:00
tth
74496aa439 trop chaud pour ecrire la doc 2019-08-31 18:06:09 +02:00
9 changed files with 85 additions and 75 deletions

View File

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

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

View File

@ -9,4 +9,11 @@
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
int essai_ecrire_tiff(FloatImg *src, char *fname)
{
/* bon, tout cela semble bien tortueux ! */
return 0;
}
/* --------------------------------------------------------------------- */

View File

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

View File

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

View File

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

View File

@ -1,42 +0,0 @@
-- v4l2_capability, /dev/video0 0x7ffeee718100
driver cx231xx
card Pixelview Xcapture USB
bus info usb-0000:00:1a.0-1.2
version 0x41325
capabilities 0x85200011
vcapt vbicapt extpix rwsysc stream
device caps 0x5200001
-- inputs enumeration 'on peut voir quoi ?'
Composite1 | camera
S-Video | camera
-- v4l2_format, Experimental 0x7ffeee718030
type 1 video capture
dims 720x576
pixformat [YUYV]
field 4
padding 1440
sizeimage 829440
colorspace 1 smpte170m
-- image formats enumeration (Experimental)
0 vidcapt 0x00 [YUYV] YUYV 4:2:2
-- controls enumeration 'is that working ?'
Brightness integer [0..255]
Contrast integer [0..127]
Saturation integer [0..127]
Hue integer [-128..127]
Volume integer [0..65535]
Balance integer [0..65535]
Bass integer [0..65535]
Treble integer [0..65535]
Mute boolean [0..1]
-- extended controls enumeration 'looking for extended'
User Controls ctrl-class [0..0]
Brightness integer [0..255]
Contrast integer [0..127]
Saturation integer [0..127]
Hue integer [-128..127]
Volume integer [0..65535]
Balance integer [0..65535]
Bass integer [0..65535]
Treble integer [0..65535]
Mute boolean [0..1]

View File

@ -36,9 +36,6 @@
#define SAVE_AS_PNM 0
#define SAVE_AS_FIMG 0
#define WIDTH 720
#define HEIGHT 576
/* --------------------------------------------------------------------- */
#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

View File

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