opencv_traincascade to train in different colorspace
I am trying to modify the opencv traincascade source which is used to train the cascade classifier to detect objects. The original implementation of the Viola Jones algorithm uses only grayscale images to train the classifier. I am trying the change the metric used to calculate the haar feature value over an image and also make the rest of the source complaint to operating on a 3 channel colorspace. If anyone had already worked in improving or modifying this particular implementation in opencv please let me know where exactly should I make this modification for haar feature metric.
The original implementation calculates the feature value by taking the difference between sum of pixel intensities of the image under black portion of the window and the sum of pixel intensities under the white portion of the window. I am planning to modify it to taking the root mean square of all the differences in all the 3 channels.
I would appreciate any comments and suggestions on my approach. Please also help me with decoding the source.
Thanks.
PS: The method also allows LBP and HOG features but I am interested only in modifying the Haar Features.