I would like to know how to make a hollow circle, with boxes and distance joint, something like this:
(source: subirimagenes.com)
I've tried it but I cant get a perfect circle, any idea? thanks
Here is one route.
Draw a regular n-gon. Below, the blue is a regular 16-gon.
Then translate each edge outward radially, and connect each
translated (red) edge to its original (blue):
Related
Looking for a solution to get the grid lines inside or over the polar area points.
Like the image attached.
I found the code which draws the gridLines and the one draws the point.
I also see it's possible to pass a creationPattern() as background.
But I don't know how to get them working together.
Maybe a solution can be simply show the gridLines over the points and not behind.
Does opencv have a function that can visually depict the gradient directions of an image?
Ie, a function that draws arrows over the top to visually show which direction the gradient slope runs? Or maybe colourise the image where red = angle 0 and so on?
Below is an example of what I mean when I say "visually depict the gradient directions of an image":
I know other people have done this but I don't want to reinvent the wheel if there is an OpenCV function or publically available function out there.
No, you need to implement it by yourself.
What is the best or easiest way to connect the dots on the given diagram. I would like to connect the dots to form a rectangle. The dots are initially blue color.
If you want to create tetragon (shape with 4 vertixes) instead of rectangle (shape with 4 vertixes and all angles equal to 90 degrees) - i. e. connect points that human can simply classify as lines, the simplest way is creating array with points coordinates, and then applying cv::approxPolyDP or cv::convexHull.
You did not specified what kind of shapes you want to get, convex or concave.
Miki mentioned convex hull algorithm.
You can also search for Concave Hull algorithm.
Here is one of possible sources in C++:
https://bitbucket.org/vostreltsov/concave-hull/src
Here is also some theory: http://www.it.uu.se/edu/course/homepage/projektTDB/ht13/project10/Project-10-report.pdf
Or if you search for rectangles only then take a look at cv::minAreaRect method from OpenCV.
I'm a newbie in OpenCV, and I want to know if you could select a contour in a processed image, for example, you are detecting 1 circle 2 squares and 1 triangle, and you want to know the distance between the triangle and 1 square right now, so i wish to know if you can select the figures in the processed image with a mouse instance or something like that, also, change the selection, like if i want to know the distance between the circle and square or circle and triangle, something like it. I don't know if I've explained myself, but I would appreciate your help. Thanks
Yes, it is possible (when you get there) but I'll recommend you split it into baby steps. This project is hard work, it will not happen in one day. I'll recommend scaling it down initially, aiming low and only after completion, to increase the task's complexity:
Have a circle, triangle, and square
Identify their contours
Identify the shape of each object
Compute and print out the distance between the centroids of the square and triangle.
Avast there fellow programmers!
I have the following problem:
I have two rectangles overlapping like shown on the picture below.
I want to figure out the polygon consisting of point ABCDEF.
Alternate christmas description: The red cookie cutter is cutting away a bit of the black cookie. I want to calculate the black cookie.
Each rectangle is a data structure with 4 2d-vertices.
What is the best algorithm to achieve this?
This is a special case of general 2D polygon clipping. A good place to start is the Weiler-Atherton algorithm. Wikipedia has a summary and links to the original paper. The algorithm seems to match the data structure you've described pretty well.
Note that it's quite possible you'll end up with a rectangle with a hole in it (if the red one is entirely inside the black one) or even two rectangles (eg if the red is taller and skinnier than the black). If you're certain there is only one corner of the red rectangle inside the black one then the solution should be much simpler.
constructive solid geometry
How precise are the coordinates? If the rectangles are fairly small, the easiest approach might be to just paint them on a canvas, black rectangle first, followed by red. The remaining black pixels on the canvas are the polygon that's left.
Another approach is to split the coordinate grid into a bunch of rectangles based on all of the sides of the rectangles (not counting unbounded rectangles, you have up to 9 rectangles generated if you have two original rectangles). Then just test a representative point from each of these rectangles for membership in the particular polygons to determine which rectangles are in and which are out.
I found some stuff here I might use:
http://www.cgal.org/Manual/3.3/doc_html/cgal_manual/Boolean_set_operations_2/Chapter_main.html
I actually downloaded the CGAL source before I even posted this question, but I think I'll look closer into it.