blob: 64312179bdecfa104846d23e47c4b1949ae44557 [file] [log] [blame]
jerrymf1579332013-02-07 01:56:28 +00001/********************************************************************************
2* Project : FIRST Motor Controller
3* File Name : TrackAPI.h
4* Contributors : ELF
5* Creation Date : August 12, 2008
6* Revision History : Source code & revision history maintained at sourceforge.WPI.edu
7* File Description : Globally defined values for the FIRST Vision API
8*/
9/*----------------------------------------------------------------------------*/
10/* Copyright (c) FIRST 2008. All Rights Reserved. */
11/* Open Source Software - may be modified and shared by FRC teams. The code */
12/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
13/*----------------------------------------------------------------------------*/
14
15#ifndef __TRACKAPI_H__
16#define __TRACKAPI_H__
17
18#include "VisionAPI.h"
19#include "BaeUtilities.h"
20
21/* Constants */
22/** image quality requirement: particle must be this % of pixels
23 * For instance, a 320x240 image has 76800 pixels. With this
24 * tolerance at .01, the image must be 768 pixels.
25 * Use a percentage instead of a fixed # of pixels so different
26 * image sizes will work the same way */
27#define PARTICLE_TO_IMAGE_PERCENT 0.01
28
29/* Structures */
30typedef struct TrackingThreshold_struct {
31 char name[64];
32 Range hue;
33 Range saturation;
34 Range luminance;
35} TrackingThreshold;
36
37/* Enumerated Types */
38
39/** Predefined hues */
40typedef enum FrcHue_enum {
41 // Basic colors
42 RED, GREEN, BLUE, YELLOW, ORANGE, PURPLE, WHITE, PINK
43}FrcHue;
44
45/** Predefined saturation / luminance settings */
46typedef enum FrcLight_enum {
47 PASSIVE_LIGHT, BRIGHT_LIGHT, ACTIVE_LIGHT, WHITE_LIGHT, FLUORESCENT
48}FrcLight;
49
50/* color tracking support functions */
51TrackingThreshold GetTrackingData(FrcHue hue, FrcLight light);
52
53void PrintReport(ParticleAnalysisReport* myReport);
54void PrintReport(ColorReport* myReport);
55void PrintReport(TrackingThreshold* myReport);
56
57/* Tracking functions */
58
59/* find a color in current camera image */
60bool InArea(Image* binaryImage, int particleIndex, Rect rect);
61int GetLargestParticle(Image* binaryImage, int* particleNum);
62int GetLargestParticle(Image* binaryImage, int* particleNum, Rect rect);
63int FindColor(FrcHue color, ParticleAnalysisReport* trackReport);
64int FindColor(const Range* hueRange, ParticleAnalysisReport *trackReport);
65int FindColor(const Range* hueRange, int minSaturation, ParticleAnalysisReport *trackReport);
66int FindColor(ColorMode mode, const Range* plane1Range, const Range* plane2Range,
67 const Range* plane3Range, ParticleAnalysisReport *trackReport);
68int FindColor(ColorMode mode, const Range* plane1Range, const Range* plane2Range,
69 const Range* plane3Range, ParticleAnalysisReport *trackReport, ColorReport *colorReport);
70int FindColor(ColorMode mode, const Range* plane1Range, const Range* plane2Range,
71 const Range* plane3Range, ParticleAnalysisReport *trackReport,
72 ColorReport *colorReport, Rect rect);
73#endif
74