'**SUMMARY**
Train the face recognizer with images and labels.
**PARAMETERS**
* *images*    - A list of Images or ImageSet. All the images must be of
same size.
* *labels*    - A list of labels(int) corresponding to the image in
images.
There must be at least two different labels.
* *csvfile*   - You can also provide a csv file with image filenames
and labels instead of providing labels and images
separately.
* *delimiter* - The delimiter used in csv files.
**RETURNS**
Nothing. None.
**EXAMPLES**
>>> f = FaceRecognizer()
>>> imgs1 = ImageSet(path/to/images_of_type1)
>>> labels1 = [0]*len(imgs1)
>>> imgs2 = ImageSet(path/to/images_of_type2)
>>> labels2 = [1]*len(imgs2)
>>> imgs3 = ImageSet(path/to/images_of_type3)
>>> labels3 = [2]*len(imgs3)
>>> imgs = imgs1 + imgs2 + imgs3
>>> labels = labels1 + labels2 + labels3
>>> f.train(imgs, labels)
>>> img = Image("some_image_of_any_of_the_above_type")
>>> print f.predict(img)
Save Fisher Training Data
>>> f.save("trainingdata.xml")
Load Fisher Training Data and directly use without trainging
>>> f1 = FaceRecognizer()
>>> f1.load("trainingdata.xml")
>>> img = Image("some_image_of_any_of_the_above_type")
>>> print f1.predict(img)
Use CSV files for training
>>> f = FaceRecognizer()
>>> f.train(csvfile="CSV_file_name", delimiter=";")
>>> img = Image("some_image_of_any_of_the_type_in_csv_file")
>>> print f.predict(img)'

def train(self, images=None, labels=None, csvfile=None, delimiter=';'):

    if (not self.supported):
        warnings.warn('Fisher    Recognizer    is    supported    by    OpenCV    >=    2.4.4')
        return None
    if csvfile:
        images = []
        labels = []
        import csv
        try:
            f = open(csvfile, 'rb')
        except IOError:
            warnings.warn('No    such    file    found.    Training    not    initiated')
            return None
        self.csvfiles.append(csvfile)
        filereader = csv.reader(f, delimiter=delimiter)
        for row in filereader:
            images.append(Image(row[0]))
            labels.append(row[1])
    if isinstance(labels, type(None)):
        warnings.warn('Labels    not    provided.    Training    not    inititated.')
        return None
    self.labels_set = list(set(labels))
    i = 0
    for label in self.labels_set:
        self.labels_dict.update({label: i})
        self.labels_dict_rev.update({i: label})
        i += 1
    if (len(self.labels_set) < 2):
        warnings.warn('At    least    two    classes/labels    are    requiredfor    training.    Training    not    inititated.')
        return None
    if (len(images) != len(labels)):
        warnings.warn('Mismatch    in    number    of    labels    and    number    oftraining    images.    Training    not    initiated.')
        return None
    self.imageSize = images[0].size()
    (w, h) = self.imageSize
    images = [(img if (img.size() == self.imageSize) else img.resize(w, h)) for img in images]
    self.int_labels = [self.labels_dict[key] for key in labels]
    self.train_labels = labels
    labels = np.array(self.int_labels)
    self.train_imgs = images
    cv2imgs = [img.getGrayNumpyCv2() for img in images]
    self.model.train(cv2imgs, labels)
