I have one requirement to show the a shape (like Home or Car etc) and depending upon the percentage of the condition will be filled with animation
I was trying with image but when I googled, I found this can be achieved by drawing image using Bezier curve.
So this is the image I am trying to draw and there are other images too.
So here are my two questions :
Can I achieve this using UIImage directly.
If not then how can i draw bezier
curve for such images. How will I calculate the points.
Related
I have two images, one that is a monochrome one which is a mask and another one with full color. What I need to do is find the CGRect of the mask (white pixels) in the other full color one.
What I did is to first find the contour of the mask using the Vision framework. Now, this returns a CGPath which is normalised. How can I translate this path into coordinates to the other image? Both have been scaled the same way to make them the same size so the translation should be "easy" but I can't figure it out.
I'm working on a project which locates the Machine Readable Zone on ID cards.
For this I need to do some pre processing to extract the ID card from a scanned image which typically are randomly disposed on a white page. I'm able to locate the majority of the cards by using a Histogram equalization with CLAHE before a contour detection. But in some cases the border around the MRZ is totally invisible (white on white) as shown on the attached image.
I'd like to detect rectangle of a predefined shape as I know the shape of the ID card will be always the same but so far I wasn't able to find a way do do something like this with OpenCV.
Basically what I need is to find two rectangle of a fixed ratio that best match the 2 cards on the scan.
I'm wondering if I need to try OpenCV matchers or if there is a simpler way to accomplish this kind of detection.
The solution to you problem is likely going to be matrix transformations. The concept is to pinpoint 4 coordinates on the card that can be easily detected using opencv, such as the the rectangle colored in blue & cyan.
Have coordinates of the card with the predefined shape stored in an array, where a corner of the card is at the 0, 0. Also store the coordinates of the blue * cyan rectangle in an array. With the two arrays you can find the perspective transform of the two arrays using the cv2.getPerspectiveTransform method.
Using the perspective transform found, you can detect the coordinates of the whole card every time you detect the coordinates of the blue & cyan rectangle.
Me and my team are working on an app for a client. We are trying to understand how to achieve this kind of animations (refer only to the circle stroke) :
We tried using a CADisplayLink to set up and change the circle, but it generated non-fluid results.
We couldn't find a way to create a circle from "components" of UIBezierPath and change each of the anchors.
Any suggestions on how to achieve this kind of effect, or how to construct a circle from seperated points, would be highly appricated
Best Regards,
Roi and the team
I suggest using Catmull-Rom splines. Those allow you to create smooth curves using only points that are on the curve, whereas Bezier curves require that you define control points that are not on the curve.
Once you have beginning and ending CGPaths its pretty easy to create a CAAnimation of the path from it's starting to it's ending state (although animating change to a CGPath only works correctly if the starting and ending paths in the animation have the same number and type of points.)
You could probably also use Bezier curves, but you would need to generate the control points for the circle and it's distorted shape.
Check out this sample app that uses Catmull-Rom splines to create a distorted circle shape:
http://wareto.com/animating-shapes-using-cashapelayer-and-cabasicanimation
(Written in Objective-C, but the technique is the same in Swift.)
A Catmull-Rom spline with 8 control points evenly spaced around a circle where the distance from the center of each control points is varied by ± r/12 seems about right:
I have downloaded the new Facebook messanger App for iOS. I was wondering, is there some option that allows to "crop" an image and leave only a circle?
Would be great to be able to put a UIImage which is rectangular and crop the circular part.
Or do you think this is done server-side? In other words, there is no special iOS cropping function but simply a cropping software on the Facebook server?
use
imageView.layer.cornerRadius=imageView.frame.size.width/2.0;
imageView.clipsToBounds=YES;
This is actually quite easy to do.
What you want to do is to create a CAShapeLayer the same size as your view. Create a UIBezierPath that uses a rounded rectangle who's corner radius is 1/2 the height/width. That gives you a circular path.
Install the bezier path's CGPath into the shape layer. Then set the shape layer to fill with an opaque color.
Finally, install the shape layer as the mask on your view's layer. The result is that the shape layer clips the view and only shows the opaque parts of the shape layer.
Suppose one image like circle image is there. Then I want draw circle over that image, then check two image is same or not in iOS. I tried image matching using CGPoint, but for circle and triangle what to do.
For matching two triangles you may have two choices:
define two areas in each traingle, then calculate areas ratio, they must have the same ratio if they are matched
try to detect three points of each triangle, then calculate the barycentre coordinates
they are invarinat
For circle, if you could easily to represent each circle by a triangle which its points cross that circle, you can find the invariance by the previous steps.