How to Draw Line on Image and Video in OpenCV

Machine Learning courses with 100+ Real-time projects Start Now!!

Program 1

import cv2
import numpy
img1=cv2.imread("D://opencvapp/library-img.jpg")
# print(type(img1))
# print(img1)
h=img1.shape[0]
w=img1.shape[1]
#print("height",h)
#print("width",w)

img1=cv2.line(img1,(0,0),(w,h),(0,0,255),10)
img1=cv2.line(img1,(w,0),(0,h),(0,0,255),10)
cv2.imshow('Library Image',img1)
cv2.waitKey(0)
cv2.destroyAllWindows()

 

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *