There are other ways to do it, you don't need openCV, in the end the image is a matrix an you can do it with multiplication, look at this post:
How can I convert an RGB image into grayscale in Python?
EDIT: Giving the solution in case link changes.
An image can be seen as 3 matrices, one for red, one for green and one for blue, the three channel colours RGB, each one with the information for each pixel ranging between 0 and 255. To transform it to gray scale image it is necessary to sum all the colours by the representation of their luminosity, which is a coeficient already known obtained in an ecuation system:
def rgb2gray(rgb):
r, g, b = rgb[:,:,0], rgb[:,:,1], rgb[:,:,2]
gray = 0.2989 * r + 0.5870 * g + 0.1140 * b
return gray
In openCV I don't know if there is a function, however this should be enough.