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
  How to process the hyperspectral image vokoyo 2 79 7 hours ago
Last Post: vokoyo
  New to Python, help with saving image from camera tantony 2 364 Sep-13-2019, 05:19 PM
Last Post: tantony
  Upper-Bound Exclusive Meaning Johnny1998 1 225 Aug-02-2019, 08:32 PM
Last Post: ichabod801
  OpenCV - Doubt in a line. ArjunSingh 1 169 Jul-14-2019, 03:36 PM
Last Post: ThomasL
  write image into string format into text file venkat18 2 342 Jun-01-2019, 06:46 AM
Last Post: venkat18
  how to analayze only a part of an image? nadavrock 2 223 May-28-2019, 04:42 AM
Last Post: heiner55
  Problems with getting image's DateTimeOriginal Pythenx 3 218 May-02-2019, 02:21 PM
Last Post: DeaD_EyE
  creating an image Rafi 1 175 Apr-24-2019, 07:17 PM
Last Post: gontajones
  How to determine pen color from an image? robie972003 2 268 Mar-24-2019, 10:06 PM
Last Post: robie972003
  Locating Grids in full page image KolGuy80 0 217 Mar-20-2019, 09:47 AM
Last Post: KolGuy80

Forum Jump:


Users browsing this thread: 1 Guest(s)