Hej
Lets say I have a cirkel as my usercontrol in a Windows Phone 8 application, And I add elements inside a Geometry group, with a rectangel and a line. I would get the following:
(source: c-sharpcorner.com)
I am interested in having my cirkel as the main element. To specify I want the everything else to only be displayed in the region of the cirkel.
So if the rectangle was red I would only get the red corner displayed.
I have code that can manage inserting and moving objects. But I do not know how to make the intersect work opporsit of the picture.
I have tried a bit of the same in a small sample as is done in this link:
the link is http://www.c-sharpcorner.com/uploadfile/mahesh/path-in-wpf/
Anybody has an idea for this?
Best
So the Best solution I found is to convert your element to WriteableBitmap, and then setting this as the background of your wished shape.
So to acheive the above if you have the elements as geometric shapes you can use this link to get the path of the object.
http://www.c-sharpcorner.com/uploadfile/mahesh/path-in-wpf/
Related
example image
after image
how to find rectangle region in image?
It can be not exactly.
i tried to use "CvInvoke.findContours" but i failed because don't know how to use.
please tell me what should i do
i need function that return region rectangles, or some hints please..
sorry and thanks.
You'll want to create an image where the regions that you want are highlighted and the regions you don't want are black. To do this, I would do an adaptive threshold (you'll want to convert the image to black and white and then use the invert threshold option to highlight the non-white areas).
Then I would use morphology (dilation followed by erosion, or 'closing') to remove the noise. The image should now have white blobs on the regions you're interesting in and be black elsewhere. The final steps will be find contours, follows by looping over each contour and finding their bounding boxes.
You'll want to read up on each of these topics, but that approach should work for what you want. Opencv's documentation isn't great, and EmGU's bindings adds another layer of confusion, but be patient and you'll get the hang of it.
Adaptive threshold:
https://docs.opencv.org/3.3.1/d7/d4d/tutorial_py_thresholding.html
Morphology: https://docs.opencv.org/2.4/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.html
find contours:
https://docs.opencv.org/2.4/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=findcontours#findcontours
bounding rect:
https://docs.opencv.org/2.4/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=boundingrect#boundingrect
here is the link that contains
shape detection using emgu.
I have an image with a decent portion of it transparent. It's the result of a green screen process. I need to overlay a filter on top of the image without laying on top of the transparent portions. You could think of it like using the base image as a cookie cutter to remove a matching shape from the filter image so I can merge them.
I've tried combing through AForge but I don't see anything helpful and google is returning all sorts of garbage. If anyone has any suggestions on where to start or alternate methods I would appreciate it.
I came up with a solution that works for me but may not answer the question directly, as I asked it. Someone else may find this useful though.
I Iterated through image I wanted to cut out. At each pixel position I would use that same position to check the "cookie cutter" image and if the Alpha channel was 0, I would then set the pixel value on the base image to 0. I was basically setting everything other than the cookie cutter shape to transparent.
A caveat is this only works if the image are the exact same size and you can't easily change the location of the where you want the cutout.
I am trying to create a WPF application using C# to run on Pixelsense that is basic version of the tangram puzzle. I am able to draw my 7 shapes and translate and rotate them all around the screen.
Could anyone give me advise regarding how I should go about saving the pattern (with shapes in specific positions and orientations) so that when a user creates the pattern next time, the application can match it to the saved one and tell the user if it's correct.
It's a pattern matching and recognition problem that I am trying to solve.
I have been stuck on this for a while now :(
Define the solution as a collection of objects with shapeType, position, and orientation properties. Have the solution include one shape at position 0, 0 and an orientation of 0. Now loop over all the shapes the user has actually placed to find the ones with a shapeType that matches the shape your solution has at 0,0,0. Calculate the position and orientation of every other shape relative to where the user put this one. Compare those values to the rest of your solution. You'll need to experiment with how much tolerance to allow because this stuff is not precise - to make the game fun, err on the side of having high tolerances. If needed, you can follow this up with some performance optimizations to only re-evaluate pieces that moved.
Hopefully you are using physical shape prices with tags on them instead of this purely a virtual game. I always wanted to build this when I was on the Surface team but it never happened. One challenge you will run into is defining how the tag's position/orientation relates to the actual shape. If you'll be putting tag stickers on multiple tangram sets, you almost certainly won't get the on precisely the same each time so you may need to add a "calibration" mode to your app (have the user place each piece in a specific spot and then push a button so you can record where the tag is relative to those spots). The TagVisualizer WPF control should help a lot for building your UI - definitely look into using it (this scenario was top of mind when we designed that API). The default behavior of that control (if you tell it the ID of a tag to look for but not how to visualize it) is a "crosshair" that can help you find tune your offset values.
Good luck! If you wouldn't mind recording a YouTube video when you are done and posting a comment here linking to it, I'd really appreciate that
You can use ObservableCollection or List of a custom class. That class can consist of various values such as position, orientation etc as properties.
When a new pattern is drawn or when the pattern change its position you can update that particular object stored in the collection. As you have all the details of the pattern(positions and orientation) you can iterate the for loop and check the position of the new pattern when added.
I'm working on a Add-in for PowerPoint 2010 (C#) and I want to prevent the end-user to move or edit all the shapes that I have programmatically created.
I have already sought in the framework but I think it's not allowed programmaticaly. Has anyone already encountered this kind of limitations and could help me to find a solution?
I know that some people create their add-in thanks to C++ because there are a lot of limitations in office.
I have found two solutions :
The first is to catch all events from the "commandBars.OnUpdate" like this great sample code : http://code.msdn.microsoft.com/CSExcelNewEventForShapes-0e26b1f2#content
Then you can impose the position/the color or everything you want to your shape.
The second one is more "brutal" > unselect immediately the shape. When you catch all the events from the "CommandBars.OnUpdate" do this :
To see which shape is selected :
var selectedShape = this.Application.ActiveWindow.Selection.ShapeRange[1]
In all my shapes, I have set a tag with an ID. I have just to check that there are an ID in the tags of the selectedShape and if this is the case :
this.Application.ActiveWindow.Selection.Unselect();
Then I show a messageBox to warn the user to do not select this kind of shape.
I don't like this solution but it's the only one that I have found and it works.
I believe this is not possible. A way of achieving this to a certain extent (people can work around it if they figure out how to select the shapes below) is by making a transparent rectangle the size of the canvas and binding a custom event to that (like you described in your comment). The transparent rectangle is overlaying the shapes you created so people can no longer access the shapes that way. Of course if they are capable of figuring out how to select the shapes they can move them anyway...
Alternatively, to make people not do stuff like that (you only stop the inexperienced) you can also set them up as master slides.
Only 'real' solution for people not doing that? Images .. but then they can move the image too!
Hello I need to know how I can manage to resize and draw pictures in a given space and the top and left values are stored in a database or XML. What elements need to use?
I put pictures of the software that works to perfection, really need to create something like what is shown in the following images:
Imagen 2
Imagen 3
Thanks!!
You probably want a canvas with a resizing adorner that tells the elements what size and placement to draw. Here is one such example.