opencv3.0

how to get a image from large video using opencv

how to get a image from large video using opencv Question: My code run very well. But this process is tiring my processor. I have 1000+ videos to make it Is there anyone to have more useful code? import cv2 video = cv2.VideoCapture("E:/videos/example1.mp4") length = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) video.get(cv2.CAP_INTELPERC_IMAGE_GENERATOR) print( length ) i=0 while True: ret, frame …

Total answers: 1

TypeError while trying to crop images on opencv

TypeError while trying to crop images on opencv Question: I am trying to crop images from the video but it’s not showing the result. I know that TypeError is happening because there is no content in crop crop_img but since I am a beginner in opencv so I don’t know the solution of it. Below …

Total answers: 1

Using dicom Images with OpenCV in Python

Using dicom Images with OpenCV in Python Question: I am trying to use a dicom image and manipulate it using OpenCV in a Python environment. So far I have used the pydicom library to read the dicom(.dcm) image data and using the pixel array attribute to display the picture using OpenCV imshow method. But the …

Total answers: 4

unable to get contour properly

unable to get contour properly Question: I am playing with openCV and doing simple below task. 1) Read Image 2) thresholding 3) Finding contours. 4) Drawing all contours in the blank image. 5) Drawing individual contour. Drawing all contours on the dummy image looks good, whereas drawing single contour produces scattered contour as shown in …

Total answers: 1

How to draw lines between points in OpenCV?

How to draw lines between points in OpenCV? Question: I have an array of tuples: a = [(375, 193) (364, 113) (277, 20) (271, 16) (52, 106) (133, 266) (289, 296) (372, 282)] How to draw lines between points in OpenCV? Here is my code that isn’t working: for index, item in enumerate(a): print (item[index]) …

Total answers: 2

How to check if point is placed inside contour?

How to check if point is placed inside contour? Question: I have drawn a contour around extreme points. Inside polygon figure I have others points. How to check if they are inside contour? Asked By: OPV || Source Answers: You can use the cv2.pointPolygonTest() function available in OpenCV. For example: dist = cv2.pointPolygonTest(cnt,(50,50),True) In this …

Total answers: 1

Sorting points from distance to a given point x,y here in my case (x=0,y=o)

Sorting points from distance to a given point x,y here in my case (x=0,y=o) Question: I would like to sort (shortest to longest) an array ‘a’ (as given below) to the distance from the origin or a point (in my case 0,0) and store it to a similar array type ‘b’ or replacing the array …

Total answers: 3

process subimages enclosed by opencv boxPoints or contours in-place?

process subimages enclosed by opencv boxPoints or contours in-place? Question: Using opencv3 in python, I have an image with different segments bounded by boxPoints using the code below: (_, conts, _) = cv2.findContours(img, mode=cv2.RETR_EXTERNAL, method=cv2.CHAIN_APPROX_SIMPLE) boxes = [] # loop over contours for c in conts: # get min bounding rect. min_rect_center_xy = min_rect[0] min_rect …

Total answers: 1

How to read/write a matrix from a persistent XML/YAML file in OpenCV 3 with python?

How can I read/write a matrix from a persistent XML/YAML file in OpenCV 3 with Python? Question: I’ve been trying to read and write matrices to persistent file storage (for example, XML) with Anaconda‘s current cv2 (which I believe is actually OpenCV 3.x). I looked at the solutions online for this, and people reference something …

Total answers: 1

How to get the latest frame from capture device (camera) in opencv

How to get the latest frame from capture device (camera) in opencv Question: I want to connect to a camera, and only capture a frame when an event happens (e.g. keypress). A simplified version of what I’d like to do is this: cap = cv2.VideoCapture(device_id) while True: if event: img = cap.read() preprocess(img) process(img) cv.Waitkey(10) …

Total answers: 5