surfaceview

Android camera preview freezes when switching cameras?

那年仲夏 提交于 2019-12-22 12:12:08
问题 I am writing a custom camera for my app. It's working fine when opening the activity with either of the back or front cameras. But I'm really struggling with switching cameras inside the activity. When I tap the switching camera button, the preview freezes and nothing happens. I have tried the answers and tips suggested in other questions related to the camera and the preview, but nothing works. Here is my activity: public class CameraActivity extends Activity implements SurfaceHolder

android camera2 process each frame and display its preview

[亡魂溺海] 提交于 2019-12-22 06:27:28
问题 I use the https://github.com/googlesamples/android-Camera2Basic, but try to modify it in a way that I could get access to each frame before it is drawn on the surfaceview. I understood, I should add additional surface (ImageReader.getSurface()), and read the frame from it in this callback: private final ImageReader.OnImageAvailableListener mOnImageAvailableListener = new ImageReader.OnImageAvailableListener() { @Override public void onImageAvailable(ImageReader reader) { Log.d("Img",

android camera2 process each frame and display its preview

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 06:27:13
问题 I use the https://github.com/googlesamples/android-Camera2Basic, but try to modify it in a way that I could get access to each frame before it is drawn on the surfaceview. I understood, I should add additional surface (ImageReader.getSurface()), and read the frame from it in this callback: private final ImageReader.OnImageAvailableListener mOnImageAvailableListener = new ImageReader.OnImageAvailableListener() { @Override public void onImageAvailable(ImageReader reader) { Log.d("Img",

Admob on surfaceview

风格不统一 提交于 2019-12-22 01:29:27
问题 I have an activity which has a surfaceview capturing whole screen. i want to put an admob ad on surfaceview. I found this link but it does not work. Any idea ? 回答1: In your activity's onCreate: // Add admob ads. admobView = new AdView(this, AdSize.BANNER, "YOUR_UNIT_ID"); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); admobView.setLayoutParams

Can u ? How to anti alias for SurfaceView in android?

会有一股神秘感。 提交于 2019-12-22 00:25:56
问题 This is a test project for antialias in Surface View and View, in the View : ( it's very good for antialias ) @Override protected void onDraw(Canvas canvas) { Paint p = new Paint(); p.setColor(Color.WHITE); canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG)); canvas.drawColor(Color.BLACK); Matrix mMatrix = new Matrix(); mMatrix.postScale(0.34f, 0.34f); canvas.drawBitmap(mBitmap, mMatrix, p); canvas.drawText("View Anti alias", 100, 300, p); } in

Custom camera app in android problems - rotation 270, stretched capture view and not getting all functions

我的梦境 提交于 2019-12-21 21:37:20
问题 I got the help from code https://github.com/josnidhin/Android-Camera-Example But facing some problems like: How to add functionalities of auto focus and flash. - solved in last edited code The when screen orientation is 270 so real view shows 180 degree rotated. Capture view is showing stretched. The CODE from where i called the custom camera class Camera cam = Camera.open(); if (null == cam) { // no camera exists Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images

Preventing “flickering” when calling Drawable.draw()

只愿长相守 提交于 2019-12-21 20:36:26
问题 I have a little experimentation app (essentially a very cut-down version of the LunarLander demo in the Android SDK), with a single SurfaceView . I have a Drawable "sprite" which I periodically draw into the SurfaceView 's Canvas object in different locations, without attempting to erase the previous image. Thus: private class MyThread extends Thread { SurfaceHolder holder; // Initialised in ctor (acquired via getHolder()) Drawable sprite; // Initialised in ctor Rect bounds; // Initialised in

Reopening camera after intent chooser is canceled

只谈情不闲聊 提交于 2019-12-21 17:45:13
问题 I have created a custom camera preview view CameraView which extends SurfaceView , and it also implements SurfaceHolder.Callback interface. The view operates with the camera. When you open the view it shows a camera preview. On the same screen there is also overlay with two buttons - 'Take picture', 'Choose from gallery'. The activity that holds the CameraView releases and reopens the camera in onPause() and onResume() methods. If I click the 'Choose from gallery' button, the following intent

Getting Bitmap from Custom SurfaceView

会有一股神秘感。 提交于 2019-12-21 09:14:48
问题 I have this code in a class that extends surface view and implements runnable I am able to use the class basically allows you to draw to the canvas using different colors and such. I'm trying to get a method that will allow me to save the image after it is drawn and this is the method. No matter what i do i just get a black image with nothing on it. Any ideas? I have cache drawing enabled Objective get a bitmap image from a custom SurfaceView I have exhausted options of looking at some other

Android's EditText is hidden when the virtual keyboard is shown and a SurfaceView is involved

我是研究僧i 提交于 2019-12-21 07:57:40
问题 I have a simple user interface: an EditText should be located below a SurfaceView. I use a RelativeLayout to arrange these two views. Now, when I tap on the EditText to open the virtual keyboard the SurfaceView slides up but the EditText is hidden and does not show the typed string. To reproduce, use the following layout XML code: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout01" android:layout