cv2.fitline() usage and exmaple [closed] - python

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 days ago.
Improve this question
So I have centre points from of contours stored in a points array.I am having trouble understanding how to use a fitline() function. can someone give an example?
points=\[\]
for i in contours:
if cv2.contourArea(i)\>200:
M = cv2.moments(i)
if M\['m00'\] != 0:
cx = int(M\['m10'\]/M\['m00'\])
cy = int(M\['m01'\]/M\['m00'\])
points.append((cx,cy))
points= np.array(points)
points = points.astype(np.float32)

Related

How to get the flipped coordinates in a rectangle (python) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 days ago.
Improve this question
I am a novice. I don't know how to write the following code:
I have a rectangular box. There is a point in the box. How to get the new coordinates for the point after turning the image horizontally.
How to get the new position of the point after a horizontal flip
Their position has changed from (100, 150) to (100, 50)
Thank you.

Python: How to check whether a Circle has equal radius along all 360 degrees [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Using Python, I want to check whether a circle has an equal radius along all 360 degrees. Actually, I have segmented a circular shape from an image and then want to check whether it has a same-sized and equal radius along all the 360 degrees or not.
Can someone kindly help and tell how to do that?
In Python, OpenCV is a strong choice for an imaging library. You'd want to fit a contour to the circle and use moments to check the properties. You can fit an ellipse and see how close the major and minor axis of the ellipse match.
See this tutorial/docs for details.
Also, this question should help.

Use of OCR to read node graphs [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I would like to code a program that will use a phones camera to read a node graph and then perform dijkstra's algorithm on it, displaying the shortest path.
Could pytesseract or other OCR tools for python read node graphs (such as in the image. Real use would be on printed ones) and give me enough information to get node coordinates and what letters are next to them, as well as the positions of the edges/which nodes they connect and what numbers are next to them?
Any help would be much appreciated.
https://i.stack.imgur.com/RUZwA.jpg

trouble in finding pixel by pixel difference of two images [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
rows, cols = img1.shape[:2]
x = np.random.randint(0, 255, (w1, h1))
for i in range(rows):
for j in range(cols):
k = x[i, j]
I am finding difficulty in completing the code for finding the pixel by pixel difference of two images in Python OpenCV. Could you please help me with the right code.
In any case you should avoid loops over single pixels, but use operations which work on full images
You may want to have a look at the general OpenCV Python tutorial.
There is a chapter on arithmetic operation on images, this is what you are looking for:
http://docs.opencv.org/3.1.0/d0/d86/tutorial_py_image_arithmetics.html#gsc.tab=0
The pdf version of the complete tutorial can be found here:
https://media.readthedocs.org/pdf/opencv-python-tutroals/latest/opencv-python-tutroals.pdf

Newbie Python Exercise - find distance between points. [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
OK so, in my first programming class. I did all the homework exercises except this one. I cannot quite wrap my head around what is asking me to do (related to the text I read) so I thought I would ask here.
Q: A dartboard of radius 10 and the wall it is hanging on are
represented using the two-dimensional coordinate system, with the
board's center at coordinate (0, 0). Variables x and y store the x-
and y-coordinate of a dart hit. Write an expression using variables x
and y that evaluates to true if the dart hits (is within) the
dartboard, and evaluate the expression for these dart coordinates:
(0,0) (10,10) (6,-6) (-7,8)
I honestly do not know where to start here. Help? Hints?
Your problem isn't Python: it's reading English.
You have a dartboard at (0,0) of radius 10. You're asked to write a program to look at the four points you're given and tell whether or not they would hit the dartboard.
What's the formula for distance from a center (x0, y0)?
r = sqrt((x-x0)^2 + (y-y0)^2)
If you calculate r <= 10, it hits the dartboard.

Categories