android-camera

Android add text to Picture and save

时光总嘲笑我的痴心妄想 提交于 2019-12-23 18:08:37
问题 I want to place a Textiew to my picture and save it, but I'm not sure how to insert the text into the picture. I can attach an image on my picture save it, and it works but now I want to insert a Textiew into the picture. Here is my code: PictureCallback cameraPictureCallbackJpeg = new PictureCallback() { @Override public void onPictureTaken(byte[] data, Camera camera) { // TODO Auto-generated method stub Bitmap cameraBitmap = BitmapFactory.decodeByteArray(data, 0, data.length); wid =

How to use the ImageReader that appeared in Android 4.4?

时光毁灭记忆、已成空白 提交于 2019-12-23 16:09:09
问题 Android 4.4 Kit Kat introduced the ImageReader class for accessing the image in the Surface, useful for real-time processing of a camera preview. However, I can't figure out how to link it to the Surface or use it. Anybody have any insights or short example code? 回答1: You can find an example in the camera CTS tests. As noted in the comments, ImageReader isn't actually usable until 5.0 ("Lollipop"). 来源: https://stackoverflow.com/questions/21147519/how-to-use-the-imagereader-that-appeared-in

How to save a YUV_420_888 image?

风格不统一 提交于 2019-12-23 16:01:47
问题 I built my own camera app with the camera2 API. I started with the sample "camera2Raw" and I added YUV_420_888 support instead of JPEG. But now I am wondering how I save the images in the ImageSaver!? Here is my code of the run method: @Override public void run() { boolean success = false; int format = mImage.getFormat(); switch(format) { case ImageFormat.RAW_SENSOR:{ DngCreator dngCreator = new DngCreator(mCharacteristics, mCaptureResult); FileOutputStream output = null; try { output = new

How to control video capture properties in android?

陌路散爱 提交于 2019-12-23 15:52:17
问题 I am capturing video using the following intent: Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); if (takeVideoIntent.resolveActivity(getPackageManager()) != null) { takeVideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); takeVideoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 10); startActivityForResult(takeVideoIntent, VIDEO_CAPTURE_INTENT); } I need to control two things, first its frames sizes with the given height/width and secondly I want to capture the video

Taking picture with flash on camera2 gives picture “after” flash occured (i.e without flash)

久未见 提交于 2019-12-23 15:43:46
问题 I based my code on the sample from Google Camera2-Basic and added flash always support. But It looks like the picture is taken right after the flash has occur. I (almost) always get non flashed picture, even though the flash is triggered. The modified preview request builder : mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH); And I also added this control mode to captureStillPicture() captureBuilder.set(CaptureRequest.CONTROL_AE_MODE,

Problem with camera when orientation changes

北城以北 提交于 2019-12-23 14:58:09
问题 I'm doing an application that calls a different activity when the device orientation changes from landscape to portrait or viceversa. The activity for the landscape mode is an augmented reality one, so I use the camera to show the surroundings to the user. However, when I try to go back to portrait, the app crashes and displays this error: 08-17 16:05:42.622: ERROR/AndroidRuntime(9769): FATAL EXCEPTION: main 08-17 16:05:42.622: ERROR/AndroidRuntime(9769): java.lang.RuntimeException: set

Android - detect reverse landscape orientation

懵懂的女人 提交于 2019-12-23 12:50:16
问题 I need to detect reverse landscape orientation in order to prevent user to start capturing vertical videos. I've implemented 2 layouts in layout-land and layout-port folders with different set of controls. The problem is that Android doesn't allow me to create a separate layout specifically for reverse landscape. I need this because video is recorded upside down in this case, albeit UI is displayed correctly. If I rotate device from 0 to 180 orientation Android doesn't even call onCreate() of

How to check if android.hardware.Camera is released?

萝らか妹 提交于 2019-12-23 10:56:06
问题 I got an exception while releasing camera object "java.lang.RuntimeException: Method called after release" following is my code and exception stack trace. if (camera != null) { camera.stopPreview(); camera.release(); camera = null; } Exception stack trace - java.lang.RuntimeException: Method called after release() Thread[main,5,main] android.hardware.Camera._stopPreview(Native Method) android.hardware.Camera.stopPreview(Camera.java:626) com.s5.selfiemonkey1.activity.Preview.surfaceDestroyed

invalid preview surface android video recording

笑着哭i 提交于 2019-12-23 10:52:16
问题 I have a service, and I try to make the service record video to file. The Activity that starts the Service: public static SurfaceView mSurfaceView; public static SurfaceHolder mSurfaceHolder; public static Camera mCamera; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView1); mSurfaceHolder = mSurfaceView.getHolder(); mSurfaceHolder.setType(SurfaceHolder

Extreme camera lag on Nexus 4

拈花ヽ惹草 提交于 2019-12-23 10:26:11
问题 Using the following very simple camera preview activity (from a google example found here), the Nexus 4 camera is noticeably slower that the device's standard camera application: public class LiveCameraActivity extends Activity implements TextureView.SurfaceTextureListener { private Camera mCamera; private TextureView mTextureView; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mTextureView = new TextureView(this); mTextureView