Android :: How To Overlay Image Over Camera Preview?
Jan 30, 2009Does someone know how I can overlay an image over the camera preview?
View 6 RepliesDoes someone know how I can overlay an image over the camera preview?
View 6 RepliesHow do I write code which layouts UI elements (Buttons, etc) over camera preview on Android ?
View 2 Replies View RelatedI have a SurfaceView that is being used to draw custom animations and I would like to overlay them onto a live-feed from the phone's camera. Currently, the SurfaceView that contains the animations has a white- background, but if I were to overlay them onto the phone's camera feed, they would have to be transparent. The camera and animation drawing cannot be done on the same SurfaceView. Is it possible to make a SurfaceView transparent? What is the best course to pursue the use of multiple views? My end goal is to essentially overlay the contents of another SurfaceView onto the Camera SurfaceView.
View 2 Replies View RelatedI have a SurfaceView that is being used to draw images, and I would like to overlay them onto a live-feed from the phone's camera. Currently, the SurfaceView that contains the images have a white-background, but if I were to overlay them onto the phone's camera feed, they would have to be transparent. The camera and animation drawing cannot be done on the same SurfaceView. What is the best course to pursue the use of multiple views that involve managing the camera and drawing images? Is it possible to make a SurfaceView transparent?
View 4 Replies View RelatedToday I tried the sample code to get the camera preview working
(http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.html)
But the image looks distorted when I start the application on my Galaxy S.
This is the code that I have for camera preview and image capture.I am trying to do camera preview and as I press the space button I am trying to take picture and save it in the picture gallery of the Android development phone. The code compiles fine,but as I press the space button,it captures the image and throws an exception and closes the application...
CODE:...................
I am writing an app to capture the camera preview frames and convert it to bitmap in Android.
Here is my code:...........
After I start preview, the callback got called with data, but the bitmap is null.
What did I do wrong when convert the byte array to BitMap?
How to overlay two images like the one in iphone notification icon or new launcher pro notification? I want to add new image on top right of an imageview to show notification.
View 2 Replies View RelatedI want to add a listener to a image which in the overlay so that dialog will exists after i click the image int the map.
View 2 Replies View RelatedI spend two weeks now trying to get this working with no success. Here is what I want to do: I have several geo points around the user and his phone. I want to display this point overlaying them on the input from the camera (kind of standard AR (Augmented Reality) app). Part of my requirements are that the user can use the phone in either landscape or portrait mode.My plan was like this.
1. Register for Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_MAGNETIC_FIELD 2. Pass the result to Sensor Manager.getRotationMatrix(), getting back the R matrix that should be telling me how to translate points from the Phone coordinate system (defined here: http://developer.android.com/reference/android/hardware/SensorEvent.html) to World coordinate system (x -> East, y -> North, z -> Sky) 3. I want to translate points from World to Phone so I take the inverse of R (I'm using Matrix.invertM()) to get R_In 4. Using the GPS I translate the geo points I want to display on the camera to points in the World coordinate system and then I run them through the R_In matrix to get their coordinates in the Phone system. 5. Draw the points in the screen only if the have (phone coordinates) z < 0 and x and y such that they are visible. This is my grand plan... however I have problems quite early (2). I do get the R matrix back and it looks good when I align the phone to the world coordinate system ( I get the identity matrix ). However when I try to translate an imaginary point from the Phone coordinate system say (0, 1, 0) to the World coordinate system I don't get the numbers I expect.
I'm passing a bitmap through a bundle to an activity which I called cameraView on which the user has access to the camera of the device. I'd like to overlay that bitmap with transparency using the camera as the background. Is it possible? to put the bitmap in front of the camera? And how can I change the transparency level? Here is my code: This is the camview.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<SurfaceView android:id="@+id/surface_camera" android:layout_width="fill_parent"
android:layout_height="10dip" android:layout_weight="1"> </SurfaceView> </RelativeLayout>
And this is the java:
public class cameraView extends Activity implements SurfaceHolder.Callback{
SurfaceView mSurfaceView; SurfaceHolder mSurfaceHolder;
Camera mCamera; boolean mPreviewRunning=false; private Context mContext = this;
public void onCreate(Bundle icicle) { super.onCreate(icicle);
setContentView(R.layout.camview); Bundle f = getIntent().getExtras();
picture = f.getParcelable("bitmap"); mSurfaceView = (SurfaceView) findViewById(R.id.surface_camera); mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this); mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
} @Override // Create the Surface and Open the Camera
public void surfaceCreated(SurfaceHolder holder) { mCamera = Camera.open();
} @Override // Reacts for camera changes public void surfaceChanged(SurfaceHolder holder,
int format, int w,int h) { if (mPreviewRunning) { mCamera.stopPreview();
} Camera.Parameters p = mCamera.getParameters(); p.setPreviewSize(w, h);
mCamera.setParameters(p); try { mCamera.setPreviewDisplay(holder);
} catch (IOException e) { e.printStackTrace();
} mCamera.startPreview(); mPreviewRunning = true;
} @Override // When the camera is closed
public void surfaceDestroyed(SurfaceHolder holder) { mCamera.stopPreview();
mPreviewRunning = false; mCamera.release(); }
// When the picure is taken. This method gives the byte[] of the picture
Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
public void onPictureTaken(byte[] imageData, Camera c) {
} };
I want to use my image to replace the Compass image of MyLocationOverlay, how can i implement?
View 1 Replies View RelatedIf I have a reference to a view, how can I overlay an icon image on top of an exisiting view?
In the screenshot below:
http://android.kanokgems.com/sms-unread-count
It overlay an icon at the top right corner of the dialer icon. How can I do that?
Does anybody knows if it is possible to zoom in and out on a custom overlay and enlarge the image? I'd like to do something like that: http://geoserver.nima.puc-rio.br/puc-rio/
If you zoom in, you'll notice that the image gets bigger.
I'm a bit new to Android but after searching on the Market, the web and this forum, I can't seem to find anything like this but I feel like it has to exist (or hopefully will soon). I'm looking for a camera application that can place the current compass direction on the image (and stamp the saved image with the direction). The tilt of the phone would be cool to have, too, but just the compass would be great. I did find an application that shows the compass direction on over top of a feed from the camera ("Reality + Compass" by Udell Enterprises).
I want something just like this, but with the ability to save the image. In case you're wondering, I'd like to use this for bettering the storm spotting community. A problem when people send in images of clouds/storms/tornadoes/etc is that you never know (1) where the picture was taken and (2) in what direction. Ideally GPS location could be added, too, but for now I just want the compass. (Other image services can handle the location part fine, like Twitter for Android/Twitpic.)
(I'm on the HTC Aria, but I can sideload apps now thanks to the new version of HTC Sync.)
I have a simple program that draws the preview of the Camera into a SurfaceView. What I'm trying to do is using the onPreviewFrame method, which is invoked each time a new frame is drawn into the SurfaceView, in order to execute the invalidate method which is supposed to invoke the onDraw method. In fact, the onDraw method is being invoked, but nothing there is being printed (I guess the camera preview is overwriting the text I'm trying to draw).
This is a simplify version of the SurfaceView subclass I have:
public class Superficie extends SurfaceView implements SurfaceHolder.Callback {
SurfaceHolder mHolder; public Camera camera; Superficie(Context context) { super(context);
mHolder = getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
} public void surfaceCreated(final SurfaceHolder holder) { camera = Camera.open();
try { camera.setPreviewDisplay(holder); camera.setPreviewCallback(new PreviewCallback() {
public void onPreviewFrame(byte[] data, Camera arg1) { invalidar();
} } ); } catch (IOException e) {} } public void invalidar(){ invalidate(); }
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
Camera.Parameters parameters = camera.getParameters(); parameters.setPreviewSize(w, h);
camera.setParameters(parameters); camera.startPreview(); }
@Override public void draw(Canvas canvas) { super.draw(canvas);
// nothing gets drawn :( Paint p = new Paint(Color.RED);
canvas.drawText("PREVIEW", canvas.getWidth() / 2, canvas.getHeight() / 2, p);
} }
I'm trying to get the camera preview running on my G2.
This is the code I'm testing with, which was taken from the sample code. It is using supplemental code supplied by Wu-Cheng, but its still throwing an error.
CODE:......................
I have a problem with using the camera of an Android 2.1 phone (HTC Desire), maybe you can help me.
After calling camera.open() DDMS in Eclipse shows the following errors:
CODE:............
Test view in the emulator works fine, but on my phone only a popup is shown where I only can close the application.
I upgraded to the 2.0 SDK yesterday. Don't know if that has anything to do with it. I can't get the Camera Preview example from the API Demos to work. I get the same error in both my emulator and on my G1:
E/AndroidRuntime( 4758): java.lang.RuntimeException: Fail to connect to camera service.
Is it possible to capture an image without showing the camera preview?, i have a requirement that i should be able to capture the image from a thread or from a service, without disturbing the foreground application, where i do not want to show the camera preview, but still i want to capture the image in background and store it in the device. So is it possible to do using the Android 2.2 SDK version?
View 3 Replies View RelatedAnybody know about the camera Api in android.when i used this Api it displayed a black and white grids and a squre moving above it.Anyone know how to get a real time camera preview please help me with some code.
View 2 Replies View RelatedI have a requirement to Capture the image without showing the Preview.. And i want to do it in the Background as a Service. Is it possible to do that?
View 2 Replies View RelatedI see a couple of threads on this topic, but none of them seem to answer the question, so, I'm giving it another go...
Very simple idea... I want to some portion of the screen to preview (and shoot) the camera and the other portions of the screen to add my own graphical elements (buttons, colorful frame around the camera preview, etc).
The example that comes with Android fills the screen. The obvious solution (that doesn't seem to be working) is to use my own SurfaceView (rather than the one they do in the example) and have it sitting in my XML. The code (beneath) doesn't crash and reports that it's firing up the camera... it just never renders on the screen.
I have no idea what I'm doing incorrectly. My guess is that it has something to do with the display thread never having the urge to redraw anything after it renders the initial screen, but I even tried adding a button and initiating the camera to render on the surface view upon button click, but that has not provoked it any further.
(most of this code is pulled directly out of the Android sample code, so, I'm sure it's correct. I'm just doing something wrong in how I pull my View in after the fact, I think).
CODE:........................
In my Application the camera preview is working properly in both in portrait and in landscape mode. No crashes are occurring, but the users are complaining that the crashes are occurring when they are using the same.
View 1 Replies View RelatedLet's say in my example I am working with SurfaceView for my CameraSurfaceView. I have a few questions, hope you can help me.
1. When this SurfaceView gets created (I assume via final CameraSurfaceView cameraView = new CameraSurfaceView (getApplicationContext()), this will result in a call createSurface() in SurfaceFlinger with format, width and height. Am I correct?
Is this SurfaceView also my UI window if I want to draw anything? I thought if I call setType(PUSH_BUFFER) on this surface, I won't be able to do any drawing on this surface.
2. How does the application pass these information like format, width and height to SurfaceFlinger for the allocation? Is it by using .setFormat, .setFixedSize?
3. How do they methods .setFormat, .setFixedSize related to the surfaceHolder.surfaceChanged() callback?
So I started with this little write-up. I wanted to try to make an application that will take pictures while running in the background. To start though I wanted an application that once opened would simply take a picture every X seconds. After recreating the classes and methods show in the walk through below I ran into a few problems.
http://itp.nyu.edu/~sve204/mobilemedia_spring10/androidCamera101.pdf
For starters its seems that the onCreate function sets up all the objects for the application, but if you try to take a picture through any other method than onClick (IE directly calling it) the application actually hasn't setup the canvas or the preview yet.
My first question:
Is there any conditional method that you can setup that will wait till all the "onCreate" objects are created and their associated methods are called and finished? How do I wait for the application to finish putting together my surface and starting the cameras preview before automatically starting to take pictures?
My second question:
I am required to have a preview available to take pictures. Is there anyway to push this application to the back (IE running in the background) while still taking pictures? Is drawing to a canvas a requirement? (From what I can tell AFAIK, you are required to have a surfaceholder to start preview, when you put up another screen or application that pauses the current application and closes the surface/canvas you were presenting that preview on). If my understanding is correct on all of this the best I will be able to do is make a 1x1 pixel canvas that will still take up the screen due to the application being in the foreground.
My Third question:
Is there any way around this? Can you still utilize the camera in some fashion without requiring the preview be drawn?
I've a problem with Camera Preview Zoom. The methods present in Android 2.2, setZoom() is not working to zoom the preview. Is there any another way to do the Zoom in android? I am using the code present in the Android API Demos. Is their any body who has worked on implementing ZoomIn & ZoomOut and got succeed??
View 4 Replies View RelatedI have yet to try this on an actual device, but expect similar results. Anyway, long story short, whenever I run my app on the emulator, it crashes due to an out of memory exception.
My code really is essentially the same as the camera preview API demo from google, which runs perfectly fine.
The only file in the app (that I created/use) is as below-
CODE:.......
When camera is launched in portrait mode, the viewfinder screen is 90 degrees rotated and stretched out. I read couple of places that this is a known bug with sdk1 but i am still finding this problem with cupcake. Has anyone having any idea is this issue is fixed in cupcake or in donut? any clues how to move ahead. setOrientation and changing the preview size didn't help. Even I read somewhere Surface flinger class needs change: http://groups.google.com/group/android-framework/browse_thread/thread...
View 3 Replies View RelatedI am using the code from ApiDemo Camera Preview and it runs fine on my Gphone but the preview is rotated and stretched.
View 8 Replies View Related