LibGDX - Cleaner font rendering with BitmapFont - android

Wondering if there's a simple solution for this; I'm rendering some text with a sprite batch and a bitmap font in a libGDX Android project. Text renders fine, but end up with a few subtle grey spots after some letters, which I want to clear up.
A bit more context; I'm loading in a bold comic sans font (for now), generated using Hiero, I've set the minfilter and magfilter of the font's texture to linear. Also, I'm not scaling the font up or down at any point in my code, but may want to later. Here's a screenshot for reference: http://i824.photobucket.com/albums/zz161/9bjames/Screenshot_zpseac8c515.png (you might need to zoom in a bit).
I've looked it up, and found this: BitmapFont rendering artifacts, but I was wondering if there was a quicker fix... or at least one that's less "hacky". For example, would using a distance field font, or custom shaders help any?
Thanks, let me know if ya need any more info to go on. I'll continue looking into it in the meantime.
-Quick edit: found that using default texture filters (nearest) helps with the grey spots, so long as I'm not scaling up. Seems like the quality also drops in general using TextureFilter.Nearest... but it'll do for now, whilst I get more important parts working. Any recommendations would still be appreciated.

Related

How to draw cleverly a complex shape in Android

I'm working on a university project in which I need to visualize on a smartphone datas from pressure sensors built in an insole.
I need to draw on a View, as a background, a footprint, something like the image below but just for one foot.
I don't want to use a static image because with different screens resolution it could lose too much quality, so I'm trying to do it by code.
The main problem is that I'm not very skilled in graphic programming so I have not a smart approach to this problem.
The first and only idea that I had was to take the insole's CAD representation, with its real dimensions, scale it in function of screen's ones and put it together using simple shapes (arc, circle, ecc...) available in Android.
In this way I'm creating a Path which will compose the whole footprint, once I will draw it with a Canvas.
This method will let me to do the work but is awful and needs an exceptional amount of work and time to set every part.
I have searched for some similar questions but I haven't found anything to solve my problem.
Is there (of course there is) a smarter way to do this stuff, saving time and energies?
Thank you
of course, you can always use open gl es
this method might not save your time and energy but will give you a better graphic and scope to improve it for later purpose
the concept is to create a float buffer with all the points of your footwear and then draw is with connected lines on a surfaceView
to get started with open gl es you can use this tutorial : https://developer.android.com/guide/topics/graphics/opengl.html
and here is an example : https://developer.android.com/training/graphics/opengl/index.html

Unity 3D Text becomes Word Cubes

As the image shows, my 3D Text keeps disappearing from my scene when I click Play, and then when I zoom in, this is what I see.
When I exit the Play scene, it stays like that till I Ctrl+S and Save on which is returns to its proper text form.
Is there something I don't know? This happens even when I deploy my app ona device. These words are never seen because of this.
Using:
Unity 5.0.3p1 (32bit)
But I've had this problem with all version starting from Unity 4.x
My Hierarchy:
Your problem is having a MeshFilter on the same GameObject as your TextMesh
What you are seeing is the MeshRenderer drawing the wrong mesh, but using the font's material. Those seemingly random letters is what a font texture atlas actually looks like when textured on a cube. What mesh is chosen might as well be random, and with bad luck this kind of things might go undetected on the editor but show up on the builds.
This situation has already been submitted as an issue, but marked as Status By Design. Quoting directly from the issue tracker page:
TextMesh mesh is wrong when MeshFilter present on same GameObject.
This is expected behavior.
MeshFilter and TextMesh are both components that rely on a
MeshRenderer component to render the mesh. When they are both present,
they are conflicting over which one gets to set the mesh that the
MeshRenderer should use.
That said, we should not allow a MeshFilter and TextMesh on the same
GameObject because it is not supported anyway. We'll file a separate
bug bug on that.
I think the RectTransform is messing things up. Right click and save the settings of your text mesh. Then use the menus at the top of Unity to add a new, clean 3D text mesh and paste the component settings into that one. Don't choose the UI text if you want to use the 3D text. There is a separate option for the 3D text.

Android: How to detect these objects in images? (Image included). Tried OpenCV and metaioSDK, but both are not working good enough

i have been working with object detection / recognition in images captured from an android device camera recently.
the object i am trying to detect are all kinds of buttons that look like this:
Picture of buttons
so far i have been trying with OpenCV and also with the metaio SDK. results:
OpenCV was always detecting something, but gave lots of false hits. also it is too much work to collect all the pictures for what i have in mind. i have tried three ways with OpenCV:
FeatureDetection (SURF, ORB and so on) -> was way too slow and not enough features on my objects.
Template Matching -> seems to only work when the template is exactly a part out of the scene image
Training classifiers -> this worked the best so far, but is too much work for my goal, and still gives too many false detections.
metaioSDK was working ok when i took my reference images (the icon part of each button) out of a picture like shown above, then printed the full image and pointed my android device camera at the printed picture. but when i tried with the real buttons (not a picture of them) then almost nothing got detected anymore. in the metaio documentation it is said that the reference images need to have lots of features and color differences and also should not only consist of white text. well, as you see my reference images are exactly the opposite from what they should be. but thats just how the buttons look ;)
so, my question would be: does any of you have a suggestion about what else i could try to detect and recognize each of those buttons when i point my android camera at them?
As a suggestion can you try the following approach:
Class-Specific Hough Forest for Object Detection
they provide a C code implementation. Compile and run it and see the results, then replace positive and negative training images with the ones you have according the following rules:
In a car you will need to define the following 3 areas:
target region (the image you provided is a good representation of a target region)
nearby working area (this area have information regarding you target relative location) I would recommend: area 3-5 times the target regions, around the target, can be a good working area
everything outside the above can be used as negative images
then,
Use "many" positive images (100-1000) at different viewing angles (-30 - +30 degrees) and various distances.
You will have to make assumptions at which viewing angles and distances your users will use the application. The more strict they are the better performance you will get. A simple "hint" camera overlay can give a good idea to people what you expect the working area to be.
Use few times (3-5) more different negative image set which includes pictures of things that might be in the camera but should not contribute any target position information.
Do not use big images, somewhere around 100-300px in width should be enough
Assemble the database, and modify the configuration file that the code comes with. Run the program, see if performance is OK for your needs.
The program will return a voting map cloud of the object you are looking fore. Add gaussian blur to it, and apply some threshold to it (you will have to make another assumption for this threshold value).
Extracted mask will define the area you are looking for. The size of the masked region can give you good estimate of the object scale. Given this information it will be much easier to select proper template and perform template matching.
(Also some thoughts) You can also try to do a small trick by using goodFeaturesToTrack function with the mask you got, to get a set of locations and compare them with the corresponding locations on a template. Constuct an SSD and solve it for rotation, scale and transition parameters, by mimizing alignment error (but not sure if this approach will work)

Implementing Oil Painting effect in android

i am trying to implement some photo effects i try different effect like sketch painting effect, Emboss effect,
and now i m trying to implement Oil Painting Effect.
i found this link
http://supercomputingblog.com/graphics/oil-painting-algorithm/
but at my level this to hard to understand plz help me in this, or any other reference link for it.
Download JHLabs Library for Android from the following link.
https://code.google.com/p/android-jhlabs/
https://code.google.com/p/android-jhlabs/downloads/list
There are the effects given for oil painting, Emboss nad many more.
You can create pencil sketch effect from DoG Filter followed by GrayScale given in the library.
I think oil paintings are simulated best using a technique called "Stroke Based Rendering" (SBR) pioneered by Aaron Hertzmann. It's been around for a long time. Whether you do this in android or any other os doesn't make much of a difference.
What you need is a function that takes a rectangle and an orientation, and place a brush stroke on the current canvas. The brush itself is defined as a set of 2 texture grayscale images: one for the opacity and one for the height. You need one for the height so that you can use create a bump map alongside the canvas (the rendered image). Now, the tough part is to get good texture maps for your brushes so that it looks realistic. That's where you need to experiment quite a bit and see what you like best. Everybody has its own idea of what looks best.
To define the rectangle and its orientation, you can use image moments. The end result is that your brush strokes will kinda follow the contours of objects, which is usually what artists do (not always though).
In any case, this methodology is better explained here (this is link to my blog):
http://3dstereophoto.blogspot.com/2018/07/non-photorealistic-rendering-software.html
You can try the software called "The Painter" which I wrote (free and works on windows 64 bit) to see what can be done using SBR. Maybe it's not what you want at all. Here's the link to the software (also includes toon shading and watercolor rendering):
http://3dstereophoto.blogspot.com/p/painting-software.html
Again, this is a link to my blog which deals primarily with 3d photography. I happen to also like painting a lot.

AndEngine custom sprites

I started using andEngine yesterday but I'm pretty confused.. I want to make a custom character for each player, so i want to make a database inside the app in Assets/gfx and if for example the player chose a different eyes or nose, the character will change. Is there any way to build something like this without making different sprites and setting up the positions and all of that. (there are some games on the computer that does what i want to do with my app like maplestory, LaTale, Gust online, etc.)
Thanks!
I am not sure it is done this way (I never had a game where I used it, nor tried it), but here is an idea that came to my mind now:
Lets say we have a game with character appearance editing like maplestory. To make it simple, a character is just a circle, or a 2d ball, and you can change it's color and it's eyes color. So you have these folders:
assets/gfx/circles
And
assets/gfx/eyes
Now, lets say we have this circle:
And we have these eyes:
And we want to combine them.
You could do it:
BitmapTextureAtlas playerTextureAtlas = new BitmapTextureAtlas(256, 256 TextureOptions.BILINEAR_PREMULTIPLYALPHA);
TextureRegion playerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(playerTextureAtlas, this, "circles/redcircle.png", 0, 0);
//By executing the next line, we place the eyes over the player texture area.
//There is NO need to keep a reference to the texture region this returns to us, because technically this one and playerTextureRegion are THE SAME - they both hold the same region in the texture (As long as they have the same sizes, of course)
BitmapTextureAtlasTextureRegionFactory.createFromAsset(playerTextureAtlas, this, "eyes/yelloweyes.png", 0, 0);
Remember - the eyes image background has to be transperant so it won't override the circle! Play around with the TextureOptions parameter. I'm not sure if the one I used will fill this purpose - maybe another one will.
And lastly, you should keep the eyes eyes and circles the same size, since this way it is easier to test whether they fit. If you make the eyes just be a small rectangle, you will have to mess with it untill you find the place where you should position it over the circle. Waste of time...
Now, you can just load different bodies/eyes/hairs and so on, place them, and you got a customized player!
I am afraid Jong's solution won't work, at least not in GLES1 version of AndEngine. When I tried to combine sprites this way, the latest one just overwrote anything that was under it. In this case, only the eyes would appear on the screen.

Categories

Resources