From 14062a9586e21a091a0745eaf73051bca8149b8b Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 29 Jul 2020 02:30:59 +0200 Subject: [PATCH 1/2] not a good day... --- v4l2/funcs.c | 12 ++++++---- v4l2/nc-camcontrol.c | 53 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/v4l2/funcs.c b/v4l2/funcs.c index efc4cbb0..a4474523 100644 --- a/v4l2/funcs.c +++ b/v4l2/funcs.c @@ -34,7 +34,8 @@ extern int verbosity; size_t length; }; - static char *dev_name; +static char *dev_name; + static enum io_method io = IO_METHOD_MMAP; static int fd = -1; struct buffer *buffers; @@ -48,10 +49,12 @@ static void errno_exit(const char *s) fprintf(stderr, "%s error %d, %s\n", s, errno, strerror(errno)); exit(EXIT_FAILURE); } + static int xioctl(int fh, int request, void *arg) { int r; +/* PLEASE EXPLAIN THAT CODE */ do { r = ioctl(fh, request, arg); } while (-1 == r && EINTR == errno); @@ -225,10 +228,11 @@ if (-1 == xioctl(fd, VIDIOC_QUERYCAP, &cap)) { if (EINVAL == errno) { fprintf(stderr, "%s is not a V4L2 device\n", dev_name); exit(EXIT_FAILURE); - } else { - errno_exit("VIDIOC_QUERYCAP"); - } } + else { + errno_exit("VIDIOC_QUERYCAP"); + } + } if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { fprintf(stderr, "%s is no video capture device\n", dev_name); diff --git a/v4l2/nc-camcontrol.c b/v4l2/nc-camcontrol.c index cc5c8a23..fa2734dd 100644 --- a/v4l2/nc-camcontrol.c +++ b/v4l2/nc-camcontrol.c @@ -25,13 +25,55 @@ void help(int n) puts("camera controls"); puts("\t-d bla\t\tselect video device"); - +puts("\t-e nnn\t\tset 'etype'"); +puts("\t-K nnn\t\tinteger parameter"); +puts("\t-n bla\t\tset title"); exit(0); +} +/* --------------------------------------------------------------------- */ +int init_screen(char *title) +{ +fprintf(stderr, ">>> %s ( '%s' )\n", __func__, title); +return -1; +} +/* --------------------------------------------------------------------- */ +int preparation(char *devname, int param) +{ +int fd, foo; +struct v4l2_capability cap; + +fd = open_device(devname); +if (fd < 0) { + fprintf(stderr, "err %d on %s opening\n", errno, devname); + return -2; + } + +/* est-ce un device qui permet la capture video */ +foo = ioctl(fd, VIDIOC_QUERYCAP, &cap); +if (-1 == foo) { + perror("VIDIOC_QUERYCAP"); + return -2; + } +if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { + fprintf(stderr, "%s is not a video capture device\n", devname); + return -3; + } + +return fd; +} +/* --------------------------------------------------------------------- */ +int interactive(int fd, int notused) +{ + +init_screen("prototype"); + +fprintf(stderr, "file descriptor = %d\n", fd); + } /* --------------------------------------------------------------------- */ int main(int argc, char *argv[]) { -int foo, opt; +int foo, opt, devnum; int etype = 0; char *device = "/dev/video0"; char *title = NULL; @@ -44,11 +86,18 @@ while ((opt = getopt(argc, argv, "d:e:hK:lT:v")) != -1) { case 'h': help(0); break; case 'K': K = atol(optarg); break; // case 'l': liste_des_devices(0); break; + case 't': title = optarg; case 'v': verbosity++; break; } } +devnum = preparation(device, K); +if (devnum < 0) { + fprintf(stderr, "%s : erreur init video device\n", argv[0]); + exit(1); + } +foo = interactive(devnum, 0); return 0; } From 6ab57a40468434dbb2b14f446584536e3af7d38c Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 29 Jul 2020 02:57:06 +0200 Subject: [PATCH 2/2] add fimg_mix_rgb_gray support to fimgfx --- tools/fimgfx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/fimgfx.c b/tools/fimgfx.c index b6e84520..48ace935 100644 --- a/tools/fimgfx.c +++ b/tools/fimgfx.c @@ -21,7 +21,7 @@ typedef struct { } Fx; enum fxid { Fx_cos01=5, Fx_cos010, Fx_pow2, Fx_sqrt, Fx_gray0, Fx_halfsz0, - Fx_rot90, Fx_cmixa, + Fx_rot90, Fx_cmixa, Fx_Desat, Fx_xper }; Fx fx_list[] = { @@ -34,6 +34,7 @@ Fx fx_list[] = { { "rot90", Fx_rot90, 0, 0 }, { "cmixa", Fx_cmixa, 0, 1 }, { "xper", Fx_xper, 0, 1 }, + { "desat", Fx_Desat, 0, 1 }, { NULL, 0, 0 } }; @@ -166,6 +167,11 @@ switch (action) { fprintf(stderr, "halfsize was not implemented\n"); return -3; + case Fx_Desat: + fimg_copy_data(&src, &dest); + foo = fimg_mix_rgb_gray(&dest, global_fvalue); + break; + default: fprintf(stderr, "%s %s : %d is bad action\n", __FILE__, __func__, action);