Is there a way to create a matrix transform or any other transformation to bend a rectangular element on the screen? Say I have a long rectangle: width=50 and height = 500. And 2/3 of the way down I want it to turn 90 degrees.
Thank you!
I think what you're looking for are the various Geometry classes, especially PathGeometry.
These links are a good start:
http://msdn.microsoft.com/en-us/library/ms747393.aspx
http://msdn.microsoft.com/en-us/library/ms751808.aspx
You could use a pixel shader (effect in WPF), however this will render the hit test in that area useless.
Related
In Python code I see that images given to MobileNet are 224x224 while the Tensorflow.js version seems to work with any size or aspect ratio. For non-square images does it stretch them or add white or transparent pixels to produce square input with the aspect ratio of the image maintained? If it does stretch it to become square should one do some image manipulation before using model.classify?
https://github.com/tensorflow/tfjs-models/tree/master/mobilenet#making-a-classification doesn't say anything about this.
There is no requirements for images to be square. Using non square images will achieve the same result. Maybe the reason why some neural networks such as mobilenet use square images are for operation such as convolution where the kernel is chosen most of the time as square.
To use mobilenet for classification, the image needs to be reshape to a shape of [224, 224, 3] which is the input size of the network. Methods such as .resizeBilinear, resizeNearestNeighbor, ... will achieve that very purpose. Obviously transforming a non square image to a square image will distort the image. But those algorithms use the technique of anti-aliasing to make up for the distorsion.
But the distorsion of the input image is the less thing one need to be concerned with. Actually, a good model prediction should be invariant to such distorsion, because the trained data were so much distorted and augmented with noise so that the model can generalize well.
I'm working on a parallax background and I would like to know which method is the best to draw a scrolling background :
Should I write two sprites one just next to the second and update the position of both or write a single sprite with two times the same pic stick on each other ?
(I'm looking for the best perfs)
Thanks
Usually the best way to answer this is to test it yourself however there is this in the FAQ for SFML:
https://www.sfml-dev.org/faq.php#graphics-xsprite
One of the fastest way to draw in SFML is to switch your implementation to use it's VertexArray as this is only 1 draw call to draw many objects.
SFML has an example how to use a VertexArray here:
https://www.sfml-dev.org/tutorials/2.4/graphics-vertex-array.php
A quick look at the way a sprite is drawn, a Sprite in SFML has 4 verts, each vert has to be transformed by the vertex shader in OpenGL. So if you are drawing the same sprite you are transforming 8 vertex's, where if you double the size, you are drawing 4 verts. The cost on the fragment shader should be relatively the same.
One last note, Get it working now optimize later.
Looking to see if anyone can recommend a computationally efficient method for translating/shifting an image by (x,y) pixels.
Reason being, I have been part successful in implementing the fourier-mellin transform to determine the rotation and translation between image frames. Once the image is unrotated I would like to untranslate the image by the calculated pixel offset (x,y). Allowing me to test the image correlation after rotation and translation.
I would think that a efficient method would be to:
Make a border cv::copyMakeBorder().
Use a ROI e.g. make a new matrix header without copying data.
Good luck
I had a generalized question to find out if it was possible or not to do matrix calculations on a rectangle. I have a CvRect that has information stored in it with coordinates and I have a cvMat that has transformational data. What I would like to know is if there was a way to get the Rect to use the matrix data to generate a rotated, skewed, and repositioned rectangle out of it. I've searched online, but I was only able to get information on image transforms.
Thanks in advance for the help.
No, this is not possible. cv::Rect is also not capable of that, as it only describes rectangles in a Manhattan world. There is cv::RotatedRect, but this also does not handle skewing.
You can, however, feed the corner points of your rectangle to cv::transform:
http://opencv.itseez.com/modules/core/doc/operations_on_arrays.html?highlight=transform#cv2.transform
You will then obtain four points that are transformed accordingly. Note that there are also more specialized versions of this function, e.g. warpPerspective() and warpAffine().
My application presents an image that can be scaled to a certain size. I'm using the Image WPF control with the scaling method of FANT.
However, there is no documentation how this scaling algorithm works.
Can anyone reference me to the relevant link for this algorithm description?
Nir
Avery Lee of VirtualDub states that it's a box filter for downscaling and linear for upscaling. If I'm not mistaken, "box filter" here means basically that each output pixel is a "flat" average of several input pixels.
In practice, it's a lot more blurry for downscaling than GDI's cubic downscaling, so the theory about averaging sounds about right.
I know what it is, but I couldn't find much on Google either :(
http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=4056711 is the appropriate paper I think; behind a pay-wall.
You don't need to understand the algorithm to use it. You should explicitly make the choice each time you create a bitmap control that is scaled whether you want it high-quality scaled or low quality scaled.