videoWin32.cpp
Go to the documentation of this file.
00001 /*******************************************************
00002  *
00003  * Author: Hirokazu Kato, Atsishi Nakazawa
00004  *
00005  *         kato@sys.im.hiroshima-cu.ac.jp
00006  *         nakazawa@inolab.sys.es.osaka-u.ac.jp
00007  *
00008  * Revision: 4.1
00009  * Date: 99/07/16
00010  *
00011  * Adapted for Win32 by Robert Blanding, August 31, 1999
00012  *
00013 *******************************************************/
00014 
00015 // define FLIPPED if your video images need to be inverted
00016 //#define FLIPPED
00017 
00018 #include <string.h>
00019 #include <AR/video.h>
00020 
00021 #include <VisImSrc.h> // MS VisSDK
00022 
00023 
00024 static int     open_flag = 0;
00025 static void    error_exit(void);
00026 
00027 // Vision SDC globals for the image sequence
00028 CVisSequence<CVisRGBABytePixel>  sequence;
00029 CVisRGBAByteImage                image;
00030 #ifdef FLIPPED
00031 CVisRGBAByteImage                flipped_image;
00032 #endif
00033 
00034 
00035 
00036 int  arVideoOpen(char *config)
00037 {
00038     if( open_flag == 1 ) return(0);
00039 
00040     /* Connect to the VFW camera */
00041     VisAddProviderRegEntryForVFW();
00042 
00043     VisFindImageSource(sequence);
00044 
00045     if (!(sequence.HasImageSource()) || !(sequence.ImageSource().IsValid()))
00046         error_exit();
00047 
00048     // Don't use continuous grab since it chews up the processor like crazy
00049     sequence.ImageSource().SetUseContinuousGrab(false);
00050 
00051     // Grab an initial image
00052     if (!sequence.Pop(image, 40000))
00053     printf("Error in v_open: Couldn't get the image (init)\n");
00054 
00055     printf("Size = [%d, %d]\n", image.Width(), image.Height());
00056 
00057 
00058     open_flag = 1;
00059         
00060 #ifdef FLIPPED
00061     // memory for a flipped copy of the image (for the USB camera)
00062     flipped_image.Allocate(image.Width(), image.Height());
00063 #endif
00064 
00065     return(0);
00066 }
00067 
00068 int arVideoClose(void)
00069 {
00070     if( open_flag == 0 ) return(-1);
00071 
00072     return(0);
00073 }
00074 
00075 
00076 int        arVideoDispOption( void )
00077 
00078 {
00079 
00080         return 0;
00081 
00082 }
00083 
00084 
00085 int arVideoInqSize( int *x, int *y )
00086 {
00087     if( open_flag == 0 ) return(-1);
00088 
00089     *x = image.Width();
00090     *y = image.Height();
00091 
00092     return(0);
00093 }
00094 
00095 unsigned char *arVideoGetImage( void )
00096 {
00097 #ifdef FLIPPED
00098     int             i, j;
00099 #endif
00100 
00101     if( open_flag == 0 )              return(NULL);
00102 
00103     if (!sequence.Pop(image, 20000)){
00104         printf("Couldn't get the image\n");
00105         return NULL;
00106     }
00107 
00108 #ifdef FLIPPED
00109     // make a flipped copy
00110     for (j = 0; j < image.Height(); j++){
00111         for (i = 0; i < image.Width(); i++){
00112             flipped_image.Pixel(i,(image.Height()-1-j)).SetR( image.Pixel(i, j).R() );
00113             flipped_image.Pixel(i,(image.Height()-1-j)).SetG( image.Pixel(i, j).G() );
00114             flipped_image.Pixel(i,(image.Height()-1-j)).SetB( image.Pixel(i, j).B() );
00115             flipped_image.Pixel(i,(image.Height()-1-j)).SetA( image.Pixel(i, j).A() );
00116         }
00117     }
00118     return (unsigned char*)flipped_image.PbPixel(flipped_image.StartPoint());
00119 #endif
00120 
00121 //  printf("Size = [%d, %d]\n", image.Width(), image.Height());
00122     return (unsigned char*)image.PbPixel(image.StartPoint());
00123 
00124     return(NULL);
00125 }
00126 
00127 int        arVideoCapStart( void )
00128 
00129 {
00130 
00131         return 0;
00132 
00133 }
00134 
00135 int        arVideoCapStop( void )
00136 
00137 {
00138 
00139         return 0;
00140 
00141 }
00142 
00143 int        arVideoCapNext( void )
00144 {
00145 
00146         return 0;
00147 
00148 }
00149 
00150 
00151 static void error_exit(void)
00152 {
00153     printf("Error_exit in Win32video_sub\n");
00154     exit(0);
00155 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


ar_recog
Author(s): Graylin Trevor Jay and Christopher Crick
autogenerated on Fri Jan 25 2013 12:15:00