Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Display the bottom image of the line and cut the upper image using Opencv
#1
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:
İmage


Suggestion on this will be very helpful


Attached Files Thumbnail(s)
   
Quote
#2
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")

Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  OpenCV - Segmentation fault samtwilliams 2 137 Yesterday, 12:45 AM
Last Post: Larz60+
  New to Python, help with saving image from camera tantony 2 341 Sep-13-2019, 05:19 PM
Last Post: tantony
  Upper-Bound Exclusive Meaning Johnny1998 1 223 Aug-02-2019, 08:32 PM
Last Post: ichabod801
  OpenCV - Distinguishing between three icons kainev 2 159 Jul-30-2019, 11:57 PM
Last Post: kainev
  NameError: name 'display' is not defined when running code on power bi beginner1 2 467 Jul-24-2019, 11:03 AM
Last Post: beginner1
  export file and display cmd prompt same time jacklee26 1 127 Jul-24-2019, 05:15 AM
Last Post: Larz60+
  Display lines pgoosen 6 243 Jul-19-2019, 11:28 AM
Last Post: pgoosen
  Display output in readable format and save hnkrish 1 126 Jul-19-2019, 09:29 AM
Last Post: Larz60+
  How To Display this Python Code in Web browser? pradhan 1 206 Jul-14-2019, 06:59 PM
Last Post: snippsat
  OpenCV - Doubt in a line. ArjunSingh 1 169 Jul-14-2019, 03:36 PM
Last Post: ThomasL

Forum Jump:


Users browsing this thread: 1 Guest(s)