'**SUMMARY**
To train the TemporalColorTracker you provide it with a video, camera, or ImageSet and either
an region of interest (ROI) or a function of the form:
(R,G,B) = MyFunction(Image)
This function takes in an image and returns a tuple of RGB balues for the frame.
The TemoralColroTracker will then attempt to find the maximum peaks in the data
and create a model for the peaks.
**PARAMETERS**
* *src* - An image source, either a camera, a virtual camera (like a video) or
an ImageSet.
* *roi* - An ROI object that tells the tracker where to look in the frame.
* *extractor* - A function with the following signature:
(R,G,B) = Extract(Image)
* *doCorr* - Do correlation use correlation to confirm that the signal is present.
* *maxFrames* - The maximum number of frames to use for training.
* *ssWndw* - SteadyState window, this is the size of the window to look for a steady
state, i.e a region where the signal is not changing.
* *pkWndw* - The window size to look for peaks/valleys in the signal. This is roughly
the period of the signal.
* *pkDelta* - The minimum difference between the steady state to look for peaks.
* *corrStdMult* - The maximum correlation standard deviation of the training set
to use when looking for a signal. This is the knob to dial in when using correlation
to confirm the event happened.
* *forceChannel* - A string that is the channel to use. Options are:
* \'r\' - Red Channel
* \'g\' - Green Channel
* \'b\' - Blue Channel
* \'h\' - Hue Channel
* \'i\' - Intensity Channel
By default this module will look at the signal with the highest peak/valley swings.
You can manually overide this behavior.
* *verbose* - Print debug info after training.
**RETURNS**
Nothing, will raise an exception if no signal is found.
**EXAMPLE**
A really simple example
>>>> cam = Camera(1)
>>>> tct = TemporalColorTracker()
>>>> img = cam.getImage()
>>>> roi = ROI(img.width*0.45,img.height*0.45,img.width*0.1,img.height*0.1,img)
>>>> tct.train(cam,roi=roi,maxFrames=250)
>>>> disp = Display((800,600))
>>>> while disp.isNotDone():
>>>>     img = cam.getImage()
>>>>     result = tct.recognize(img)
>>>>     roi = ROI(img.width*0.45,img.height*0.45,img.width*0.1,img.height*0.1,img)
>>>>     roi.draw(width=3)
>>>>     img.drawText(str(result),20,20,color=Color.RED,fontsize=32)
>>>>     img = img.applyLayers()
>>>>     img.save(disp)'

def train(self, src, roi=None, extractor=None, doCorr=False, maxFrames=1000, ssWndw=0.05, pkWndw=30, pkDelta=3, corrStdMult=2.0, forceChannel=None, verbose=True):

    if ((roi is None) and (extractor is None)):
        raise Exception('Need    to    provide    an    ROI    or    an    extractor')
    self.doCorr = doCorr
    self.corrStdMult = corrStdMult
    self._extractor = extractor
    self._roi = roi
    self._extract(src, maxFrames, verbose)
    self._findSteadyState(windowSzPrct=ssWndw)
    self._findPeaks(pkWndw, pkDelta)
    self._extractSignalInfo(forceChannel)
    self._buildSignalProfile()
    if verbose:
        for key in self.data.keys():
            print (30 * '-')
            print 'Channel:    {0}'.format(key)
            print 'Data    Points:    {0}'.format(len(self.data[key]))
            print 'Steady    State:    {0}+/-{1}'.format(self._steadyState[key][0], self._steadyState[key][1])
            print 'Peaks:    {0}'.format(self.peaks[key])
            print 'Valleys:    {0}'.format(self.valleys[key])
            print 'Use    Peaks:    {0}'.format(self.doPeaks[key])
        print (30 * '-')
        print 'BEST    SIGNAL:    {0}'.format(self._bestKey)
        print 'BEST    WINDOW:    {0}'.format(self._window)
        print 'BEST    CUTOFF:    {0}'.format(self._cutoff)
