So I am trying to draw square over live CameraPreview.
I followed camera instructions on developer.android and I got CameraPreview class set up.
I was wondering how could I draw a square on top of the live image.
Something what we can see in face detection on cameras. I wont use it for face detection but same idea.
I have CameraPreview object that i place in my camera activity. Now any suggestions on how to go about learning about this or if you know of any code sample for it.
That would be great. And I am looking to do this in API 10. Not 14 which supports it through sdk.
This is what my current camera app code is based on http://developer.android.com/guide/topics/media/camera.html
Thanks
Put your SurfaceView (which you need for the camera preview) inside of a FrameLayout. Then, you can put that square image right on top of the camera preview.
Related
I have a activity in my android app which is receiving a bitmap from previous activity through intent. In the image view of the current activity I want to display that bitmap along with the contour on largest rectangle or square found in the bitmap and the contour should be adjustable so that I can adjust it in case its not correct and then when I click ok it should perform a 4 point perspective transformation on the bitmap and display it in the same image view. I searched through web a lot but I could not find what I was looking for.
This is the result I want:
How can I achieve this in opencv java android studio. I am new to opencv so I don't have even a slightest idea about how can I do that and where should I start.
Thank you.
I'm quite new to LibGDX but not a beginner in java programming. I was making a Flappy bird like game. I used Orthographic camera in my play state so it would follow the bird, but now i want to make a game over screen. I created a class with all the code i need but when i try it still uses the Orthographic camera at the birds position before it died, so the textures on that game over screen are heavily out of place, although isTouched() method is at the right position, so if i press that region i set earlier it restarts the game as it should. The only problem are the textures. Could someone help me solve the problem as i can't figure it out.
I think you want something similar to HUD, which is always displayed on the screen, right?
If so, you can use another orthographic camera, name it hudCam or something you remember.
Not sure if necessary but I changed Y-down of the camera to false like this:
hudCamera.setToOrtho(false, WIDTH / 2, HEIGHT / 2); // width and height being the screen size
Then you can just switch between the cameras when drawing.
batch.setProjectionMatrix(camera.combined);
draw...
batch.setProjectionMatrix(hudCamera.combined);
draw HUD stuff...
To get the correct mouse coordinates, just do like you did with the other camera, unproject it.
I'm currently using OpenGL to draw sprites on a texture laid on a SurfaceView. Everything works except for the fact that as soon as a sprite (which as of now is a simple 2D triangle built following Google's own developer tutorial) is drawn the SurfaceView gets dimmer. It happens only the first time and then it stays with that brightness layer. What am I doing wrong?
imagine that, an imaginary minecraft, where you build cubes.
You have a panel where you have the diferents cubes(tool box),
and other big panel, the world where you build, but the world is bigger.
and all of this things are in the same screen, imagine how can i put a orthografic camera that only zoom the panel where you have the whole world, that it allows you to zoom and build cubes with details and presicion, but the tool box panel still the same position. always visible. ?
Use two cameras. One for the "game" and one for the "HUD".
During a render call, use one camera to render the game, then "switch" cameras and then render the HUD. How you switch cameras depends on what API you're using to render objects (for example use setProjectionMatrix on a SpriteBatch).
You could also create more than one SpriteBatch or more than one Stage (as each tracks camera state internally), but they're a bit heavy-weight.
Beware that when switching contexts, you will probably have to explicitly end/flush/complete the first context before starting the second.
You do not use one Camera to show the stuff. For example you use a Camera for the background of your game and you have a second camera for the game Hud that always has a fixed size. But the game in background can be zoomed in and out because its an different camera.
But for simple boxes on the screen you do not use a second camera. You just use one more Stage that get displayed or not where the new "ui" stuff is shown.
Hope this helps a bit.
I am trying to make an android app and I can't seem to find anywhere how to make a simple activity where a circle shows up when anywhere on the screen is touched. It doesn't have to link with the coordinates with the click, just a circle in the middle of the screen. I have the frameview and everything set up, I just need to figure out the circle class. Any help?
Use Touch events to get the touch points of x and y value.
refer this link
use canvas to draw circle.
refer this link
This tutorial is kinda old, but should get you most of the way there...
You should use a SurfaceView with a drawable at the place where screen is touched.
Refer to this sample which does something similar
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/BouncingBalls.html