WPILib 2012
WPILibRoboticsLibraryforFRC
Vision2009/AxisCamera.h
00001 /********************************************************************************
00002 *  Project              : FIRST Motor Controller
00003 *  File Name            : AxisCamera.h          
00004 *  Contributors         : ELF
00005 *  Creation Date        : August 12, 2008
00006 *  Revision History     : Source code & revision history maintained at sourceforge.WPI.edu    
00007 *  File Description     : Globally defined values for the FRC Camera API
00008 * 
00009 *  API: Because nivision.h uses C++ style comments, any file including this
00010 *  must be a .cpp instead of .c.
00011 * 
00012 */
00013 /*----------------------------------------------------------------------------*/
00014 /*        Copyright (c) FIRST 2008.  All Rights Reserved.                     */
00015 /*  Open Source Software - may be modified and shared by FRC teams. The code  */
00016 /*  must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
00017 /*----------------------------------------------------------------------------*/
00018 
00019 #ifndef __AXISCAMERA_H__
00020 #define __AXISCAMERA_H__
00021 
00022 #include "nivision.h"
00023 
00025 #define CAMERA_PORT 80
00026 
00027 #define CAMERA_IMAGE_STALE_TIME_SEC 2.0  
00028 
00029 #define MAX_BLOCKING_TIME_SEC 0.5
00030 
00031 /*  Enumerated Types */
00033 enum FrcvCameraMetric {CAM_STARTS, CAM_STOPS, 
00034         CAM_NUM_IMAGE, CAM_BUFFERS_WRITTEN, CAM_BLOCKING_COUNT,
00035         
00036         CAM_SOCKET_OPEN, CAM_SOCKET_INIT_ATTEMPTS, CAM_BLOCKING_TIMEOUT,
00037         CAM_GETIMAGE_SUCCESS, CAM_GETIMAGE_FAILURE, 
00038         
00039         CAM_STALE_IMAGE, CAM_GETIMAGE_BEFORE_INIT, CAM_GETIMAGE_BEFORE_AVAILABLE,
00040         CAM_READ_JPEG_FAILURE, CAM_PID_SIGNAL_ERR, 
00041         
00042         CAM_BAD_IMAGE_SIZE, CAM_HEADER_ERROR};
00043 
00044 #define CAM_NUM_METRICS 17
00045 
00047 IMAQ_FUNC int Priv_SetWriteFileAllowed(UINT32 enable); 
00048 
00052 enum ImageResolution { k640x480, k320x240, k160x120 };
00053 
00057 enum ImageRotation { ROT_0 = 0, ROT_180 = 180 };
00058 
00059 
00060 
00061 int StartCameraTask();
00062 
00063 extern "C" {
00064 /*  Image Acquisition functions */
00065 /* obtains an image from the camera server */
00066 int GetImage(Image* cameraImage, double *timestamp);
00067 int GetImageBlocking(Image* cameraImage, double *timestamp, double lastImageTimestamp);
00068 /* obtains raw image string to send to PC */
00069 int GetImageData(char** imageData, int* numBytes, double* currentImageTimestamp);
00070 int GetImageDataBlocking(char** imageData, int* numBytes, double* timestamp, double lastImageTimestamp);
00071 
00072 /* start the camera server */
00073 void StartImageAcquisition();
00074 void StopImageAcquisition();
00075 void StartImageSignal(int taskId);
00076 
00077 /* status & metrics */
00078 int frcCameraInitialized();
00079 int GetCameraMetric(FrcvCameraMetric metric);
00080 
00081 /* camera configuration */
00082 int ConfigureCamera(char *configString);
00083 int GetCameraSetting(char *configString, char *cameraResponse);
00084 int GetImageSetting(char *configString, char *cameraResponse);
00085 
00086 /* camera task control */
00087 
00088 int StartCameraTask(int frames, int compression, ImageResolution resolution, ImageRotation rotation);
00089 int StopCameraTask();
00090 }
00091 #endif
00092 
 All Classes Functions Variables