Exemple #1
0
        private void takePicture()
        {
            try
            {
                SCaptureRequest.Builder builder = mSCameraDevice.createCaptureRequest(SCameraDevice.TEMPLATE_STILL_CAPTURE);
                builder.addTarget(mYUVReader.Surface);

                mSCameraSession.capture(builder.build(), new CaptureCallbackAnonymousInnerClassHelper(this), mBackgroundHandler);
            }
            catch (CameraAccessException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
        }
Exemple #2
0
        private void createPreviewSession()
        {
            lock (this)
            {
                if (null == mSCameraDevice || null == mSCameraManager || null == mPreviewSize || !mTextureView.Available)
                {
                    return;
                }

                try
                {
                    SurfaceTexture texture = mTextureView.SurfaceTexture;

                    // Set default buffer size to camera preview size.
                    texture.setDefaultBufferSize(mPreviewSize.Width, mPreviewSize.Height);

                    Surface surface = new Surface(texture);

                    // Creates CaptureRequest.Builder for preview with output target.
                    mZslBuilder = mSCameraDevice.createCaptureRequest(SCameraDevice.TEMPLATE_ZERO_SHUTTER_LAG);
                    mZslBuilder.addTarget(surface);
                    mZslBuilder.addTarget(mZslReader.Surface);

                    // Creates a CameraCaptureSession here.
                    IList <Surface> outputSurface = new List <Surface>();
                    outputSurface.Add(mZslReader.Surface);
                    outputSurface.Add(surface);
                    outputSurface.Add(mJpegReader.Surface);

                    mSCameraDevice.createReprocessableCaptureSession(new InputConfiguration(mZslReader.Width, mZslReader.Height, mZslReader.ImageFormat), outputSurface, new StateCallbackAnonymousInnerClassHelper(this), mBackgroundHandler);
                }
                catch (CameraAccessException)
                {
                    showAlertDialog("Fail to create camera capture session.", true);
                }
            }
        }