Ask Your Question

Display the bottom image of the line and cut the upper image using Opencv

asked 2019-04-26 02:17:55 -0500

varul gravatar image

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:

import cv2

vc = cv2.VideoCapture(0)

if vc.isOpened(): # try to get the first frame
    rval, frame =
    rval = False

while rval:
    cv2.imshow("preview", frame)
    rval, frame =
    key = cv2.waitKey(20)
    if key == 27: # exit on ESC
        cv2.line(img=frame, pt1=(700,5), pt2=(5, 450), color=(255, 0, 0), thickness=1, lineType=8, shift=0)



image description

Suggestion on this will be very helpful

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-04-26 05:04:13 -0500

kbarni gravatar image

You need the fillConvexPoly function with the following points: (0,0), (frame.shape(1),0), (0,frame.shape(0)), (0,0) and black color (0,0,0). Concerning the points, that's the top left corner, then the top right, bottom left and back to top left.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-04-26 02:17:55 -0500

Seen: 31 times

Last updated: Apr 26