Just wondering - is there a way to add custom shape recognition to UWP ink analyzer?
I need to be able to recognize a semi-circle, an arrow an couple of other simple shapes.
What is the best approach to solve this issue?
As far as I known, we can not recognize a semi-circle, an arrow an couple of other simple shapes by the InkAnalyzer class. It can recognize the specified shape in the InkAnalysisDrawingKind.
The InkAnalysisDrawingKind enum lists Circle, Diamond, Drawing, Ellipse,
EquilateralTriangle, Hexagon, IsoscelesTriangle, Parallelogram, Pentagon, Quadrilateral, Rectangle, RightTriangle, Square, Trapezoid and Triangle. We can not add our custom shape to it.
If you draw a semi-circle, it maybe will recognize to Ellipse or Rectangle that we can not know it is a semi-circle. If you draw an arrow, it will not be recognized as one of the shapes listed. Then it will return InkAnalysisDrawingKind.Drawing.
https://github.com/Microsoft/MTC_WindowsSmartInk
You can do it if you use it in conjunction with Azure's Custom Vision service. I've seen a lot of demo videos from Build about it.
Related
I'm working on an application that has a graphic editor. Aside from some other graphic components the main feature are some shapes (rectangles, triangles, stars etc.). The thing I would like to do is to have the ability to resize them after a double click, so there should be a container shown with points that can be dragged to resize the shape. There are many great tutorials out in the internet but mainly for rectangles or for other shapes that are "packed" into rectangle viewboxes.
The issue is that I need to have my resize points exactly on the vertexes, so for example I can't have a triangle inside a rectangle viewbox, but I need exactly three points - one on every vertex. The same applies for the other shapes like stars and arrows which are much more complicated.
Here's what I mean:
So I think I have two ways. Either pass a dynamic list of points after a double click and display them as separate shapes or binding them with my shape inside my shape class, but I cannot figure out how to add multiple shapes to a viewbox so that they keep their abilities. Here is a simplified snippet of how my shape classes look like:
public class RectangleObject : ShapeObject
{
private Rectangle _rectangle;
private Viewbox _viewbox;
public RectangleObject(Color fillColor)
{
_rectangle = new Rectangle()
{
Fill = new SolidColorBrush(fillColor),
Stretch = Stretch.Fill
};
_viewbox.child = _rectangle;
}
public void SetDimensions(){}
//... and some other methods
}
A nice solution would be if the viewbox could contain my shape and the resize points but I will appreciate any advice. I know that a canvas would be a better solution but all other components are packed in viewboxes so it would be problematic because of inheritance and would need many changes. Thanks in advance!
Yes I know exactly what you mean. I used CorelDraw back in the day and then Adobe Illustrator and both had the concept of shape transformation mode (your image on the right) as well as vertex edit mode (your image on the left). UWP is similar to WPF and WPF has a concept of adorners which you can customise to do whatever you want including what I just described.
So when you enter one of these modes, rather than modify your existing shape to show selectors; instead you create adorners that are superimposed over the shape. That way one doesn't clobber the other and you may have custom behavior for each as you indicated.
See also
Adorners - MSDN, https://msdn.microsoft.com/en-us/library/ms743737(v=vs.110).aspx, retrieved 2017-1-12
I need to find the coordinates of the most popular simple shapes (usually - rectangles) in the picture. I used the approach that has been described here (Simple approach for finding rectangles ). But I've faced with the situation shown in the picture. Some boxes have a torn border and I cannot detect them with standard approach. These rectangles circled in red.
What solution would you suggest?
UPDATE:
Using dilation/erosion before binarization:
Dilation
Erosion
Use a simple dilation using a small structuring element
Find connected component
For each connected component i would calculate the ratio between the number of pixels in the component divided by the area of the bounding box i would keep only the ones that are very close to 1.
im writing application similar to MS Paint, I've got pencil, shapes and line functionality alredy. I'm adding System.Windows.Shapes.Shape objects (like Rectange, Ellipse etc.) to Canvas and everything works fine. Now im wondering how to create "bucket" functionality like in MS Paint (filling area of same color), is it possibile to do such thing in my app or i need to refactor it?
I think there are diffrent ways of implementing this depending on your skill and time.
If i would do it, i would link the pixels that are same color and at the same place by
http://en.wikipedia.org/wiki/Connected-component_labeling this method. And then color them.
or this:
http://en.wikipedia.org/wiki/Flood_fill
I am very curious, I have for example a app to localize our property, our first, second house, favorite park and we can add pushpins to corners of this property in a way to form a shape(triangle, square, polygon etc), not a line or point.
How to create this shape, there is a method to calculate the surface area? Change a background for example to color yellow between these pushpins ?
When we created a shape we can chose from the listbox or map to delete this shape or go to there using GPS, i wrote something like that in Simulate my current position
I think its a interesting app but i need your help ;)
Try getting the geocoordinates of each pushpin and using maths? I guess you could assume the flatness of the Earth over a small area (like a house) but over larger you'll need to account for curvature.
As for colouring the shapes in, I don't think there's a way to do this using the Map control.
I have polygons of various shapes and sizes. They have a solid fill and currently a solid border.
I would like to give the polygons a gradient on their edge to soften them.
So far I've tried using a Pen with a LinearGradientBrush and whilst the effect it produces is very interesting it's most definitely not what I want ;)
I've looked through the System.Drawing.Drawing2D namespace but there didn't seem to be any other classes that would be applicable for this purpose.
I've had a search around and the articles that I can find are mostly about creating borders for rectangles, which are mush easier, or are irrelevant.
So to summarize, does anyone have a way of drawing a gradient border in on a polygon using GDI+?
Perhaps a screen shot of what your previous attempt produced and a mock up of what you would like would help?
Though I suspect the issue you're running into is that the direction and offset of the gradient is consistent throughout the entire shape and does not change with the orientation of the lines of the polygon.
Have you taken a look instead at the PathGradientBrush? (Examples) If you can't achieve the effect using it with a Pen for the stroke of the shape, perhaps you could do it with two "fills" with the first (the border) being slightly larger than the second (the interior).
I think I have done exactly what you're asking for, but in my case I have used it for creating soft shadows on text.
I do the following:
Draw the text (in your case:
polygon) to a Bitmap
Apply a
softening filter on the alpha
channel only
Iterate step 2 as
many times needed to get the desired
gradient width
Finally draw the
result onto the resulting
bitmap/screen