WPILib 2012
WPILibRoboticsLibraryforFRC
Vision2009/TrackAPI.h
00001 /********************************************************************************
00002 *  Project              : FIRST Motor Controller
00003 *  File Name            : TrackAPI.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 FIRST Vision API
00008 */
00009 /*----------------------------------------------------------------------------*/
00010 /*        Copyright (c) FIRST 2008.  All Rights Reserved.                     */
00011 /*  Open Source Software - may be modified and shared by FRC teams. The code  */
00012 /*  must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
00013 /*----------------------------------------------------------------------------*/
00014 
00015 #ifndef __TRACKAPI_H__
00016 #define __TRACKAPI_H__
00017 
00018 #include "VisionAPI.h"
00019 #include "BaeUtilities.h"
00020 
00021 /*  Constants */
00027 #define PARTICLE_TO_IMAGE_PERCENT 0.01
00028 
00029 /*  Structures */
00030 typedef struct TrackingThreshold_struct {
00031         char name[64];
00032         Range hue;
00033         Range saturation;
00034         Range luminance;
00035 } TrackingThreshold;
00036                 
00037 /*  Enumerated Types */
00038 
00040 typedef enum FrcHue_enum { 
00041         // Basic colors
00042         RED, GREEN, BLUE, YELLOW, ORANGE, PURPLE, WHITE, PINK
00043 }FrcHue;
00044 
00046 typedef enum FrcLight_enum { 
00047         PASSIVE_LIGHT, BRIGHT_LIGHT, ACTIVE_LIGHT, WHITE_LIGHT, FLUORESCENT
00048 }FrcLight;
00049         
00050 /* color tracking support functions */
00051 TrackingThreshold GetTrackingData(FrcHue hue, FrcLight light);
00052 
00053 void PrintReport(ParticleAnalysisReport* myReport);
00054 void PrintReport(ColorReport* myReport);
00055 void PrintReport(TrackingThreshold* myReport);
00056 
00057 /*  Tracking functions */
00058 
00059 /* find a color in current camera image */
00060 bool InArea(Image* binaryImage, int particleIndex, Rect rect);
00061 int GetLargestParticle(Image* binaryImage, int* particleNum);
00062 int GetLargestParticle(Image* binaryImage, int* particleNum, Rect rect);
00063 int FindColor(FrcHue color, ParticleAnalysisReport* trackReport);
00064 int FindColor(const Range* hueRange, ParticleAnalysisReport *trackReport);
00065 int FindColor(const Range* hueRange, int minSaturation, ParticleAnalysisReport *trackReport);
00066 int FindColor(ColorMode mode, const Range* plane1Range, const Range* plane2Range, 
00067                 const Range* plane3Range, ParticleAnalysisReport *trackReport);
00068 int FindColor(ColorMode mode, const Range* plane1Range, const Range* plane2Range, 
00069                 const Range* plane3Range, ParticleAnalysisReport *trackReport, ColorReport *colorReport);
00070 int FindColor(ColorMode mode, const Range* plane1Range, const Range* plane2Range, 
00071                 const Range* plane3Range, ParticleAnalysisReport *trackReport, 
00072                 ColorReport *colorReport, Rect rect);
00073 #endif
00074 
 All Classes Functions Variables