luvcview.c
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <unistd.h>
00027 #include <sys/types.h>
00028 #include <sys/stat.h>
00029 #include <sys/file.h>
00030 #include <string.h>
00031 #include <pthread.h>
00032 #include <linux/videodev.h>
00033 #include <sys/ioctl.h>
00034 #include <sys/mman.h>
00035 #include <errno.h>
00036 #include <fcntl.h>
00037 #include <time.h>
00038 #include <sys/time.h>
00039 #include <signal.h>
00040 #include "v4l2uvc.h"
00041 #include "gui.h"
00042 #include "utils.h"
00043 #include "color.h"
00044
00045 #define FIXED Sint32
00046 #define FIXED_BITS 16
00047 #define TO_FIXED(X) (((Sint32)(X))<<(FIXED_BITS))
00048 #define FROM_FIXED(X) (((Sint32)(X))>>(FIXED_BITS))
00049
00050 #define INCPANTILT 64 // 1°
00051
00052 static const char version[] = VERSION;
00053 struct vdIn *videoIn;
00054
00055 int main(int argc, char *argv[])
00056 {
00057
00058 int status;
00059 int currtime;
00060 int lasttime;
00061 unsigned char *p = NULL;
00062 int hwaccel = 0;
00063 const char *videodevice = NULL;
00064 const char *mode = NULL;
00065
00066 int format = V4L2_PIX_FMT_YUYV;
00067 int i;
00068 int grabmethod = 1;
00069 int width = 640;
00070 int height = 480;
00071 int fps = 30;
00072 unsigned char frmrate = 0;
00073 char *avifilename = NULL;
00074 int queryformats = 0;
00075 int querycontrols = 0;
00076 int readconfigfile = 0;
00077 char *separateur;
00078 char *sizestring = NULL;
00079 char *fpsstring = NULL;
00080 int enableRawStreamCapture = 0;
00081 int enableRawFrameCapture = 0;
00082
00083 printf("luvcview %s\n\n", version);
00084
00085 videodevice = "/dev/video0";
00086
00087 videoIn = (struct vdIn *) calloc(1, sizeof(struct vdIn));
00088 if ( queryformats ) {
00089
00090 check_videoIn(videoIn,(char *) videodevice);
00091 free(videoIn);
00092 exit(1);
00093 }
00094
00095 if (init_videoIn
00096 (videoIn, (char *) videodevice, width, height, fps, format,
00097 grabmethod, avifilename) < 0)
00098 exit(1);
00099
00100
00101 if ( querycontrols )
00102 enum_controls(videoIn->fd);
00103
00104
00105 if ( readconfigfile )
00106 load_controls(videoIn->fd);
00107
00108
00109 if (enableRawFrameCapture)
00110 videoIn->rawFrameCapture = enableRawFrameCapture;
00111
00112
00113
00114
00115 while (videoIn->signalquit) {
00116
00117
00118
00119
00120 lasttime = currtime;
00121 if (uvcGrab(videoIn) < 0) {
00122 printf("Error grabbing\n");
00123 break;
00124 }
00125
00126
00127 printf("frame rate: %d \n",frmrate);
00128
00129
00130
00131
00132 if (videoIn->getPict) {
00133 switch(videoIn->formatIn){
00134 case V4L2_PIX_FMT_MJPEG:
00135 get_picture(videoIn->tmpbuffer,videoIn->buf.bytesused);
00136 break;
00137 case V4L2_PIX_FMT_YUYV:
00138 get_pictureYV2(videoIn->framebuffer,videoIn->width,videoIn->height);
00139 break;
00140 default:
00141 break;
00142 }
00143 videoIn->getPict = 0;
00144 printf("get picture !\n");
00145 }
00146
00147 }
00148
00149 close_v4l2(videoIn);
00150 free(videoIn);
00151
00152 printf("Cleanup done. Exiting ...\n");
00153 }
00154