logo
down
shadow

Android: How to draw on a Surfaceview which already is displaying a Camara Preview


Android: How to draw on a Surfaceview which already is displaying a Camara Preview

By : Blake Weissman
Date : November 22 2020, 02:42 PM
around this issue You can't. A Surface is the producer side of a producer-consumer pair, and there can only be one producer at a time. You can provide camera frames, render in software with Canvas, or render in hardware with OpenGL, but you can't mix them up on a single Surface.
You have a few options. One approach is to use a second SurfaceView that overlaps the first (via a FrameLayout). For this to work, you must specify the Z order for the second Surface -- if you don't, the system will see that you have two Surfaces attempting to occupy the same space, and only one will win. Use the setZOrderMediaOverlay() method to place the new Surface in front of the camera preview but behind the View UI. You also need to change the Surface's color format from the default RGB565 to one that supports transparency; setColorFormat(TRANSLUCENT) or RGB8888 will work. Make sure you erase the Surface to transparent black with an appropriate color transfer mode.
code :


Share : facebook icon twitter icon
android : camera preview using surfaceview

android : camera preview using surfaceview


By : Jorma Orava
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Have you set the permission in your AndroidManifest.xml?
// permission for camera
Android SurfaceView Preview Blurry

Android SurfaceView Preview Blurry


By : user2762150
Date : March 29 2020, 07:55 AM
help you fix your problem There are two reason why your image and preview may appear blurry
1) the way you are settings the picture size and preview size is wrong. You have to query the supported sizes and decide which is the best size for you and set size from the list that your have got. You cannot give arbit values. Check this sample app for implementation details - https://github.com/josnidhin/Android-Camera-Example
code :
private void setCamFocusMode(){

    if(null == mCamera) {
        return;
     }

    /* Set Auto focus */ 
    Parameters parameters = mCamera.getParameters();
    List<String>    focusModes = parameters.getSupportedFocusModes();
    if(focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)){
        parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);   
    } else 
    if(focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)){
        parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
    }   

    mCamera.setParameters(parameters);
}
Android SurfaceView Preview too dark

Android SurfaceView Preview too dark


By : Aman Kabra
Date : March 29 2020, 07:55 AM
around this issue
Don't lock auto-exposure; if you do, the camera is stuck with whatever settings it had when you locked it, which may be too dark
subclassing SurfaceView and overriding onDraw() to change SurfaceView parameters to generate preview of desired size

subclassing SurfaceView and overriding onDraw() to change SurfaceView parameters to generate preview of desired size


By : Desiree Lingard
Date : March 29 2020, 07:55 AM
may help you . I have subclassed the SurfaceView and instantiating it in onCreate of the Activity. The preview is generated but the control never enters onDraw() which is overriden in the subclass of SurfaceView. Why is that? , You simply have to add
Android camera preview in surfaceview

Android camera preview in surfaceview


By : Dean Brown
Date : March 29 2020, 07:55 AM
like below fixes the issue You have a choice to start "startPreview" inside a different thread ..
Related Posts Related Posts :
  • Search specific nearby places using google places api web services for android
  • How to update app?
  • Is It possible to develop app with react native and make changes in android studio?
  • How to create Motion Splash Screen in Android?
  • Build Gradle Android studio Build Slow
  • Using Android DownloadManager,how do i get file name?
  • Android - How to Load More then 20mb Image in Imageview
  • Notification is not cancelled after calling notification.cancel
  • How to implement the smart-crop feature
  • Null Pointer exception on reading SMS stored in SIM in Android
  • remove google text from google maps in android
  • Image captured from camera not displaying in imageview android
  • kivy: My screenmanager code is not working with scrollview
  • Dynamic MpAndroidChart Not Working
  • Yandex Maps return 403 Forbidden using retrofit
  • how set selected spinner item in android studio?
  • Does Picasso library for Android handle image loading while network connectivity is off?
  • colorAccent in Holo Theme
  • Android: animation on layout after button clicked for minimum SDK version of 14
  • Are static variable truly "global" (system-wide) in Android?
  • How to create android snackbar with custom layout
  • Animate a car(Marker) along a path in google map android
  • Default to "compass" (gyroscope) mode when viewing a photosphere
  • Gradle - finished with non-zero exit value 1
  • Android Studio 2.0 Application crash on unmodified Application class
  • Android Studio cursor display error
  • Creating Dagger 2 component to be shared between src/test and src/androidTest
  • Android losing state when screen is OFF and ON again
  • Android Notification.Builder addAction PendingIntent Fragment
  • Use another button instead of back button
  • Android Studio Send string over socket after taking a picture [Google Glass]
  • Realm `access from incorrect thread` error when using shared code between IntentService and AsyncTask (Android)
  • osmdroid plotting current location offline
  • GifAnimationDrawable(Gif file) not playing in ListView
  • Controlling emission of Observable items in unit tests
  • android: Log in Button
  • Gradle github and facebook dependencies can't resolve
  • How can you animate a view back and forth between two states on Android, while supporting backpressure?
  • $(LOCAL_PATH) not returning the path to current directory correctly
  • Error:Cause: com.android.sdklib.repository.FullRevision
  • How to get an offset in RecyclerView ItemDecorator
  • Android toolbar home button not showing
  • TextView keeps popping up
  • Toolbar overlaps below status bar
  • Inflated view not updating
  • Errors of the Manifest
  • How to perform the same operation on several elements in array in doInBackground()
  • see error when use getSupportActionBar().setDisplayHomeAsUpEnabled(true)
  • What the heck is going on with this animation?
  • How to set the color of the counter on a TextInputLayout?
  • Cannot resolve symbol 'GeoJsonLayer '
  • Font file not loading on Libgdx Android
  • Simulate GCM push notifications on Android
  • Google maps provider, Wifi, 3g and GPS
  • Textview animation error
  • I want my FAB to stay at the bottom of the screen
  • How to attach multiple Images with a note taking app in android?
  • How to share xml layout using Intent.ACTION_SEND
  • Is there a default selector for the RecyclerView
  • Cordova SQLite Plugin not functioning with Android Studio
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co