コード例 #1
0
 public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height)
 {
     _camera2.ConfigureTransform(width, height);
 }
コード例 #2
0
 public void OnSurfaceTextureUpdated(SurfaceTexture surface)
 {
     //throw new NotImplementedException();
 }
コード例 #3
0
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     previewPage.UnderlyingService.DetectionResultAquired -= OnDetectionResultAquired;
     cameraPreview.PreviewTexture = null;
     return(true);
 }
コード例 #4
0
 public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
 {
     _camera2.OpenCamera(width, height);
 }
コード例 #5
0
 public override bool onSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     return(true);
 }
コード例 #6
0
ファイル: CarsView.cs プロジェクト: ANIVRA/VIA-Hubble
 public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
ファイル: ACamera.cs プロジェクト: joaofiliperocha/Auget
 void TextureView.ISurfaceTextureListener.OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height)
 {
 }
コード例 #8
0
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     StopCamera();
     return(true);
 }
コード例 #9
0
        public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
        {
            StopBackgroundThread();

            return(true);
        }
コード例 #10
0
ファイル: ACamera.cs プロジェクト: joaofiliperocha/Auget
 bool TextureView.ISurfaceTextureListener.OnSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     return(true);
 }
コード例 #11
0
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     return(true);
 }
コード例 #12
0
 public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
 {
     owner.OpenCamera(width, height); // TODO only open when the view is ready for viewing
 }
コード例 #13
0
        public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
        {
            {
                _surface = surface;
                {
                    int cameraCount = Android.Hardware.Camera.NumberOfCameras;
                    int cameraId    = 0;
                    Android.Hardware.Camera.CameraInfo cameraInfo = new Android.Hardware.Camera.CameraInfo();
                    for (int camIdx = 0; camIdx < cameraCount; camIdx++)
                    {
                        Android.Hardware.Camera.GetCameraInfo(camIdx, cameraInfo);
                        if (cameraInfo.Facing == Android.Hardware.CameraFacing.Front)
                        {
                            camera = Android.Hardware.Camera.Open(camIdx);

                            currentFacing = Android.Hardware.CameraFacing.Front;
                            cameraId      = camIdx;
                            break;
                        }
                    }

                    if (camera == null)
                    {
                        camera = Android.Hardware.Camera.Open();
                    }
                }


                var parameters = camera.GetParameters();
                var aspect     = ((decimal)height) / ((decimal)width);

                // Find the preview aspect ratio that is closest to the surface aspect
                //var previewSize = parameters.SupportedPreviewSizes
                //                            .OrderBy(s => Math.Abs(s.Width / (decimal)s.Height - aspect))
                //                            .First();

                var previewSize = parameters.SupportedPreviewSizes[2];
                //     mainLayout.LayoutParameters.Height = previewSize.Height;
                //     mainLayout.LayoutParameters.Width = previewSize.Width;

                parameters.SetPreviewSize(previewSize.Width, previewSize.Height);
                camera.SetParameters(parameters);
                camera.SetPreviewTexture(surface);
                StartCamera();

                //caemra page render
                Task.Run(() =>
                {
                    NetProcess.JpegStream.Clear();

                    DateTime chk = DateTime.Now;
                    while (isDestroy == false)
                    {
                        try
                        {
                            if (NetProcess.JpegStream.Count == 0)
                            {
                                continue;
                            }

                            if (chk < DateTime.Now)
                            {
                                exitButton.Text = "exit";

                                chk = DateTime.Now.AddSeconds(3);
                            }


                            MainThread.BeginInvokeOnMainThread(() =>
                            {
                                StreamWrapper ms;
                                while (NetProcess.JpegStream.TryDequeue(out ms) == true)
                                {
                                    if (ms == null)
                                    {
                                        continue;
                                    }

                                    var bitmap = BitmapFactory.DecodeByteArray(ms?.stream.ToArray(), 0, ms.stream.ToArray().Length);


                                    ImageView imageView;
                                    if (imageViewDic.TryGetValue(ms.pos, out imageView) == true)
                                    {
                                        imageView?.SetImageBitmap(bitmap);
                                    }
                                    else
                                    {
                                        AddImageView(ms.pos);

                                        if (imageViewDic.TryGetValue(ms.pos, out imageView) == true)
                                        {
                                            imageView?.SetImageBitmap(bitmap);
                                        }
                                    }


                                    //제일 하단 큰 스크린

                                    if (ms.pos == target_pos)
                                    {
                                        ImageView imageView2;
                                        if (imageViewDic.TryGetValue(6, out imageView2) == true)
                                        {
                                            imageView2?.SetImageBitmap(bitmap);
                                        }
                                        else
                                        {
                                            AddImageView(ms.pos);

                                            if (imageViewDic.TryGetValue(6, out imageView2) == true)
                                            {
                                                imageView2?.SetImageBitmap(bitmap);
                                            }
                                        }
                                    }
                                }
                            });
                        }
                        catch (Exception e)
                        {
                        }
                    }
                });


                //caemra page render
                Task.Run(() =>
                {
                    audiomgr?.record();
                });


                Task.Run(() =>
                {
                    while (isDestroy == false)
                    {
                        StreamWrapper ms;
                        if (NetProcess.AudioStream.TryDequeue(out ms) == true)
                        {
                            if (ms == null)
                            {
                                continue;
                            }

                            audiomgr?.play(ms.stream.ToArray());
                        }
                    }
                });
            }
        }
コード例 #14
0
			public override void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
			{
				// "onSurfaceTextureAvailable" is called, which means that CameraCaptureSession is not created.
				// We need to configure transform for TextureView and crate CameraCaptureSession.
				outerInstance.configureTransform(width, height);
				outerInstance.createPreviewSession();
			}
コード例 #15
0
ファイル: ACamera.cs プロジェクト: joaofiliperocha/Auget
 void TextureView.ISurfaceTextureListener.OnSurfaceTextureUpdated(SurfaceTexture surface)
 {
 }
コード例 #16
0
			public override bool onSurfaceTextureDestroyed(SurfaceTexture surface)
			{
				return true;
			}
コード例 #17
0
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surfaceTexture)
 {
     this._owner.StopCamera();
     return(true);
 }
コード例 #18
0
 public override void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height)
 {
     // SurfaceTexture size changed, we need to configure transform for TextureView, again.
     outerInstance.configureTransform(width, height);
 }
コード例 #19
0
        public void OnSurfaceTextureUpdated(SurfaceTexture surface)
        {
            this._owner.SurfaceTexture = surface;

            this.ProcessOnSurfaceTextureUpdate();
        }
コード例 #20
0
 public override void onSurfaceTextureUpdated(SurfaceTexture surface)
 {
 }
コード例 #21
0
        Task ToggleTorchAsync(bool switchOn)
        {
            return(Task.Run(() =>
            {
                lock (locker)
                {
                    if (OperatingSystem.IsAndroidVersionAtLeast((int)BuildVersionCodes.M) && !AlwaysUseCameraApi)
                    {
                        var cameraManager = Platform.CameraManager;
                        foreach (var id in cameraManager.GetCameraIdList())
                        {
                            var hasFlash = cameraManager.GetCameraCharacteristics(id).Get(CameraCharacteristics.FlashInfoAvailable);
                            if (Java.Lang.Boolean.True.Equals(hasFlash))
                            {
                                try
                                {
                                    cameraManager.SetTorchMode(id, switchOn);
                                    break;
                                }
                                catch (Exception ex)
                                {
                                    System.Diagnostics.Debug.WriteLine($"Unable to SetTorchMode on {id}: {ex.Message}");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (camera == null)
                        {
                            if (surface == null)
                            {
                                surface = new SurfaceTexture(0);
                            }

#pragma warning disable CS0618 // Camera types are deprecated in Android 10+
                            camera = Camera.Open();

                            // Nexus 5 and some devices require a preview texture
                            camera.SetPreviewTexture(surface);
                        }

                        var param = camera.GetParameters();

                        // Deprecated in an earlier android version
                        param.FlashMode = switchOn ? Camera.Parameters.FlashModeTorch : Camera.Parameters.FlashModeOff;

                        camera.SetParameters(param);

                        if (switchOn)
                        {
                            camera.StartPreview();
                        }
                        else
                        {
                            camera.StopPreview();
                            camera.Release();
                            camera.Dispose();
#pragma warning restore CS0618 // Type or member is obsolete
                            camera = null;
                            surface.Dispose();
                            surface = null;
                        }
                    }
                }
            }));
        }
コード例 #22
0
ファイル: CarsView.cs プロジェクト: ANIVRA/VIA-Hubble
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     throw new NotImplementedException();
 }
コード例 #23
0
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     _camera.StopPreview();
     _camera.Release();
     return(true);
 }
コード例 #24
0
        //async void TakePhotoButtonTapped(object sender, EventArgs e)
        //{
        //    camera.StopPreview();

        //    var image = textureView.Bitmap;

        //    try
        //    {
        //        var absolutePath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim).AbsolutePath;
        //        var folderPath = absolutePath + "/Camera";
        //        var filePath = System.IO.Path.Combine(folderPath, string.Format("photo_{0}.jpg", Guid.NewGuid()));

        //        var fileStream = new FileStream(filePath, FileMode.Create);
        //        await image.CompressAsync(Bitmap.CompressFormat.Jpeg, 50, fileStream);
        //        fileStream.Close();
        //        image.Recycle();

        //        var intent = new Android.Content.Intent(Android.Content.Intent.ActionMediaScannerScanFile);
        //        var file = new Java.IO.File(filePath);
        //        var uri = Android.Net.Uri.FromFile(file);
        //        intent.SetData(uri);
        //        MainActivity.Instance.SendBroadcast(intent);
        //    }
        //    catch (Exception ex)
        //    {
        //        System.Diagnostics.Debug.WriteLine(@"				", ex.Message);
        //    }

        //    camera.StartPreview();
        //}

        public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height)
        {
        }
コード例 #25
0
 public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height)
 {
     PrepareAndStartCamera();
 }
コード例 #26
0
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     _camera2.CameraDevice?.Close();
     _camera2.CameraDevice = null;
     return(true);
 }
コード例 #27
0
 public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
 {
     Console.WriteLine("Surface.TextureAvailable");
     VideoPlayer.SetSurface(new Surface(surface));
 }
コード例 #28
0
 public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height)
 {
     //throw new NotImplementedException();
 }
コード例 #29
0
 public bool OnSurfaceTextureDestroyed(SurfaceTexture surface)
 {
     Console.WriteLine("Surface.TextureDestroyed");
     RemoveVideo();
     return(false);
 }
コード例 #30
0
 public void OnSurfaceTextureUpdated(SurfaceTexture surface)
 {
 }
コード例 #31
0
 public void OnSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height)
 {
     Console.WriteLine("Surface.TextureSizeChanged");
 }
コード例 #32
0
			public override void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height)
			{
				// SurfaceTexture size changed, we need to configure transform for TextureView, again.
				outerInstance.configureTransform(width, height);
			}
コード例 #33
0
 public void OnSurfaceTextureUpdated(SurfaceTexture surface)
 {
     Console.WriteLine("Surface.TextureUpdated");
 }
コード例 #34
0
			public override void onSurfaceTextureUpdated(SurfaceTexture surface)
			{
			}
コード例 #35
0
		public override int startCapture()
		{
			if (isCaptureStarted)
			{
				return -1;
			}

			// Set the preferred capturing size
			configureCaptureSize(PREFERRED_CAPTURE_WIDTH, PREFERRED_CAPTURE_HEIGHT);

			// Set the capture parameters
			Camera.Parameters parameters = mCamera.Parameters;
			parameters.setPreviewSize(mCaptureWidth, mCaptureHeight);
			parameters.PreviewFormat = PIXEL_FORMAT;
			parameters.PreviewFrameRate = mCaptureFPS;
			try
			{
				mCamera.Parameters = parameters;
			}
			catch (Exception e)
			{
				Log.e(LOGTAG, "setParameters failed", e);
				return -1;
			}

			// Create capture buffers
			PixelFormat pixelFormat = new PixelFormat();
			PixelFormat.getPixelFormatInfo(PIXEL_FORMAT, pixelFormat);
			int bufSize = mCaptureWidth * mCaptureHeight * pixelFormat.bitsPerPixel / 8;
			sbyte[] buffer = null;
			for (int i = 0; i < mNumCaptureBuffers; i++)
			{
				buffer = new sbyte[bufSize];
				mCamera.addCallbackBuffer(buffer);
			}

			try
			{
				mSurfaceTexture = new SurfaceTexture(42);
				mCamera.PreviewTexture = mSurfaceTexture;

			}
			catch (Exception e)
			{
				// TODO Auto-generated catch block
				Console.WriteLine(e.ToString());
				Console.Write(e.StackTrace);
			}

			// Start preview
			mCamera.PreviewCallbackWithBuffer = this;
			mCamera.startPreview();

			mPreviewBufferLock.@lock();
			mExpectedFrameSize = bufSize;
			isCaptureRunning = true;
			mPreviewBufferLock.unlock();

			isCaptureStarted = true;

			return 0;
		}