Compare commits

..

5 Commits

Author SHA1 Message Date
tonton Th
c48a3e4870 minor improvments 2020-01-28 22:12:12 +01:00
tonton Th
312f892576 beurk... 2020-01-28 22:11:20 +01:00
tonton Th
379bd1b7de outfile format now configurable 2020-01-28 21:57:02 +01:00
tonton Th
5da64b6145 can now save as 8bits png file 2020-01-25 17:22:31 +01:00
tonton Th
0a814f1bc6 setting some better defaults 2020-01-25 16:58:45 +01:00
7 changed files with 69 additions and 47 deletions

View File

@ -9,7 +9,9 @@ SZ=640x480
NBRE=320
PERIOD=0.0
COUNT=compteur
OPTIONS=" -u"
OPTIONS=" -v "
SHOW="no"
OFORMAT="P_%04d.pnm"
# ------------------------------------
# overide parameters from $PWD
@ -33,7 +35,7 @@ if [ 1 -eq $# ]
then
outfile="$1"
else
outfile=$( printf "P_%04d.pnm" $numero )
outfile=$( printf ${OFORMAT} $numero )
fi
# ------------------------------------

View File

@ -18,10 +18,10 @@ v4l2_pr_structs.o: v4l2_pr_structs.c v4l2_pr_structs.h Makefile
gcc ${COPT} -c $<
grabvidseq: grabvidseq.c ${DEPS} rgb2fimg.o
gcc ${COPT} $< rgb2fimg.o ../libfloatimg.a -lz -lm -lv4l2 -o $@
gcc ${COPT} $< rgb2fimg.o ../libfloatimg.a -lpnglite -lz -lm -lv4l2 -o $@
video-infos: video-infos.c Makefile funcs.o v4l2_pr_structs.o
gcc -Wall -g $< funcs.o v4l2_pr_structs.o -o $@
gcc -Wall -g $< funcs.o v4l2_pr_structs.o ../libfloatimg.a -o $@
# ---------------

View File

@ -15,6 +15,10 @@
#include <linux/videodev2.h>
#include "../floatimg.h"
#include "funcs.h"
/* --------------------------------------------------------------------- */
extern int verbosity;
@ -215,7 +219,7 @@ fprintf(stderr, ">>> %s ( %d )\n", __func__, notused);
if (-1 == xioctl(fd, VIDIOC_QUERYCAP, &cap)) {
if (EINVAL == errno) {
fprintf(stderr, "%s is no V4L2 device\n", dev_name);
fprintf(stderr, "%s is not a V4L2 device\n", dev_name);
exit(EXIT_FAILURE);
} else {
errno_exit("VIDIOC_QUERYCAP");

View File

@ -365,6 +365,12 @@ switch (foo) {
case FILE_TYPE_PNM:
foo = fimg_save_as_pnm(&cumul, outfile, 1);
break;
case FILE_TYPE_PNG:
foo = fimg_save_as_png(&cumul, outfile, 0);
break;
default:
fprintf(stderr, "can't save as %s\n", outfile);
break;
}
// free buffers
fimg_destroy(&cumul);

View File

@ -20,9 +20,9 @@
int verbosity;
/* --------------------------------------------------------------------- */
int essai(char *dev, int k)
int essai_get_fmt(char *dev, int k)
{
int vfd, foo;
int vfd, idx, foo;
struct v4l2_format fmt;
struct v4l2_requestbuffers reqbuf;
@ -33,18 +33,20 @@ if (verbosity) fprintf(stderr, "\topen %s -> %d\n", dev, vfd);
memset(&fmt, 0, sizeof(fmt));
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
foo = ioctl(vfd, VIDIOC_G_FMT, &fmt);
fprintf(stderr, "ioctl -> %d\n", foo);
fprintf(stderr, "%s : ioctl -> %d\n", __func__, foo);
if (0 != foo) {
perror("ioctl G_FMT");
exit(1);
return -1;
}
pr_v4l2_format("after ioctl VIDIOC_G_FMT", &fmt);
/* this function is bugged */
close(vfd);
return k;
}
/* --------------------------------------------------------------------- */
@ -79,7 +81,7 @@ while ((opt = getopt(argc, argv, "d:hK:v")) != -1) {
if (verbosity) fimg_print_version(0);
foo = essai(device, K);
foo = essai_get_fmt(device, K);
fprintf(stderr, "\tessai -> %d\n", foo);
return 0;

View File

@ -59,7 +59,7 @@ fputs("\n", FP);
/* --------------------------------------------------------------------- */
int pr_v4l2_capability(char *txt, struct v4l2_capability *ptr)
{
fprintf(FP, "-- v4l2_capability, %-15s %p\n", txt, ptr);
fprintf(FP, "## v4l2_capability, %-15s %p\n", txt, ptr);
fprintf(FP, " driver %s\n", ptr->driver);
fprintf(FP, " card %s\n", ptr->card);
@ -115,7 +115,7 @@ return "???";
/* --------------------------------------------------------------------- */
int pr_v4l2_fmtdesc(char *txt, struct v4l2_fmtdesc *ptr)
{
fprintf(FP, "-- v4l2_fmtdesc, %-15s %p\n", txt, ptr);
fprintf(FP, "## v4l2_fmtdesc, %-15s %p\n", txt, ptr);
fprintf(FP, " index %d\n", ptr->index);
fprintf(FP, " type %d\n", ptr->type); /* enum v4l2_buf_type */
@ -170,7 +170,7 @@ if (st & V4L2_IN_CAP_NATIVE_SIZE) fputs("nativsz ", FP);
/* --------------------------------------------------------------------- */
int pr_v4l2_input(char *txt, struct v4l2_input *ptr)
{
fprintf(FP, "-- v4l2_input, %-15s %p\n", txt, ptr);
fprintf(FP, "## v4l2_input, %-15s %p\n", txt, ptr);
fprintf(FP, " index %d\n", ptr->index);
fprintf(FP, " name %s\n", ptr->name);
@ -218,7 +218,7 @@ return "???";
/* --------------------------------------------------------------------- */
int pr_v4l2_format(char *txt, struct v4l2_format *ptr)
{
fprintf(FP, "-- v4l2_format, %-15s %p\n", txt, ptr);
fprintf(FP, "## v4l2_format, %-15s %p\n", txt, ptr);
fprintf(FP, " type %d %s\n", ptr->type,/* enum v4l2_buf_type */
fmttype2str(ptr->type));
@ -250,7 +250,7 @@ return 0;
/* --------------------------------------------------------------------- */
int pr_v4l2_requestbuffers(char *txt, struct v4l2_requestbuffers *ptr)
{
fprintf(FP, "-- v4l2_requestbuffers, %s %p\n", txt, ptr);
fprintf(FP, "## v4l2_requestbuffers, %s %p\n", txt, ptr);
fprintf(FP, " type %d\n", ptr->type); /* enum v4l2_buf_type */

View File

@ -28,7 +28,7 @@ int enum_image_framesizes(int fd, char *txt, int k)
int foo, idx;
struct v4l2_frmsizeenum fmtsz;
printf("-- image framesizes enumeration (%s)\n", txt);
printf("## image framesizes enumeration (%s)\n", txt);
for (idx=0; ; idx++) {
memset(&fmtsz, 0, sizeof(fmtsz));
@ -57,7 +57,7 @@ int enum_image_formats(int fd, char *txt, int k)
int foo, idx;
struct v4l2_fmtdesc fmtd;
printf("-- image formats enumeration (%s)\n", txt);
printf("## image formats enumeration (%s)\n", txt);
idx = 0;
for (;;) {
@ -93,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(;;) {
@ -130,7 +130,7 @@ struct v4l2_queryctrl qctrl;
int idx;
printf("-- controls enumeration '%s'\n", txt);
printf("## controls enumeration '%s'\n", txt);
memset (&qctrl, 0, sizeof (qctrl));
@ -148,7 +148,7 @@ for (idx=V4L2_CID_BASE; idx<V4L2_CID_LASTP1; idx++) {
continue;
}
printf(" %-32s %-10s [%d..%d]\n",
printf(" %-40s %-10s [%d..%d]\n",
qctrl.name,
str_ctrl_type(qctrl.type),
qctrl.minimum, qctrl.maximum);
@ -179,7 +179,7 @@ int enum_extended_controls(int fd, char *txt, int k)
struct v4l2_queryctrl qctrl;
int idx;
printf("-- extended controls enumeration '%s'\n", txt);
printf("##- extended controls enumeration '%s'\n", txt);
memset(&qctrl, 0, sizeof(qctrl));
qctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
@ -200,7 +200,7 @@ while (0 == ioctl (fd, VIDIOC_QUERYCTRL, &qctrl)) {
return -1;
}
/* --------------------------------------------------------------------- */
int show_webcam_infos(char *devname, char *title, int k)
int show_webcam_infos(char *devname, char *title, int k, int type)
{
int vfd, foo;
char ligne[100];
@ -213,7 +213,7 @@ struct v4l2_format fmt;
// struct v4l2_requestbuffers reqbuf;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, devname, k);
fprintf(stderr, ">>> %s ( '%s' %d %d)\n", __func__, devname, k, type);
#endif
vfd = open_device(devname);
@ -245,13 +245,17 @@ else {
pr_v4l2_format("Experimental", &fmt);
}
if (type) {
;
}
else {
foo = enum_image_formats(vfd, "Experimental", 0);
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);
@ -267,12 +271,15 @@ return -1;
static void help(int k)
{
puts("Options :");
puts("\t-e N\t\texamine that, please");
puts("\t-d\t\tselect the video device");
puts("\t-K\t\tset the K parameter");
puts("\t-l\t\tlist video devices");
puts("\t-T bla\t\tadd a title");
puts("\t-v\t\tincrease verbosity");
// if (verbosity)
{ puts(""); fimg_print_version(1); }
exit(0);
}
/* --------------------------------------------------------------------- */
@ -293,14 +300,15 @@ puts("\n");
int main(int argc, char *argv[])
{
int foo, opt;
int etype = 0;
char *device = "/dev/video0";
char *title = NULL;
int K = 0;
while ((opt = getopt(argc, argv, "d:hK:lT:v")) != -1) {
while ((opt = getopt(argc, argv, "d:e:hK:lT:v")) != -1) {
switch(opt) {
case 'd': device = optarg; break;
case 'e': etype = atol(optarg); break;
case 'h': help(0); break;
case 'K': K = atol(optarg); break;
case 'l': liste_des_devices(0); break;
@ -313,7 +321,7 @@ if (NULL != title) {
print_title(title);
}
foo = show_webcam_infos(device, "", K);
foo = show_webcam_infos(device, "", K, etype);
fprintf(stderr, "\n\tshow_webcam_infos -> %d\n", foo);
return 0;