Compare commits
2 Commits
f0c704a818
...
776c3e9dbd
Author | SHA1 | Date | |
---|---|---|---|
|
776c3e9dbd | ||
|
0e9fa47d76 |
@ -200,9 +200,10 @@ dans \texttt{floatimg.h}. Les codes d'erreur sont disparates
|
||||
et non documenté.
|
||||
\vspace{1em}
|
||||
|
||||
Bon, vous avez une image latente, et vous souhaitez dessiner dessus
|
||||
(ou dedans ?) avec vos encres flottantes ?
|
||||
Il y a une fonction pour ça.
|
||||
|
||||
Bon, vous avez une image latente, et
|
||||
vous souhaité dessiner dessus (ou dedans ?) avec vos encres
|
||||
flottantes ?
|
||||
|
||||
\subsection{funcs/}\index{funcs/}\label{funcs}
|
||||
|
||||
|
27
essai.c
27
essai.c
@ -14,11 +14,21 @@
|
||||
int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
void fait_un_dessin(FloatImg *dessin)
|
||||
void fait_un_dessin(char *fname)
|
||||
{
|
||||
FloatImg dessin;
|
||||
double tb;
|
||||
|
||||
fimg_draw_something(dessin);
|
||||
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);
|
||||
|
||||
puts("");
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
void help(int k)
|
||||
@ -50,17 +60,10 @@ if (verbosity) fimg_print_version(0);
|
||||
fimg_create(&fimgA, W, H, 3);
|
||||
fimg_create(&fimgB, W, H, 3);
|
||||
|
||||
fimg_drand48(&fimgB, 100.0);
|
||||
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);
|
||||
}
|
||||
fimg_drand48(&fimgB, 100.0);
|
||||
fimg_drand48(&fimgA, 100.0);
|
||||
fimg_add(&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,11 +9,4 @@
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
/* --------------------------------------------------------------------- */
|
||||
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 -pg -DDEBUG_LEVEL=0
|
||||
COPT = -Wall -fpic -g -no-pie -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,16 +117,9 @@ int nbre, idx;
|
||||
fprintf(stderr, ">>> %s ( %p %g )\n", __func__, fi, kmul);
|
||||
#endif
|
||||
|
||||
if (fi->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s : type %d invalide\n",
|
||||
__func__, fi->type);
|
||||
return;
|
||||
}
|
||||
nbre = fi->width * fi->height;
|
||||
nbre = fi->width * fi->height * fi->type;
|
||||
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 $@
|
||||
|
42
v4l2/exemple.txt
Normal file
42
v4l2/exemple.txt
Normal file
@ -0,0 +1,42 @@
|
||||
-- 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]
|
@ -36,6 +36,9 @@
|
||||
#define SAVE_AS_PNM 0
|
||||
#define SAVE_AS_FIMG 0
|
||||
|
||||
#define WIDTH 720
|
||||
#define HEIGHT 576
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
||||
@ -71,12 +74,10 @@ 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);
|
||||
}
|
||||
@ -101,10 +102,7 @@ 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";
|
||||
|
||||
@ -112,16 +110,14 @@ char *outfile = "out.pnm";
|
||||
FloatImg grab, cumul;
|
||||
#endif
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:ghn:o:O:p:s:v")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "d:hn:o:O:p: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;
|
||||
}
|
||||
}
|
||||
@ -129,7 +125,6 @@ while ((opt = getopt(argc, argv, "d:ghn:o:O:p:s: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);
|
||||
@ -140,17 +135,16 @@ 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);
|
||||
}
|
||||
@ -201,10 +195,11 @@ 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);
|
||||
|
||||
@ -285,10 +280,6 @@ 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,38 +19,6 @@
|
||||
|
||||
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)
|
||||
{
|
||||
@ -93,7 +61,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(;;) {
|
||||
@ -251,7 +219,6 @@ 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