How to create dynamic time line for Android with canvas? - android

I need to make a dynamic time line for my application. This line is needed to play video from a surveillance camera and select the viewing time you need. An example of the operation of such a line.Once a second, the line should move.

Related

Android add real time overlay to camera feed

I am trying to add a real time overlay to video capture from the camera feed. Which api should I use and how?
Idea is below,
Get camera feed (left)
Generate overlay from the feed, I'm using deep models here (middle)
Add overlay on top of the original video feed in real time(right)
OpenCV (https://opencv.org) will allow you take your video feed, and frame by frame:
load the frame
analyse it and generate your overlay
add your overlay to the frame (or replace the frame with your merged overlay)
display and/or save the frame
Depending on the amount of processing you need to do, the platform or device you are running on and whether you need it in real time you may find it hard to complete this every frame for high frame rates. One solution to this, if it is ok for your problem domain, is to only do the processing very nth frame.
I have used something similar with the GraphicOverlay for text.
Also, ViewOverlay may be something to look into.

Tracing an SVG path

I'm currently working on an app that will teach users how to write a foreign character(Character Tracing/Alphabet Tracing) such as Kanji, Hangul, Arabic and etc. I made the characters through Adobe Illustrator and imported it as XML file in Android. The SVG will then serves as a guide to trace its stroke and detect the user gesture, the user should follow the stroke and then it should be filled once it is done correctly else it should display the stroke what user should trace first.
Please see the sample image below:
The red line below is my gesture while the green line shows the correct way of tracing the character before proceeding to the other strokes.
Does anyone here has already experienced working with this kind of projects? Is it possible to do it using native android gesture detection? Thanks in advance
Disclaimer: The screenshot below is from the app Japanese Kanji Study, developed by Chase Colburn
If I were you, I probably wouldn't use SVG <path> elements. I would use a sequence (array) of points (ie the equivalent of an SVG <polyline>). The points should be close enough together that they look like a smooth line when drawn. Or you could apply some smoothing when you render them.
The advantage of the points array is that it is much easier to find the closest point to your touch location, than it is to find the closest point on an arbitrary <path>. And when you are "tracing" with the finger, you just need to draw a line through all the points up to the one closest to your touch location.
Obviously for most characters you would actually have two or more point arrays. But you would just work with each array in sequence.
Actually just take a look html and get some ideas. In html you can give coordinate area inside a image map and make it clickable. This following link elaborated what i am trying to say.
So after giving area, you can make order like 1 area 2 area ... n area. After that you gonna need first area clickable just give a flag, if there flag = true, then change background color when it is touched. When first area touched you make following area flag to true. It is all up to you. One of the solution. But main thing is in xml you can create MappedImage with co-ordinates

android block map generation through text file

(Just to be clear I'm asking for guideance not for someone to program this whole thing(unless they want to XD))
Hi, I'm currently trying to make a game for android in which you can build a map out of blocks(there are several types but we'll just use walls here).
The map is going to be 100x20 blocks, in which the players can put any of the blocks available inside in any order, and it's going to be stored as a text file "Let's call it "mapFile""(this part I've already solved) in which 0's would be nothing and 1's would be walls.
Now, the problem is that when you start playing the map, the game will have to load all the blocks to make the obstacles, but I want it to do it in a specific way (mainly to make the game go smoother and doesn't have to check 2000 blocks every update):
-make groups of blocks(lines, squares, rectangles) as 1 obstacle so there os only 1 collision detection in a large amount of blocks(the difficult part is to divide a complex shape in the best way)
-divide the map into 5x5 chunks so it doesn't have to check every obstacle in order to see if it should be drawn(it would just draw the chunk in which the player is in and the ones surrounding it)
The output from this should be a 4 levels array(or something similar):
Array[Ychunk][Xchunk][obstacle][x,y,xBlocks,yBlocks,type]
(Type is just the num of the block in the map(in this case it's 1 because it's the number for wall in my app)
For now the game has:
-An array with all the obstacles info (x,y,xBlocks,yBlocks,type)
-Only updates obstacles if they are a small distance from the player(still has to check them all)
-Only draws obstacles that are inside the window(also has to check them all)
Firstly, You don't need an array with all the map info, what you need is a 2D array of tiles. The tile object will contain all the info like the image, isSolid, etc.
Secondly, You will always have the player visible, so that acts as your anchor, Only show the tiles around your player and render that to the screen. Its makes no sense to render the tiles that will not be rendered on the screen e.g., If the player is at the center and the screen renders 5x5 tiles then +/- 2 tiles of the player tile. Same goes for checking if the tile is visible No, need to check all
Lastly, Again you don't need to check the player collision with all the obstacles, only need to check collision with the tile that the player is going to move on.
Hope it helps.

Animation sinusoid in android

I have a problem with moving animation. I want to create animation which start when I to a screen and she starts from touched place and go to end place like on this picture:
The end place is constant. How Can I do this sinusoid movement?
edit1: I want to click and when i click, show image and he goes this way to end place. I don't click and drag this picture. This picture must shows and goes to this place without my help. Only what I do is touch the screen. How I can do that?I have a problem with moving animation. I want to create animation which start when I to a screen and she starts from touched place and go to end place like on this picture:
The end place is constant. How Can I do this sinusoid movement?
edit1: I want to click and when i click, show image and he goes this way to end place. I don't click and drag this picture. This picture must shows and goes to this place without my help. Only what I do is touch the screen. How I can do that?
I wrote something like this that allows curved animation, you can see the full answer (and working code) here: Problem to achieve curved animation
It shouldn't be too difficult to either chain a number of those together, or modify the algorithm to use a cubic (or higher) function to produce multiple curves.
Only caveat is that because of the bezier curve, there is no guarantee the path will actually travel through the middle point you give it. If this is a problem again you could easily replace the bezier algorithm I use in the above example with something more suitable for your needs.
Check the sources of TranslationAnimation where the translation is done. Then build your function that maps the sinus function on the line from start to end. You could start with setting a horizontal line of with length dist(start,end) starting at (start), mapping sinus on it and then rotating it around your starting point.

how to start Activty randomly in Android

i want to implement simple game. In game there are only three pictures which will displayed to gesture on it. but i need to start game each time with different pictures.
Means if first time i play the game. it will show 2nd image to draw, then 1st to draw to draw, then third to draw. Game End
if i play game 2nd time. order of images should be changed.
Any guide ...
Thanks
In onCreate, load your three images into an ArrayList and then call Collections.shuffle(imageList). Then use the first image in the array. If you don't want to do all the work of loading the images, use an ArrayList of the image resource IDs.

Categories

Resources