Compare commits
No commits in common. "c7a428c5f04a989940b5cffe25f5adf24b25fd06" and "447464f6c8703248002f91255d16012526aae13d" have entirely different histories.
c7a428c5f0
...
447464f6c8
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,10 +1,6 @@
|
||||
|
||||
lib/*.o
|
||||
lib/t
|
||||
lib/*.fimg
|
||||
lib/*.png
|
||||
lib/*.gif
|
||||
|
||||
funcs/*.o
|
||||
|
||||
*.a
|
||||
|
@ -2,7 +2,7 @@
|
||||
* floatimg.h
|
||||
*/
|
||||
|
||||
#define FIMG_VERSION 76
|
||||
#define FIMG_VERSION 75
|
||||
|
||||
/*
|
||||
* in memory descriptor
|
||||
@ -36,12 +36,6 @@ typedef struct {
|
||||
#define FILE_TYPE_PNM 2
|
||||
#define FILE_TYPE_PNG 3
|
||||
|
||||
/* lib/contrast.c */
|
||||
#define CONTRAST_NONE 0
|
||||
#define CONTRAST_SQRT 1
|
||||
#define CONTRAST_POW2 2
|
||||
#define CONTRAST_COS01 3
|
||||
|
||||
/*
|
||||
* core module
|
||||
*/
|
||||
|
@ -1,7 +1,3 @@
|
||||
/*
|
||||
* contrast.c - part of libfloatimg
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@ -13,9 +9,6 @@
|
||||
extern int verbosity;
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/*
|
||||
* if the second parameter is NULL, operate 'in-place'
|
||||
*/
|
||||
int fimg_square_root(FloatImg *s, FloatImg *d, double maxval)
|
||||
{
|
||||
int nbre, idx;
|
||||
@ -30,13 +23,6 @@ if (s->type != FIMG_TYPE_RGB) {
|
||||
if (NULL==d) {
|
||||
d = s;
|
||||
}
|
||||
else {
|
||||
if (d->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s : dst type %d invalide\n",
|
||||
__func__, d->type);
|
||||
return -4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nbre = s->width * s->height * 3;
|
||||
@ -66,7 +52,7 @@ if (NULL==d) {
|
||||
else {
|
||||
if (d->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s : dst type %d invalide\n",
|
||||
__func__, d->type);
|
||||
__func__, s->type);
|
||||
return -4;
|
||||
}
|
||||
}
|
||||
@ -87,6 +73,7 @@ return 0;
|
||||
#macro Cos_01( X )
|
||||
(0.5-0.5*cos( 3.141592654 * X))
|
||||
#end
|
||||
|
||||
*/
|
||||
int fimg_cos_01(FloatImg *s, FloatImg *d, double maxval)
|
||||
{
|
||||
@ -102,13 +89,6 @@ if (s->type != FIMG_TYPE_RGB) {
|
||||
if (NULL==d) {
|
||||
d = s;
|
||||
}
|
||||
else {
|
||||
if (d->type != FIMG_TYPE_RGB) {
|
||||
fprintf(stderr, "%s : dst type %d invalide\n",
|
||||
__func__, d->type);
|
||||
return -4;
|
||||
}
|
||||
}
|
||||
|
||||
nbre = s->width * s->height * 3;
|
||||
|
||||
|
@ -33,9 +33,6 @@ if (FIMG_TYPE_RGB != src->type) {
|
||||
if (FIMG_TYPE_GRAY != dst->type) {
|
||||
fprintf(stderr, "%s : bad dst type %d on %p\n", __func__,
|
||||
dst->type, dst);
|
||||
/*
|
||||
* may be we can convert dst picture on the fly ?
|
||||
*/
|
||||
return -9;
|
||||
}
|
||||
|
||||
|
12
lib/runme.sh
12
lib/runme.sh
@ -1,23 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
../v4l2/grabvidseq -s 960x720 -n 10000 -p 0.078 \
|
||||
-vv -g -c none \
|
||||
-o original.fimg
|
||||
grabvidseq -s 960x720 -n 600 -p 0.5 -vv -g -o original.fimg
|
||||
|
||||
make t && ./t
|
||||
|
||||
for picz in original power2 squareroot cos_01
|
||||
do
|
||||
|
||||
echo _______________________ ${picz}
|
||||
echo _______________ ${picz}
|
||||
|
||||
# ../tools/fimgstats -v ${picz}.fimg
|
||||
../tools/fimg2pnm -v ${picz}.fimg ${picz}.pnm
|
||||
|
||||
convert -pointsize 48 \
|
||||
-fill black -annotate +14+40 "${picz}" \
|
||||
-fill white -annotate +16+42 "${picz}" \
|
||||
convert -pointsize 36 \
|
||||
-fill white -annotate +10+28 "${picz}" \
|
||||
-fill black -annotate +12+30 "${picz}" \
|
||||
${picz}.pnm ${picz}.png
|
||||
|
||||
rm ${picz}.pnm
|
||||
|
24
lib/t.c
24
lib/t.c
@ -13,6 +13,29 @@
|
||||
|
||||
int verbosity;
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
int petit_dessin(FloatImg *img)
|
||||
{
|
||||
int x, y;
|
||||
float r, g, b;
|
||||
|
||||
for (y=0; y<img->height; y++) {
|
||||
|
||||
r = (float)y / (float)img->height;
|
||||
|
||||
for (x=0; x<img->width; x++) {
|
||||
|
||||
g = (float)x / (float)img->width;
|
||||
b = 0.0;;
|
||||
|
||||
fimg_plot_rgb(img, x, y, r, g, b);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
int essai_2gray(FloatImg *picz, char *outname)
|
||||
@ -54,6 +77,7 @@ double maxi;
|
||||
foo = fimg_create_from_dump(fname, &dessin);
|
||||
foo = fimg_clone(&dessin, ©, 0);
|
||||
|
||||
|
||||
maxi = (double)fimg_get_maxvalue(&dessin);
|
||||
fprintf(stderr, "image source valeur maxi = %f\n", maxi);
|
||||
|
||||
|
@ -64,16 +64,6 @@ if (r == -1) {
|
||||
}
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int contraste(char *str)
|
||||
{
|
||||
|
||||
if (!strcmp(str, "sqrt")) return CONTRAST_SQRT;
|
||||
if (!strcmp(str, "pow2")) return CONTRAST_POW2;
|
||||
if (!strcmp(str, "cos01")) return CONTRAST_COS01;
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
void help(int v)
|
||||
{
|
||||
if (verbosity) {
|
||||
@ -84,10 +74,9 @@ 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.xxx\tset output filename");
|
||||
puts("\t-o bla\t\tset output filename");
|
||||
puts("\t-p NN.N\t\tperiod in seconds");
|
||||
puts("\t-s WxH\t\tsize of capture");
|
||||
puts("\t-c mode\t\tcontrast enhancement");
|
||||
puts("\t-u\t\ttry upscaling...");
|
||||
puts("\t-v\t\tincrease verbosity");
|
||||
exit(0);
|
||||
@ -115,10 +104,9 @@ int nbre_capt = 1; /* nombre de captures */
|
||||
int opt;
|
||||
int width = 640;
|
||||
int height = 480;
|
||||
double t_final, maxvalue;
|
||||
double t_final;
|
||||
int to_gray = 0;
|
||||
int upscaling = 0;
|
||||
int contrast = 0;
|
||||
char *dest_dir = "."; /* no trailing slash */
|
||||
char *outfile = "out.pnm";
|
||||
|
||||
@ -126,9 +114,8 @@ char *outfile = "out.pnm";
|
||||
FloatImg cumul;
|
||||
#endif
|
||||
|
||||
while ((opt = getopt(argc, argv, "c:d:ghn:o:O:p:s:uv")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "d:ghn:o:O:p:s:uv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'c': contrast = contraste(optarg); break;
|
||||
case 'd': dev_name = optarg; break;
|
||||
case 'g': to_gray = 1; break;
|
||||
case 'h': help(0); break;
|
||||
@ -153,10 +140,9 @@ while ((opt = getopt(argc, argv, "c:d:ghn:o:O:p:s:uv")) != -1) {
|
||||
|
||||
if (verbosity) {
|
||||
fprintf(stderr, "running %s pid=%d\n", argv[0], getpid());
|
||||
fprintf(stderr, "grabing %d picz\n", nbre_capt);
|
||||
fprintf(stderr, "period is %.3f milliseconds\n", period/1e3);
|
||||
fprintf(stderr, "framesize is %dx%d\n", width, height);
|
||||
if (upscaling) fprintf(stderr, "upscaling is on\n");
|
||||
fprintf(stderr, "upscaling is %s\n", upscaling ? "on" : "off");
|
||||
}
|
||||
|
||||
fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0);
|
||||
@ -174,11 +160,11 @@ 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 ? */
|
||||
fprintf(stderr, "Libv4l didn't accept RGB24 format. Can't proceed.\n");
|
||||
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)) {
|
||||
fprintf(stderr, "Warning: driver is sending image at %dx%d\n",
|
||||
printf("Warning: driver is sending image at %dx%d\n",
|
||||
fmt.fmt.pix.width, fmt.fmt.pix.height);
|
||||
}
|
||||
|
||||
@ -330,29 +316,6 @@ if (to_gray) {
|
||||
// save cumul to file
|
||||
if (verbosity) fprintf(stderr, "saving cumul to '%s'\n", outfile);
|
||||
|
||||
/* ----- nouveau 15 nov 2019 */
|
||||
maxvalue = cumul.fval * cumul.count;
|
||||
if (verbosity) {
|
||||
fprintf(stderr, "computed maxvalue = %g\n", maxvalue);
|
||||
}
|
||||
switch (contrast) {
|
||||
case CONTRAST_NONE:
|
||||
fprintf(stderr, "contrast: none\n");
|
||||
break;
|
||||
case CONTRAST_SQRT:
|
||||
fimg_square_root(&cumul, NULL, maxvalue);
|
||||
break;
|
||||
case CONTRAST_POW2:
|
||||
fimg_power_2(&cumul, NULL, maxvalue);
|
||||
break;
|
||||
case CONTRAST_COS01:
|
||||
fimg_cos_01(&cumul, NULL, maxvalue);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "bad contrast method\n");
|
||||
break;
|
||||
}
|
||||
|
||||
foo = format_from_extension(outfile);
|
||||
switch (foo) {
|
||||
case FILE_TYPE_FIMG:
|
||||
|
Loading…
Reference in New Issue
Block a user