I am opening images from a folder using glob function. The images are RGB. I am trying to convert them to Grayscale using the cv::cvColor(RGB, GRAY, cv::COLOR_RGB2GRAY). For some reason memory problem appears in Visual Studio 2019 as shown in image above. Could someone help me ?
In the first loop open you load all images and push to an array.
Second loop, do nothing. just sets the variable Sum_BGR to point to the last image in the array.
Third loop, just try to convert the value in Sum_BGR ( that is pointing to the last image ) and store it in Sum variable.
If you need all images to be in gray scale, you can just open them as gray scale ( even if they are truly in color ) using cv::IMREAD_GRAYSCALE