adding a new tool : video-infos
This commit is contained in:
parent
0a1abce976
commit
991308f5b2
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,6 +17,7 @@ v4l2/capture
|
||||
v4l2/grabvidseq
|
||||
v4l2/*.o
|
||||
v4l2/*.ppm
|
||||
v4l2/video-infos
|
||||
|
||||
tools/fimg2png
|
||||
tools/fimg2pnm
|
||||
|
@ -14,13 +14,18 @@ funcs.o: funcs.c funcs.h Makefile
|
||||
v4l2_pr_structs.o: v4l2_pr_structs.c v4l2_pr_structs.h Makefile
|
||||
gcc ${COPT} -c $<
|
||||
|
||||
grabvidseq: grabvidseq.c Makefile
|
||||
gcc -Wall -g $< ../libfloatimg.a -lv4l2 -o $@
|
||||
|
||||
video-infos: video-infos.c Makefile funcs.o v4l2_pr_structs.o
|
||||
gcc -Wall -g $< ../libfloatimg.a funcs.o v4l2_pr_structs.o -o $@
|
||||
|
||||
|
||||
# ---------------
|
||||
# external things
|
||||
|
||||
capture: capture.c Makefile
|
||||
gcc -Wall -g $< -o $@
|
||||
|
||||
grabvidseq: grabvidseq.c Makefile
|
||||
gcc -Wall -g $< ../libfloatimg.a -lv4l2 -o $@
|
||||
|
||||
|
||||
|
@ -27,11 +27,26 @@ switch(type) {
|
||||
return "???";
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int pr_v4l2_capability(char *txt, struct v4l2_capability *ptr)
|
||||
{
|
||||
fprintf(FP, "-- v4l2_capability, %-15s %p\n", txt, ptr);
|
||||
|
||||
fprintf(FP, " driver %s\n", ptr->driver);
|
||||
fprintf(FP, " card %s\n", ptr->card);
|
||||
fprintf(FP, " bus info %s\n", ptr->bus_info);
|
||||
|
||||
fprintf(FP, " version %X\n", ptr->version);
|
||||
fprintf(FP, " capabilities %X\n", ptr->capabilities);
|
||||
fprintf(FP, " device caps %X\n", ptr->device_caps);
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int pr_v4l2_format(char *txt, struct v4l2_format *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));
|
||||
fmttype2str(ptr->type));
|
||||
|
||||
switch(ptr->type) {
|
||||
|
||||
@ -39,10 +54,10 @@ switch(ptr->type) {
|
||||
fprintf(FP, " dims %dx%d\n",
|
||||
ptr->fmt.pix.width,
|
||||
ptr->fmt.pix.height);
|
||||
|
||||
break;
|
||||
|
||||
default: fputs(" ???\n", FP); break;
|
||||
default: fprintf(FP, "type is %d\n", ptr->type);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
/*
|
||||
* fonctions pour afficher les structures de V4L2
|
||||
*
|
||||
* WARNING : this is a work in progress !
|
||||
*/
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int pr_v4l2_capability(char *txt, struct v4l2_capability *ptr);
|
||||
|
||||
int pr_v4l2_format(char *txt, struct v4l2_format *ptr);
|
||||
int pr_v4l2_requestbuffers(char *txt, struct v4l2_requestbuffers *ptr);
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
104
v4l2/video-infos.c
Normal file
104
v4l2/video-infos.c
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* tests pour capturer les webcams
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
#include "v4l2_pr_structs.h"
|
||||
#include "funcs.h"
|
||||
|
||||
int verbosity;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
int show_webcam_infos(char *devname, int k)
|
||||
{
|
||||
int vfd, foo;
|
||||
|
||||
struct v4l2_capability cap;
|
||||
struct v4l2_format fmt;
|
||||
|
||||
// struct v4l2_requestbuffers reqbuf;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, devname, k);
|
||||
#endif
|
||||
|
||||
vfd = open_device(devname);
|
||||
if (vfd < 0) {
|
||||
perror(devname);
|
||||
return -3;
|
||||
}
|
||||
|
||||
fprintf(stderr, "\topen %s -> %d\n", devname, vfd);
|
||||
|
||||
foo = ioctl(vfd, VIDIOC_QUERYCAP, &cap);
|
||||
if (foo < 0) {
|
||||
perror("ioctl QUERYCAP");
|
||||
return -4;
|
||||
}
|
||||
pr_v4l2_capability(devname, &cap);
|
||||
if ( ! (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
|
||||
fprintf("%s : no video capture\n", devname);
|
||||
}
|
||||
|
||||
close(vfd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int liste_des_devices(int flag)
|
||||
{
|
||||
fprintf(stderr, "%s not implemented\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
void help(int k)
|
||||
{
|
||||
puts("Options :");
|
||||
puts("\t-d\tselect the video device");
|
||||
puts("\t-K\tset the K parameter");
|
||||
puts("\t-l\tlist video devices");
|
||||
puts("\t-v\tincrease verbosity");
|
||||
|
||||
if (verbosity) { puts(""); fimg_print_version(1); }
|
||||
|
||||
exit(0);
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo, opt;
|
||||
|
||||
char *device = "/dev/video0";
|
||||
int K = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:hK:lv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'd': device = optarg; break;
|
||||
case 'h': help(0); break;
|
||||
case 'K': K = atol(optarg); break;
|
||||
case 'l': liste_des_devices(0); break;
|
||||
case 'v': verbosity++; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (verbosity) fimg_print_version(0);
|
||||
|
||||
foo = show_webcam_infos(device, K);
|
||||
fprintf(stderr, "\tshow_webcam_infos -> %d\n", foo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user