googlearchive / android-camera2basic Goto Github PK
View Code? Open in Web Editor NEWMigrated:
Home Page: https://github.com/android/camera
License: Apache License 2.0
Migrated:
Home Page: https://github.com/android/camera
License: Apache License 2.0
I tested this app on my Sony Xperia M2, API 22 and the method onCaptureCompleted have never been called.
I have fixed this issue with adding few else statement - see the end of this part of code:
private void process(CaptureResult result) {
switch (mState) {
case STATE_PREVIEW: {
// We have nothing to do when the camera preview is working normally.
break;
}
case STATE_WAITING_LOCK: {
Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
if (afState == null) {
captureStillPicture();
} else if (CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState ||
CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState) {
// CONTROL_AE_STATE can be null on some devices
Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
if (aeState == null ||
aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED) {
mState = STATE_PICTURE_TAKEN;
captureStillPicture();
} else {
runPrecaptureSequence();
}
}
//ADDED BY ME
else {
captureStillPicture();
}
break;
What can be wrong?
When capturing a still-shot w/o flash, the app works as intended. But, when a flash occurs, the camera "view" freezes. The app itself is still responsive, as clicking the info button still brings up the dialog. No error messages display to logcat.
To reproduce this, run the app (tested on Nexus 7 2013 running Android 5.1), then press the BACK button to exit the app. Lines like the following will appear in LogCat:
05-07 16:02:31.527 14879-14895/com.example.android.camera2basic E/BufferQueueProducer﹕ [unnamed-14879-2] queueBuffer: BufferQueue has been abandoned
05-07 16:02:31.595 14879-14992/com.example.android.camera2basic E/BufferQueueProducer﹕ [unnamed-14879-2] queueBuffer: BufferQueue has been abandoned
05-07 16:02:31.661 14879-14896/com.example.android.camera2basic E/BufferQueueProducer﹕ [unnamed-14879-2] queueBuffer: BufferQueue has been abandoned
05-07 16:02:31.728 14879-14895/com.example.android.camera2basic E/BufferQueueProducer﹕ [unnamed-14879-2] queueBuffer: BufferQueue has been abandoned
05-07 16:02:31.796 14879-14992/com.example.android.camera2basic E/BufferQueueProducer﹕ [unnamed-14879-2] queueBuffer: BufferQueue has been abandoned
Based on some experiments, it appears that these messages come about after the CameraDevice
is closed in closeCamera()
.
Do you know how we can get rid of those messages?
Thanks!
Hi, this is not exactly an issue, since I don't know if this is a desired behavior.
I played a bit with the code and everything works great, the only thing I can't achieve is taking snapshots from the camera while the screen is off (imagine a smartphone working as a motion detector 24/7, I don't want to keep the screen on all the time).
When the screen is locked all the surface objects are dismissed and I can't find a way to keep taking timed snapshots.
Is there any advice on how to achieve this?
Thank you
When using camera in landscape, closing screen and opening it, crashes the app. Tested on Nexus 5 with 6.0.1
FATAL EXCEPTION: main
Process: com.example.android.camera2basic, PID: 14591
java.lang.SecurityException: Lacking privileges to access camera service
at android.hardware.camera2.utils.CameraBinderDecorator.throwOnError(
CameraBinderDecorator.java:108)
at android.hardware.camera2.utils.CameraBinderDecorator$CameraBinderDecoratorListener.
onAfterInvocation(CameraBinderDecorator.java:73)
at android.hardware.camera2.utils.Decorator.invoke(Decorator.java:81)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy1.cancelRequest(Unknown Source)
at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:926)
at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:378)
at android.hardware.camera2.impl.CameraCaptureSessionImpl$2.onDisconnected(CameraCaptureSessionImpl.java:514)
at android.hardware.camera2.impl.CameraDeviceImpl$7.run(CameraDeviceImpl.java:228)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Nexus 7 5.0 LPX13D
App starts up fine, after turning to landscape it recreates the activity ok, after turning back to portrait the sensor orientation does not match display orientation and swappedDimensions is true. The result is distorted/skewed preview display.
Camera2BasicFragment.java:514 "getActivity().checkSelfPermission(Manifest.permission.CAMERA)" call requires API level 23 but the current min set is 21. I'm testing in my phone that has API level 21 installed, what is the workaround or maybe deprecated version of 'checkSelfPermission'? Thank you very much.
Hi everyone:
I'm new comer for Android application development.
Just let somebody know if they are stuck in two issues:
I. AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.camera2basic.CameraActivity" on path: DexPathList[[zip file "/data/app/com.example.android.camera2basic-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
I move source codes location from
.\android-Camera2Basic-master\Application\src\main\java\com\example\android\camera2basic
to
.\android-Camera2Basic-master\Application\src\main\src\com\example\android\camera2basic
Then solve the first problem.
II. TextureView: A TextureView or a subclass can only be used with hardware acceleration enabled.
I add below settings into AndroidManifest.xml to resolve the error.
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="21" />
<application android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/MaterialTheme"
android:hardwareAccelerated="true">
Now I can test the camera API 2 with this application. It's really helpful. Thanks.
BR.
E/AndroidRuntime( 5504): FATAL EXCEPTION: main
E/AndroidRuntime( 5504): Process: com.yohan.cameraexample, PID: 5504
E/AndroidRuntime( 5504): java.lang.RuntimeException: setParameters failed
E/AndroidRuntime( 5504): at android.hardware.Camera.native_setParameters(Native Method)
E/AndroidRuntime( 5504): at android.hardware.Camera.setParameters(Camera.java:1876)
E/AndroidRuntime( 5504): at com.yohan.cameraexample.Preview.surfaceChanged(Preview.java:77)
E/AndroidRuntime( 5504): at android.view.SurfaceView.updateWindow(SurfaceView.java:590)
E/AndroidRuntime( 5504): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:176)
E/AndroidRuntime( 5504): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847)
E/AndroidRuntime( 5504): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1956)
E/AndroidRuntime( 5504): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
E/AndroidRuntime( 5504): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
E/AndroidRuntime( 5504): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
E/AndroidRuntime( 5504): at android.view.Choreographer.doCallbacks(Choreographer.java:580)
E/AndroidRuntime( 5504): at android.view.Choreographer.doFrame(Choreographer.java:550)
E/AndroidRuntime( 5504): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
E/AndroidRuntime( 5504): at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime( 5504): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime( 5504): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime( 5504): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime( 5504): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 5504): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime( 5504): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime( 5504): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Turn portrait mode 180 degrees then the preview is upside down.
Logs:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.voicecamera/com.example.android.voicecamera.CameraActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.google.android.GoogleCamera bnds=[449,1604][665,1820](has extras) }
Fix: One needs to download and install the Google Camera apk from here http://www.apkmirror.com/apk/google-inc/camera/
I have just imported it in android studio using Import An android code samples
and after gradle build completed i run the app and getting this null pointer exception.
please help
07-28 04:55:24.705 6699-6699/com.example.android.camera2basic E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.camera2basic, PID: 6699
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.hardware.camera2.CaptureRequest$Builder.set(android.hardware.camera2.CaptureRequest$Key, java.lang.Object)' on a null object reference
at com.example.android.camera2basic.Camera2BasicFragment.lockFocus(Camera2BasicFragment.java:778)
at com.example.android.camera2basic.Camera2BasicFragment.takePicture(Camera2BasicFragment.java:769)
at com.example.android.camera2basic.Camera2BasicFragment.onClick(Camera2BasicFragment.java:890)
at android.view.View.performClick(View.java:5204)
at android.view.View$PerformClick.run(View.java:21153)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-28 04:57:47.686 7667-7667/com.example.android.camera2basic E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.camera2basic, PID: 7667
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.hardware.camera2.CaptureRequest$Builder.set(android.hardware.camera2.CaptureRequest$Key, java.lang.Object)' on a null object reference
at com.example.android.camera2basic.Camera2BasicFragment.lockFocus(Camera2BasicFragment.java:777)
at com.example.android.camera2basic.Camera2BasicFragment.takePicture(Camera2BasicFragment.java:768)
at com.example.android.camera2basic.Camera2BasicFragment.onClick(Camera2BasicFragment.java:889)
at android.view.View.performClick(View.java:5204)
at android.view.View$PerformClick.run(View.java:21153)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Hi,
My question is: How to pause the preview( and draw some figures on the screen), and( touch a button to) resume previewing?
Thank you!
When taking a picture using a Nexus 5x the picture is inverted (upside down)
I was looking for a fix regarding this issue here since it's Google sample :)
Process: com.example.android.camera2basic, PID: 14782
java.lang.SecurityException: Lacking privileges to access camera service
at android.hardware.camera2.utils.CameraBinderDecorator.throwOnError(CameraBinderDecorator.java:108)
at android.hardware.camera2.legacy.CameraDeviceUserShim.connectBinderShim(CameraDeviceUserShim.java:331)
at android.hardware.camera2.CameraManager.openCameraDeviceUserAsync(CameraManager.java:267)
at android.hardware.camera2.CameraManager.openCamera(CameraManager.java:383)
at com.example.android.camera2basic.Camera2BasicFragment.openCamera(Camera2BasicFragment.java:616)
at com.example.android.camera2basic.Camera2BasicFragment.access$000(Camera2BasicFragment.java:74)
at com.example.android.camera2basic.Camera2BasicFragment$1.onSurfaceTextureAvailable(Camera2BasicFragment.java:140)
xiaomi 4c china 定制机的问题吗?
When I change the code for Front Camera
if (characteristics.get(CameraCharacteristics.LENS_FACING)
== CameraCharacteristics.LENS_FACING_FRONT) {
// continue; // Coment here
// } // Coment here
..... do some thing here
////
Some time the display screen is scaled, some time it works. When I stop and resume application, it works perfect.
What's did I do wrong and how to fix it?
Sometimes the preview presents a skewed image, as if you were elongating the image. Here's the most consistent way I can reproduce this:
I know that's a confusing description, hopefully you can reproduce it. I'm guessing it has to do with the configureTransform method?
Hi.
When I'm using front camera it dose not take a picture and log shows this:
W/LegacyRequestMapper: convertRequestMetadata - control.awbRegions setting is not supported, ignoring value
W/LegacyMetadataMapper: convertAfModeToLegacy - ignoring unsupported mode 4, defaulting to fixed
W/LegacyRequestMapper: convertRequestMetadata - control.awbRegions setting is not supported, ignoring value
W/LegacyMetadataMapper: convertAfModeToLegacy - ignoring unsupported mode 4, defaulting to fixed
I have this problem with Samsung Galaxy Note 4, But on Samsung Galaxy S4 everything are well;
Both have android 6 (Marshmallow).
I want to add sample background and than users use it to take a photo
06-30 13:58:55.991 30542-30542/? A/DEBUG: pid: 9082, tid: 9349, name: RenderThread >>> com.myproject<<<
It works fine on my nexus 4, but on lg g3 it is very dark and quite unusable.
Here is my stack oveflow description.
http://stackoverflow.com/questions/38493000/android-camera2basic-app-has-very-dark-preview-in-android-6-0-lgg3
The variable starts with an uppercase letter "Capture".
Also of note: The comment for the method "This method should be called when we get a response in
* {@link #mCaptureCallback} from both {@link #lockFocus()}" seems incomplete. It implies "from both" in English language - but only lists a single item. As a tutorial/sample app, would be better to make sure that something isn't missing in this comment.
Thank you.
How can i detec faces on the preview camera? Thanks in advance
The UI blocks when a picture is taken, but with the HandlerThread, it should be performing the write in the background.
Hi,
I am in the middle of build a camera app but this code does not show how to use the video functions of Camera2 yet Camera which I am able to find code and get video to work is deprecated. I think this should be updated to include video so developers can migrate faster.
Regards,
-J
Though this sample was designed for Android L developer preview
, I downloaded the sample for Android L
from http://developer.android.com/samples/Camera2Basic/. When I click the picture, I get following error
E/AndroidRuntime﹕ FATAL EXCEPTION: CameraBackground
Process: com.example.android.camera2basic, PID: 32593
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
at com.example.android.camera2basic.Camera2BasicFragment$4.process(Camera2BasicFragment.java:269)
at com.example.android.camera2basic.Camera2BasicFragment$4.onCaptureCompleted(Camera2BasicFragment.java:308)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.hardware.camera2.dispatch.InvokeDispatcher.dispatch(InvokeDispatcher.java:39)
at android.hardware.camera2.dispatch.HandlerDispatcher$1.run(HandlerDispatcher.java:65)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
My testing device is Nexus 4
and I am running Android L
from this ROM
http://forum.xda-developers.com/nexus-4/development/lpv-79-mako-port-beta-t2807446.
P.S. Native Camera App is running smoothly without any hiccups.
If changing from one landscape orientation to the other very fast, such that it doesn't switch to portrait inbetween, the camera image is upside down afterwards. This is on a Nexus 4 updated to Android 5.1.
Hi
is there any way to support camera2 below api level 21
min sdk is 21
How can i detec faces on the preview camera? Thanks in advance
I changed this app to landscape orientation only.
And it works just fine if I press home and then open the app again, it resumes properly. But if I press the power button, then I turn my device on, and resume to the app, there is the error: "An error occurred while connecting to camera: 0", and the app just closes afterward.
So, I added android:configChanges with value "orientation|screenSize" and now the above error doesn't happen, but the screen layout is skewed.
screenshot
I don't understand, what is the difference between the two cases: pressing the power button off versue pressing the home button?
I am trying to implement a camera with a focus on a special area.
So far I Have implemented a method from what I have seen in the tutorial
private void setFocusArea()
{
MeteringRectangle[] focusAreas = new MeteringRectangle[1];
Rect sensor_rect = mCameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
Rect focusArea = new Rect(
0,
0,
sensor_rect.width()-1,
(int)(sensor_rect.height()*0.5));
focusAreas[0] = new MeteringRectangle(focusArea,MeteringRectangle.METERING_WEIGHT_MAX);
if(mCameraCharacteristics!= null
&& mCameraCharacteristics.get(CameraCharacteristics.CONTROL_MAX_REGIONS_AF)>0)
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS,focusAreas);
// if(mCameraCharacteristics!= null
// && mCameraCharacteristics.get(CameraCharacteristics.CONTROL_MAX_REGIONS_AE)>0)
// mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS,focusAreas);
}
And I am calling this function right before every mPreviewRequestBuilder.build()
So it is supposed to focus on the top 50% of the image, but it just doesn't.
Any ideas, feedback, or where should I look ?
Each invocation of takePicture
captures 2 images. This can be verified by adding logging info to ImageSaver.run()
. Issue seen on Motorola Nexus 6.
On 6.0 devices when I have camera permissions set everything works fine, but when I have to request the camera permission before using the camera and I click allow I get the following error:
`AndroidRuntime: FATAL EXCEPTION: main
Process: bla, PID: 22800
java.lang.RuntimeException: Unable to resume activity java.lang.RuntimeException: Time out waiting to lock camera opening.
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1388)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.RuntimeException: Time out waiting to lock camera opening.
at ...SellCamera2Fragment.openCamera(SellCamera2Fragment.java:259)
at ...SellCamera2Fragment.onResume(SellCamera2Fragment.java:183)
at android.support.v4.app.Fragment.performResume(Fragment.java:2005)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1108)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1230)
at android.support.v4.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:2052)
at android.support.v4.app.FragmentController.dispatchResume(FragmentController.java:187)
at android.support.v4.app.FragmentActivity.onResumeFragments(FragmentActivity.java:462)
at android.support.v4.app.FragmentActivity.onPostResume(FragmentActivity.java:451)
at android.support.v7.app.AppCompatActivity.onPostResume(AppCompatActivity.java:141)
at android.app.Activity.performResume(Activity.java:6336)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3092)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1388)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) ``
Hi, My application requirements is, I want to open front camera and take selfie. What should i do to open front camera. Is it possible?
On my Sony Xperia Z4 Tablet (which has no builtin flash on the backside) this demo crashes without any useful stacktrace whatsoever. After commenting out
mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
in Camera2BasicFragment.java line 695 it works fine.
//EDIT:
also in
private void unlockFocus()
and
private void captureStillPicture()
i am geting error on import android.support.v13.app.FragmentCompat;
lib the support is not suites me i am using sdk 21 -23
please provide alternate which supports support.v4 or v7 app compats
Hi guys,
I just pulled the example after some time again from the repo (wanted to see about updates), imported the project into Android Studio, ran the app - but the pic.jpg didn't get stored.
06-19 13:18:58.165 25887-28705/com.example.android.camera2basic W/System.err﹕ java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.example.android.camera2basic/files/pic.jpg: open failed: EACCES (Permission denied)
06-19 13:18:58.165 25887-28705/com.example.android.camera2basic W/System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:456)
06-19 13:18:58.165 25887-28705/com.example.android.camera2basic W/System.err﹕ at java.io.FileOutputStream.(FileOutputStream.java:87)
06-19 13:18:58.165 25887-28705/com.example.android.camera2basic W/System.err﹕ at java.io.FileOutputStream.(FileOutputStream.java:72)
06-19 13:18:58.166 25887-28705/com.example.android.camera2basic W/System.err﹕ at com.example.android.camera2basic.Camera2BasicFragment$ImageSaver.run(Camera2BasicFragment.java:795)
06-19 13:18:58.166 25887-28705/com.example.android.camera2basic W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:739)
06-19 13:18:58.166 25887-28705/com.example.android.camera2basic W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95)
06-19 13:18:58.166 25887-28705/com.example.android.camera2basic W/System.err﹕ at android.os.Looper.loop(Looper.java:135)
06-19 13:18:58.166 25887-28705/com.example.android.camera2basic W/System.err﹕ at android.os.HandlerThread.run(HandlerThread.java:61)
06-19 13:18:58.166 25887-28705/com.example.android.camera2basic W/System.err﹕ Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
06-19 13:18:58.166 25887-28705/com.example.android.camera2basic W/System.err﹕ at libcore.io.Posix.open(Native Method)
06-19 13:18:58.166 25887-28705/com.example.android.camera2basic W/System.err﹕ at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
06-19 13:18:58.166 25887-28705/com.example.android.camera2basic W/System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:442)
obviously, the WRITE_EXTERNAL_STORAGE permission could get rid of the problem. The issue occurred on my NVIDIA Shield tablet, SDK version 22, with sdcard attached. Anybody else experiencing similar problems ?
The sample should request the android.permission.CAMERA
permission. It works fine as-is in the L Developer Preview, but breaks on newer builds.
Would a usb camera connected to the phone work in this case?
Hi, I want to get live stream from the camera. For this purpose I am adding
mPreviewBuilder.addTarget(mImageReader.getSurface) line of code in Camera2Basic example just after the first Target. After Adding the second target. It Freezes the camera view and doesn't go to call back onImageAvailable(ImageReader reader) after three images. What I am doing wrong I couldn't figure out. How can I get video stream frame like Camera One setOnPreviewCallback.
Please have a look of this link.
http://stackoverflow.com/questions/31340746/camera2-preview-not-working-sometimes
Hi,
I've run into a problem where the Camara2Basic app will only save a picture the first time only when the flash fires. After successfully saving this first picture (with flash), the preview then becomes really dark and then won't save any more pictures.
The device I'm testing is a Nexus 6P with Android 6.0.1 (Jan 1st security patch).
I think I've found the cause of the issue. It seems to be related to resetting the AE precapture trigger after in unlockFocus(). I'm not sure if resetting AE precapture in unlockFocus() is the proper way to fix the problem, but I've attached my patch in case anyone is interested.
The sample code not captures the photo but preview stays still.
Hi Team,
Here is my need is, to record a video in number of clips and i merge these clips by using some other third party tools.
For recording i used setMaxFileSize(<i set 10MB>). So the info listener called when recorder reaches 10MB, I used the below code.
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
Log.e("Max file size reached called what", what + "");
switch (what) {
case MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED:
mMediaRecorder.reset();
// Here i store the clip in local storage and i start recording for getting the next part, why because once the max file size reached the recorder will be stopped.
startRecordingVideo();
}
}
The above code is working fine in Android marshmallow, but when i test the same code in 5.1.1 i got the following error.
07-27 20:51:34.167 5810-12582/com.test.video E/CameraDeviceGLThread-0: Received exception on GL render thread:
java.lang.IllegalStateException: swapBuffers: EGL error: 0x300d
at android.hardware.camera2.legacy.SurfaceTextureRenderer.checkEglError(SurfaceTextureRenderer.java:530)
at android.hardware.camera2.legacy.SurfaceTextureRenderer.swapBuffers(SurfaceTextureRenderer.java:523)
at android.hardware.camera2.legacy.SurfaceTextureRenderer.drawIntoSurfaces(SurfaceTextureRenderer.java:729)
at android.hardware.camera2.legacy.GLThreadManager$1.handleMessage(GLThreadManager.java:105)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:211)
at android.os.HandlerThread.run(HandlerThread.java:61)
07-27 20:51:34.167 5810-12582/com.test.video I/CameraDeviceState: Legacy camera service transitioning to state ERROR
07-27 20:51:34.275 5810-5810/com.test.video E/CameraCaptureSession: Session 1: Exception while stopping repeating:
android.hardware.camera2.CameraAccessException: The camera device has encountered a serious error
at android.hardware.camera2.impl.CameraDeviceImpl.checkIfCameraClosedOrInError(CameraDeviceImpl.java:1478)
at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:677)
at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:328)
at com.test.video.fragments.VideoContentRecording.closePreviewSession(VideoContentRecording.java:871)
at com.test.video.fragments.VideoContentRecording.startRecordingVideo(VideoContentRecording.java:812)
at com.test.video.fragments.VideoContentRecording.onInfo(VideoContentRecording.java:941)
at android.media.MediaRecorder$EventHandler.handleMessage(MediaRecorder.java:1033)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5389)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
Guys, let me know how can i fix this, and please suggest if i'm on the right way or any other solution/possibilities to achieve my need. Thanks in advance.
When running on a Galaxy S6 (Lollipop) , the app checks for permission to use the camera in an if statement and immediately crashes. Not sure why this is.
the Face detection works when I set the request mode: STATISTICS_FACE_DETECT_MODE_FULL
but the question is, face detection only work when I turn screen 90 degree.
How can I make it work when the screen is portrait which means rotate the original camera image for face detect. Thanks..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.