is extracteur ready for the prime time ?

master
tth 2 years ago
parent 7718ca0f62
commit 9cf60526d7
  1. 18
      experiment/essai.sh
  2. 62
      experiment/extracteur.c

@ -1,9 +1,19 @@
#!/bin/bash
make assemblage
make extracteur
grabvidseq -vv -n 4 -p 3.3333 -o foo.fimg
IMGS="foo.fimg"
./assemblage -v
for idx in $(seq 0 69)
do
outf=$(printf "%s/X%04d.png" "/tmp" $idx)
echo $outf
x=$(( idx * 4 ))
y=$(( idx + 80 ))
./extracteur $IMGS 320,200,${x},${y} $outf
done
convert -delay 10 /tmp/X????.png foo.gif
display out.pnm

@ -3,6 +3,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../floatimg.h"
@ -27,6 +28,21 @@ printf("rect @ %p : %dx%d at %d,%d\n", rect, rect->w, rect->h,
return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int parse_rectangle(char *str, Rectangle *r, int notused)
{
int x, y, w, h, foo;
if (verbosity)
fprintf(stderr, "parsing %s\n", str);
foo = sscanf(str, "%d,%d,%d,%d", &w, &h, &x, &y);
if (4 == foo) {
r->x = x, r->y = y, r->w = w, r->h = h;
return 4;
}
return -1;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int essai_extraction(FloatImg *in, FloatImg *out, Rectangle *rect)
{
int foo;
@ -45,14 +61,12 @@ for (yd=0; yd<rect->h; yd++) {
ys = yd + rect->y;
if ((ys<0) || (ys>=in->height)) continue;
for (xd=0; xd<rect->w; xd++) {
xs = xd + rect->x;
if ((xs<0) || (xs>=in->width)) continue;
fimg_get_rgb(in, xs, ys, rgb);
fimg_put_rgb(out, xd, yd, rgb);
count++;
}
}
// fprintf(stderr, "%s: %d pix moved\n", __func__, count);
@ -60,10 +74,16 @@ for (yd=0; yd<rect->h; yd++) {
return 0;
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
void help(int k)
{
puts("Usage:\n\textracteur in.fimg w,h,x,y out.???");
exit(0);
}
/* ---------------------------------------------- ~~~~~~~~~~~~~~~~ */
int main(int argc, char *argv[])
{
int foo;
int foo, opt;
FloatImg src, dst;
Rectangle zone;
char *infile = "foo.fimg";
@ -71,15 +91,25 @@ char *outfile = "out.fimg";
verbosity = 0;
if (3 != argc) {
fprintf(stderr, "usage\n\t %s infile.fimg outfile.???\n",
argv[0]);
while ((opt = getopt(argc, argv, "hv")) != -1) {
switch(opt) {
case 'h': help(0); break;
case 'v': verbosity++; break;
default: break;
}
}
if (3 != argc-optind) {
fprintf(stderr, "---- %s errcli %d ----\n", argv[0], argc-optind);
help(1);
exit(1);
}
fprintf(stderr, "***%s %s %s\n", argv[0], __DATE__, __TIME__);
fimg_print_version(1);
infile = argv[1]; outfile = argv[2];
infile = argv[optind]; outfile = argv[optind+2];
fprintf(stderr, " %s -> %s\n", infile, outfile);
foo = fimg_create_from_dump(infile, &src);
if (foo) {
@ -88,8 +118,16 @@ if (foo) {
exit(1);
}
zone.w = src.width / 2; zone.h = src.height / 2;
zone.x = src.width / 4 ; zone.y = src.height / 4;
if (4 != parse_rectangle( argv[optind+1], &zone, 0) ) {
fprintf(stderr, "%s: error in parsing of '%s'\n",
argv[0], argv[optind+1]);
exit(1);
}
// zone.w = src.width / 2; zone.h = src.height / 2;
// zone.x = src.width / 4 ; zone.y = src.height / 4;
print_rectangle(&zone);
foo = fimg_create(&dst, zone.w, zone.h, FIMG_TYPE_RGB);
@ -100,6 +138,10 @@ if (foo) {
}
foo = fimg_export_picture(&dst, outfile, 0);
if (foo) {
fprintf(stderr, "export '%s' -> err %d\n", outfile, foo);
exit(1);
}
return 0;
}

Loading…
Cancel
Save