How To Draw a Line In OpenCV Python? To draw a line, we need to select the starting and ending coordinates of the line. First, let's create a black image and draw a green line. We need to use the code below to create a black image: image = np.zeros(( 360 , 360 , 3 ) , np.uint8) Now we can create our line. cv2.line(image , ( 0 , 0 ) , ( 511 , 511 ) , ( 0 , 255 , 0 ) , 5 ) The code for creating a line is as follows: import numpy as np import cv2 image = np.zeros(( 360 , 360 , 3 ) , np.uint8) cv2.line(image , ( 0 , 0 ) , ( 511 , 511 ) , ( 0 , 255 , 0 ) , 5 ) cv2.imshow( "image" , image) cv2.waitKey( 0 ) cv2.destroyAllWindows() Output: Another Example import numpy as np import cv2 image = np.zeros(( 360 , 360 , 3 ) , np.uint8) cv2.line(image , ( 0 , 180 ) , ( 360 , 180 ) , ( 0 , 255 , 0 ) , 5 ) cv2.imshow( "image" , image) cv2.waitKey( 0 ) cv2.destroyAllWindows() Output: