Fastest method to extract the R, G and B values from an image in c++ (OpenCV)

I’m currently working on a traffic light detection code, that I would like to implement on a Raspberry Pi 3.
To do it, I need to have the fastest program possible to detect in real time the different traffic lights. At one step of my program, I need to separate the R, G and B values from an RGB image. The only problem is that with my method, it takes 80000ms approximately to only do this (due to the imwrite and imread function I think).
Here is my code :

    Mat bgr[3];
    split(cropped_img, bgr);
    imwrite("blue.png", bgr[0]);
    imwrite("green.png", bgr[1]);
    imwrite("red.png", bgr[2]);

    Mat red_img = imread("red.png", IMREAD_COLOR);
    Mat green_img = imread("green.png", IMREAD_COLOR);
    Mat blue_img = imread("blue.png", IMREAD_COLOR);

So does anyone have a solution to make this part much faster ?

Thank’s a lot and have a nice week !

Source: Windows Questions C++