Display the bottom image of the line and cut the upper image using Opencv - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Display the bottom image of the line and cut the upper image using Opencv (/thread-17853.html) |
Display the bottom image of the line and cut the upper image using Opencv - jenkins43 - Apr-26-2019 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 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")Output: Suggestion on this will be very helpful RE: Display the bottom image of the line and cut the upper image using Opencv - heiner55 - May-27-2019 The idea is: rotate, crop, rotate back: #!/usr/bin/python3 import cv2 import imutils cv2.namedWindow("preview"). vc = cv2.VideoCapture('test.mp4') 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() if rval: frame = imutils.rotate_bound(frame, 45) h = frame.shape[0] w = frame.shape[1] frame = frame[h//2:h, 0:w] frame = imutils.rotate_bound(frame, -45) key = cv2.waitKey(20) if key == 27: # exit on ESC break vc.release() cv2.destroyWindow("preview") |