I’d like to get a 1000 x 1000 picture in Python from any input picture so that the input doesn’t lose it’s aspect ratio. In other words, I want to resize the input so that its longer dimension is 1000 pixels and “fill” the other dimension with the background color until it become…
Tag: opencv
How to get the latest frame from capture device (camera) in opencv
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: However, cap.read seems to only capture the next frame in the queue, and not the latest. I did a lot of searching online, and there seems to be a lot of
RGB average of circles
I’m using OpenCV and PIL in Python. I have 96 circles detected with their center coordinates and radios. I need the average RGB from each circles. Each circle has 6000 pixels, so I thinks iterate one to one it is not efficient. How can I extract the average RGB from each circle? I am ready to use any ot…
Python OpenCV – Extrapolating the largest rectangle off of a set of contour points
I’m trying to make an OpenCV detect a bed in the image. I am running the usual Grayscale, Blur, Canny, and I’ve tried Convex Hull. However, since there’s quite a number of “noise” which gives extra contours and messes up the object detection. Because of this, I am unable to detec…
Cannot install openCV 3.1.0 with python3. CMAKE not including or linking python correctly
I’m trying to get OpenCV 3.1.0 installed with Python3 on my machine. Because I have Ubuntu 16.04, I am following this guide exactly: http://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/ However, I have trouble in step 4, after running cmake. The output of my cmake program has this…
python – opencv morphologyEx remove specific color
After remove captcha’s background. The image remain digits and noise. Noise line is all in one color : RGB(127,127,127) And then using morphology method. Some part of digit will be remove. How to use morphologyEx() remove only color in RGB(127,127,127) ? Answer In order to eliminate color within a parti…
How to detect and draw contours using OpenCV in Python?
I wrote the following code to detect and draw contours: And here is the error I received: Traceback (most recent call last): File “C:/Users/R.K.singh/Desktop/Image processing/intro-to-contours.py”, line 10, in contours,hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE); Val…
Python showing an OpenCV Assertion error for finding contours
I was trying to draw contours in an image using Python OpenCV. My code is the following: I am getting an error while compiling this code. The error is the following: How can I avoid this error? Answer The problem should be that cv2.drawContours (and in general all opencv “drawing” functions in pyt…
implement mat2gray in Opencv with Python
I have the same problem with him: Scaling a matrix in OpenCV I got the same problem with him, I have a colored picture, I used matlab to read the picture: Input = imread(‘input1.jpg’);, and the format of the picture is 612x612x3 uint8, I print the 5x5x1 pixel in the picture as below:Input(1:5,1:5,…
Attribute Error : none type object has no attribute ‘ shape ‘
I keep encountering an attribute error trying to read some frames from a piCamera on a raspberry pi Here is the error: Answer It seems that frame was returned as None in this line as if you camera couldn’t read an image: Then, when resizing a None object, the program blows up as we described in the erro…