How do I set the slider to increment by a whole number, not by a decimal value of .N? I can get the value to translate to a label, but I don't want it in decimal value.
This was my original reference: https://www.youtube.com/watch?v=P80FkfGvHWw
Edit:
My value needs to be at 5 maximum... but I do not want to receive the decimal values at all. I eliminated most of the possible fractional values, but there are still some options.
Between 1-5, is there a mathematical way that can automatically round fractions to a whole number?
Thank you! (Please ignore the comment, that was for something else)
see the documentation
round
Returns the given number rounded to the closest integer. If the
fractional part is < .5 it will be rounded down. It it is > .5 it will
be rounded up. If it is exactly equal to .5, numbers with an even
whole part will be rounded down, and numbers with an odd whole part
will be rounded up. (This method is called round to even.)
Probably also a good idea is to use Do it, see also the Top 5 Tips how to learn App Inventor. You also can simplify your blocks a bit instead of using 3 times set global wholeInt ...
Related
Do anyone have some idea about next problem:
In my app, I have textview with double value like 12242,25
I am updating that value every 100ms with step like 0,6
Currently I'm just changing the whole text with new value, but then I get that blinking because of changing all of numbers.
I would like to update only those decimals that are for real changing.
So on previous example, 12242, would stay (no text update), and i would update only last 2 decimals, from ,25 to ,85...and so on
Do anyone have some idea how to solve this?
If you mean everything keeps moving around, using a monospace font will keep your digits in the same place, so long as you format the string so the decimal point has a consistent number of digits before or after it (depending on whether the text is aligned with the left or right or it's centred)
If you mean it's actually blinking on and off, that shouldn't happen - it should just draw the current text, and the next frame after the text is changed it should just draw the new text. If that is a thing that's happening though, you might want to look into separate text views, one for each digit like a digital display. That way you're only changing the views for specific digits, but you'll need extra logic to work out which ones you're changing!
I need to show chart with dashed line in my application. I am using MpAndroidChart to achieve it. It works, but when data contains too much values, it works incorrectly. For example:
Only 7 values on chart:
Over 500 values:
How to fix it?
The library behaves as expected. The problem is that you are providing too many data points so that the curve overlaps itself (and thus the dashing is displayed as in your image).
Depending on your use case I can suggest the following solutions:
Reduce the line width (probably not sufficient in your case)
Smooth the data points (on this page an overview of possible methods is given)
I am creating a line chart using MPAndroidChart, all is working great, but I've noticed that at the labels often become bunched up. I know there is a way to prevent this (I've seen other apps that don't have this issue,) but I don't know what setting to enable.
There are a couple of ways you could make the labels fit better.
Decrease the text size of the X axis labels with mChart.getXAxis().setTextSize(float)
Set a label count limit for the X axis using mChart.getXAxis().setLabelCount(int). This should work fine, as you are already not showing one label per data point.
Change the date format of your label.
Some, all or none of these might help you, depending on your requirements. Good luck!
I would like to detect some nutrition facts on food package with an Android Application, with OpenCV.
So far I managed to do it with one image of a nutrition table, but of course it only works with this one.
The goal is to detect and retrieve the value of Energy, Proteines, and Glucides, for 100g of product. These informations are present in almost every table, that is why I focus only on them for the moment.
So I was wondering if there a good method to do so ? For the moment, I try to detect each block of text, recognise it with Tesseract, and if it fits the word I'm looking for, I get the corresponding column and line in the picture, to finally get the value I want.
Is there any way to track the words straightly, and get the value that fits best in the image (in terms of alignement with the "100g" column).
Typical image : hpics.li/4231f79
Sorry if my problem is not well explained, just ask if something is not clearor if you want me to explain more what I've done for the moment.. Also sorry for my english
Cheers
Just a few ideas:
1. Convert image to HSV color space and look only for black and white regions (using inRange function). Blobs which contains only those 2 colors probably will be your informations (but unfortunetely some other things too - barcode, maybe some drawing or logo).
2 You regions should be rectangles, so if the blob is not rectangle - discard it.
3. If founded rectangle is rotated use affineTransform function to align it vertically - here i've explained how to do it. Note that rectangle width and height should stay the same.
4. After using affine transform your rectangle might be rotated by 90, 180 or 270 degrees. In the example you provided on the top there is a black region - it it's true for all you images than finding top is quite easy - just find black rectangle within you region. In other case finding top might be harder - a quick idea, which might be worth testing is to look for black pixels in each white rectangle. In most cases there are aligned to center (not interesting case for us) or to the left - if you find left sied of rectangle, finding top is obvious :) Alternatively you may look for characters which are always on the right side - %, g and mg
If you will have any problems, give us more examples and describe what you have done already - right know it's hard to tell something more.
Recently I played a simple game on android called Pou, and one of it's inside games was a connect the dots on the field game. Here is a screenshot to better explain the situation.
At the beginning of the game you are given n-pairs of dots and you have to connect the same colored ones. While doing this you need to fill the matrix field.
Generating such a field is not a problem, but how can I be sure that it is solvable?
My question would be how can I generate a field that has a solution?
Is this a graph problem? Or some kind of a connectivity problem?
Of course I can always produce a brute force solution, but I am looking for something better
Actually you can generate the matrix in such a way that you can be sure it is solvable.
The main idea is as follow. Let say that you need i pairs of dots and the matrix is n by n
Set i randomly chosen cells (start points) as heads and to each assign a different color.
At each iteration for each color move its head randomly (left, right, up, down) into an uncolored cell and color it with i-th color. (if there is no legal such moves do not consider this color any more -- that will be the end point)
When you are finished and there is no uncolored cells you created a legal coloring of the board.
If there are some uncolored cells -- it may be quite challenging but for sure doable to modify / extend the coloring you obtained to fill those regions with some color -- the easiest way would be to exclude those regions from the matrix altogether :-)
Some other very loose thoughts:
each region that consists of more than 2 uncolored cells can be made legal (or at least some part of it) by assigning two additional dots to it;
you can split your initial n by n matrix into smaller rectangular parts and assign to each part some number of dots (proportional to the area) and use the above method -- for sure there will be less uncolored cells when you merge those parts back (on the other hand the puzzle will be bit easier).
UPDATE
once still in phase of coloring, if the next move produces a single, isolated cell: chose a different move and if no such move exists stop the coloring process for this color.
if you want to have a predefined number of dots (or the number close to it), check not only for single isolated cell, but for whole isolated regions. [btw. mind the possibility of coloring a candidate for isolation region by extending its start point]
for relative small n you can try using above method(s) until you hit full-coloring (so generate, check if legal, if not: generate again)
UPDATE II
If you have time you can try generating colors once at a time, with some probability of stopping, that depends on the length / area of the coloring. So basically just choose a random uncolored position and execute the above method. It should be easier to implement.