Apr-26-2019, 07:33 AM
I am trying to crop the live video diagonally. With the help of cv.line, I have mentioned the dimensions and my goal is to display the video of the lower side of the line I have drawn and the upper video should be cropped, As a beginner, I was just able to draw a line using the following code:
Output:
![[Image: QJcUL.jpg]](https://i.stack.imgur.com/QJcUL.jpg)
Suggestion on this will be very helpful
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import cv2 cv2.namedWindow( "preview" ) vc = cv2.VideoCapture( 0 ) if vc.isOpened(): # try to get the first frame rval, frame = vc.read() else : rval = False while rval: cv2.imshow( "preview" , frame) rval, frame = vc.read() key = cv2.waitKey( 20 ) if key = = 27 : # exit on ESC break else : cv2.line(img = frame, pt1 = ( 700 , 5 ), pt2 = ( 5 , 450 ), color = ( 255 , 0 , 0 ), thickness = 1 , lineType = 8 , shift = 0 ) vc.release() cv2.destroyWindow( "preview" ) |
![[Image: QJcUL.jpg]](https://i.stack.imgur.com/QJcUL.jpg)
Suggestion on this will be very helpful