If you subtract the mean in your C++ approach, is image transformed to a float32 image or is it still a uint8 image and thus clipped to [0, 255]?
As far as I know, OpenCV loads the image in BGR, so you might want to permute the mean vector (since your comment says it’s in RGB).