How Transform animation works? - manim

I am trying to understand how manim automatically figures out how to smoothly transform, say, a Circle() into Square()?
Is this a common pattern? Is Manim unique in this respect or are there similar libraries which do the same magic? I am interested in figuring out how to create manim animations for iOS without running python.

I'm not going to explain all the math behind it, just an outline so you can learn on your own.
In Manim, every curve that you generate (circles, squares, etc.) is a Bezier Curve, these curves have very special properties and are widely used in multimedia and graphic design software.
The transformations are essentially interpolations between Bezier curves, that is, if you want to transform a circle into a square, what Manim does is take those Bezier curves and interpolate between them using an algorithm.
Learn here Bezier curves.

Related

Creating smooth curve from sampled poitns

I am creating sort of a 'paint' application in which use can draw free curves. If i draw the sampled points as is, the curve does not look smooth.
I tried the algorithm in the following tutorial: http://www.merowing.info/2012/04/drawing-smooth-lines-with-cocos2d-ios-inspired-by-paper/#.U2e1EK2Sy-Q
This tutorial create smooth curves using quad bezier curves.
The result is OK, but still not as good as i would like and i can still see the curve 'breaks'. How can i improve the curves and make them smoother, similar to 'paper' application?

Recognize basic shapes in binarized image using OpenCV

How can I recognize some basic (usually rotated) shapes:
circle,
"empty" circle,
cross,
empty triangle,
using OpenCV? What's the most straightforward way? It would be nice if the user could "define" his own shapes somehow (load a template image, possibly).
I'd like to map each recognized shape to its type (circle, triangle etc.) and a position of its center. (And its rotation if possible).
For circles HoughCircles could be used (there's no rotation in this case, too). But what about the others? Template matching doesn't support rotation and scaling, right?...
Here's the input:
You are right that regular template matching are not rotation, scale invariant. Take a look at OpenCV's matchShapes. Internally, it uses HuMoments. You will need to use findContours to find each individual object. Now once you have done this, you will probably find matchShapes couldn't distinguish Circle from Ring. A simple way to solve this is to use the hierarchy structure from findContours. If there is a hole (large enough) inside a Circle, that's probably a Ring.

iOS drawRect, finding points on a curve

I will draw a curve similar to the red curve in the illustration below (can be a bezier or whatever is most convenient for my purposes I think). I would like to find points on the curve (blue dots in the illo). The points would most likely be divisions of equal parts of the length of the curve.
Can I find these points? I am not seeing a solution in the docs as of yet.
This answer covers segmentation of a Bezier curve using the de Casteljau algorithm. You already have your parameterized values along the curve for segmentation.
(If you follow the link referenced in the answer make sure you have java enabled in your browser, so you can view the example visualisations).

Three Dimensional Hough Space

Im searching for radius and the center coordinates of circle in a image. have already tried 2D Hough transform. but my circle radius is also a unknown. Im still a beginner to Computer vision so need guild lines and help for implementing three dimensional hough space.
You implement it just like 2D Hough space, but with an additional parameter. Pseudo code would look like this:
for each (x,y) in image
for each test_radius in [min_radius .. max_radius]
for each point (tx,ty) in the circle with radius test_radius around (x,y)
HoughSpace(tx,ty,test_radius) += image(x,y)
Thiton gives you the correct approach to formalize the problem. But then, you will run in other problems inherent to the hough transform:
how do you visualize the parameter space? You may implement something with a library like VTK, but 3D visualization of data is always a difficult topic. The visualization is important for debugging your detection algorithm and is one of the nice thing with 2D hough transform
the local maximum detection is non trivial. The new dimension will mean that your parameter space will be more sparse. You will have more tuning to do in this area
If you are looking for a circle detection algorithm, you may have better options than the hough transform (google "Fast Circle Detection Using Gradient Pair Vectors" looks good to me)

OpenCV Identifying Lines and Curves

I'm just starting to learn OpenCV programming. May I just ask about how can I identify lines and curves in OpenCV? My problem is that I have to identify if the image contains a convex or concave (horizontal or vertical curve) curve, a vertical, diagonal or a horizontal line.
In my code, I used CvSetImageROI to take a particular part of an image, and then I'm trying to identify each according to the said lines/curves.
Are there functions in OpenCV that are available? Thank you very much for the help. By the way, i'm using Linux and C++.
Hough transform http://en.wikipedia.org/wiki/Hough_transform, http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm
is the standard way to do it. In its simple form (as implemented in OpenCV) it can detect lines of arbitray position and angle and line segments.
Look here for an example
http://opencv.itseez.com/modules/imgproc/doc/feature_detection.html?highlight=hough#houghlinesp
For curves, the detection process is a bit more complicated, and you need the general Hough transform It is not yet available in OCV, but you can write it as an exercise or look for a good implementation.
http://en.wikipedia.org/wiki/Generalised_Hough_transform describes it (in short)

Resources