Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            cameraView = FindViewById <SurfaceView>(Resource.Id.surface_view);
            textView   = FindViewById <TextView>(Resource.Id.text_view);


            TextRecognizer textRecognizer = new TextRecognizer.Builder(ApplicationContext).Build();

            if (!textRecognizer.IsOperational)
            {
            }

            //Log.Error("Main Activity", "As dependencias ainda não estão prontas para serem carregadas!");
            else
            {
                cameraSource = new CameraSource.Builder(ApplicationContext, textRecognizer)
                               .SetFacing(CameraFacing.Back)
                               .SetRequestedPreviewSize(1280, 1024)
                               .SetRequestedFps(2.0f)
                               .SetAutoFocusEnabled(true)
                               .Build();
                cameraView.Holder.AddCallback(this);
                textRecognizer.SetProcessor(this);

                //var camera =  Android.Hardware.Camera.Open();
                //Parameters parameters = camera.GetParameters();
                //parameters.FlashMode = Parameters.FlashModeOn;
                //camera.SetParameters(parameters);
                //camera.StartPreview();
            }
        }
Exemplo n.º 2
0
 public CameraAnalyzer(SurfaceView surfaceView, MobileBarcodeScanningOptions scanningOptions)
 {
     _scanningOptions     = scanningOptions;
     _cameraEventListener = new CameraEventsListener();
     _cameraController    = new CameraController(surfaceView, _cameraEventListener, scanningOptions);
     Torch = new Torch(_cameraController, surfaceView.Context);
 }
Exemplo n.º 3
0
        private void BindResources()
        {
            var toolbar = FindViewById <CenteredToolbar>(Resource.Id.toolbar);

            toolbar.SetTitle(Resource.String.new_device_scan_title);

            var layout = FindViewById <LinearLayout>(Resource.Id.instruction);

            var instructionNumber = layout.FindViewById <AppCompatTextView>(Resource.Id.instruction_number);
            var instructionText   = layout.FindViewById <AppCompatTextView>(Resource.Id.instruction_text);

            statusLabel = FindViewById <AppCompatTextView>(Resource.Id.status_label);

            instructionNumber.Text = "3";
            instructionText.SetText(Resource.String.scan_qr_message_label);

            SetSupportActionBar(toolbar);
            this.BackPressed += NewDeviceSetupActivity_BackPressed;
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            surfaceView = FindViewById <SurfaceView>(Resource.Id.cameraView);

            barcodeDetector = new BarcodeDetector.Builder(this)
                              .SetBarcodeFormats(BarcodeFormat.QrCode)
                              .Build();

            cameraSource = new CameraSource
                           .Builder(this, barcodeDetector)
                           .SetRequestedPreviewSize(640, 480)
                           .Build();

            surfaceView.Holder.AddCallback(this);
            barcodeDetector.SetProcessor(this);
        }
Exemplo n.º 4
0
        public CameraPreview(Context context, bool defaultTorchOn, bool virbationOnDetected, bool startScanningOnCreate)
            : base(context)
        {
            Configuration.IsScanning = startScanningOnCreate;
            _windowManager           = Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>();
            _barcodeDetector         = new BarcodeDetector.Builder(context)
                                       .SetBarcodeFormats(Configuration.BarcodeFormats)
                                       .Build();
            _cameraSource = new CameraSource
                            .Builder(context, _barcodeDetector)
                            .SetRequestedPreviewSize(1280, 720)
                            .SetAutoFocusEnabled(true)
                            .Build();
            Configuration.CameraSource = _cameraSource;
            _surfaceView = new SurfaceView(context);
            _surfaceView.Holder.AddCallback(new SurfaceHolderCallback(_cameraSource, _surfaceView));
            AddView(_surfaceView);

            var detectProcessor = new DetectorProcessor(context, virbationOnDetected);

            detectProcessor.OnDetected += DetectProcessor_OnDetected;
            _barcodeDetector.SetProcessor(detectProcessor);
            if (defaultTorchOn)
            {
                AutoSwitchOnTorch();
            }
        }
Exemplo n.º 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            cameraView  = FindViewById <SurfaceView>(Resource.Id.surface_view);
            drawingView = FindViewById <DrawingView>(Resource.Id.drawing_View);
            checkBox    = FindViewById <CheckBox>(Resource.Id.checkbox);

            TextRecognizer txtRecognizer = new TextRecognizer.Builder(ApplicationContext).Build();

            if (!txtRecognizer.IsOperational)
            {
                Log.Error("Main Activity", "Detector dependencies are not yet available");
            }
            else
            {
                cameraSource = new CameraSource.Builder(ApplicationContext, txtRecognizer)
                               .SetFacing(CameraFacing.Back)
                               //.SetRequestedPreviewSize(Resources.DisplayMetrics.WidthPixels, Resources.DisplayMetrics.HeightPixels)
                               .SetRequestedPreviewSize(1080, 1920)
                               .SetRequestedFps(2.0f)
                               .SetAutoFocusEnabled(true).Build();
                cameraView.Holder.AddCallback(this);
                txtRecognizer.SetProcessor(this);
            }
        }
Exemplo n.º 6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            //Establecer nuestra vista "main"
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            //Bandera
            flag = false;

            //SurfaceView
            cameraView = FindViewById <SurfaceView>(Resource.Id.surface_view);

            //TextView
            texto = FindViewById <TextView>(Resource.Id.text_view);

            //Botones
            botonCaptura = FindViewById <Button>(Resource.Id.btn_CapturaTexto);
            botonDatos   = FindViewById <Button>(Resource.Id.btn_datos);

            //Evento clic boton datos
            botonDatos.Click += DatosGuardados;

            //Obtener permisos lectura/escritura
            PermisosLecturaEscritura();

            //Crear directorio de la app
            CreacionDirectorioApp();

            //TextRecognizer
            CrearTextRecognizer();

            //Al producirse el evento Click del boton llama al metodo Capturar.
            botonCaptura.Click += Capturar;
        }
Exemplo n.º 7
0
 public CameraController(SurfaceView surfaceView, CameraEventsListener cameraEventListener)
 {
     this.context             = surfaceView.Context;
     this.holder              = surfaceView.Holder;
     this.surfaceView         = surfaceView;
     this.cameraEventListener = cameraEventListener;
 }
Exemplo n.º 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //var camera=new Camera.CameraInfo();



            var mLiveSession = new LiveSessionHW(this, 1280, 720, 15, 2048000, 0);

            mLiveSession.PrepareSessionAsync();

            SurfaceView cameraView = FindViewById <SurfaceView>(Resource.Id.camera);

            //cameraView.Holder
            mLiveSession.BindPreviewDisplay(cameraView.Holder);

            // LiveConfig liveConfig = new LiveConfig.Builder();

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.myButton);

            button.Click += delegate {
                var status = mLiveSession.StartRtmpSession("Your rtmp live url");
                if (status)
                {
                    //var temp1 = 0;
                }
            };
        }
Exemplo n.º 9
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Resource.Layout.fragment_crime_camera, container, false);

            Button takePictureButton = v.FindViewById <Button>(Resource.Id.crime_camera_takePictureButton);

            takePictureButton.Click += (object sender, EventArgs e) => {
                //Activity.Finish();
                if (mCamera != null)
                {
                    mCamera.TakePicture(this, null, this);
                }
            };

            mSurfaceView = v.FindViewById <SurfaceView>(Resource.Id.crime_camera_surfaceView);
            ISurfaceHolder holder = mSurfaceView.Holder;

            holder.SetType(SurfaceType.PushBuffers);

            holder.AddCallback(this);

            mProgressViewContainer            = v.FindViewById <View>(Resource.Id.crime_camera_progressContainer);
            mProgressViewContainer.Visibility = ViewStates.Invisible;

            return(v);
        }
            public override void OnOpened(CameraDevice camera)
            {
                // プレビュー用のSurfaceViewをリストに登録
                SurfaceView surfaceView = m_parent.m_surfaceView;

                ViewGroup.LayoutParams lp = (ViewGroup.LayoutParams)surfaceView.LayoutParameters;
                lp.Width  = 320; //横幅
                lp.Height = 240; //縦幅
                surfaceView.LayoutParameters = lp;

                surfaceView.Holder.SetFixedSize(240, 320);//縦で持つときはwidth height が逆

                List <Surface> surfaceList = new List <Surface>();

                surfaceList.Add(surfaceView.Holder.Surface);

                try
                {
                    // プレビューリクエストの設定(SurfaceViewをターゲットに)
                    m_parent.m_PreviewBuilder = camera.CreateCaptureRequest(CameraTemplate.Preview);
                    m_parent.m_PreviewBuilder.AddTarget(surfaceView.Holder.Surface);

                    // キャプチャーセッションの開始(セッション開始後に第2引数のコールバッククラスが呼ばれる)
                    camera.CreateCaptureSession(surfaceList, new CameraCaptureSessionCallback(m_parent), null);
                }
                catch (CameraAccessException e)
                {
                    // エラー時の処理を記載
                }
            }
 public DroidCameraPreview(SurfaceView a_surfaceView, Context a_Context, CustomCamera a_CustomCamera)
 {
     m_surfaceView  = a_surfaceView;
     m_CustomCamera = a_CustomCamera;
     m_Context      = a_Context;
     Initialize();
 }
        public override void OnStart(Android.Content.Intent intent, int startId)
        {
            base.OnStart(intent, startId);

            Log.Debug("SimpleService", "SimpleService started");

            flag = false;
            DAO  = new DataAccessObject();

            sv = new SurfaceView(this.BaseContext);

            position = new Position();

            getLatLong();

            //Get a surface
            sHolder = sv.Holder;

            //add the callback interface methods defined below as the Surface View callbacks
            sHolder.AddCallback(this);

            //cslls the camera
            SurfaceCreated(sHolder);

            //set up the camera and take picture
            SurfaceChanged(sHolder, Android.Graphics.Format.Jpeg, 0, 0);

            emailThread = new Thread(StartProtection);
            emailThread.Start();

            Log.Debug("", DAO.getDetails(1));
        }
Exemplo n.º 13
0
        public DroidCameraPreview(Context context, CameraPreview formsCameraPreview)
            : base(context)
        {
            FormsCameraPreview = formsCameraPreview;
            surfaceView        = new SurfaceView(context);
            AddView(surfaceView);

            _IsPreviewing = FormsCameraPreview.IsPreviewing;
            holder        = surfaceView.Holder;
            holder.AddCallback(this);

            this.context = context;

            MessagingCenter.Subscribe <LifeCyclePayload>(this, "", (p) => {
                switch (p.Status)
                {
                case LifeCycle.OnSleep:
                    if (surfaceCreated)
                    {
                        //Sleepの時にSurfaceViewが生成されていればリソース解放
                        Release();
                    }
                    break;

                case LifeCycle.OnResume:
                    if (surfaceCreated)
                    {
                        //Resumeの時にSurfaceViewが生成されていればリソース初期化
                        Initialize();
                    }
                    break;
                }
            });
        }
        protected override void OnCreate(Bundle bundle)
        {
            screenWidth  = Resources.DisplayMetrics.WidthPixels;
            screenHeight = Resources.DisplayMetrics.HeightPixels;
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.CameraLayout);
            analyseButton                       = FindViewById <Button>(Resource.Id.show);
            analyseButton.Visibility            = ViewStates.Invisible;
            retakeButton                        = FindViewById <Button>(Resource.Id.retake);
            retakeButton.Visibility             = ViewStates.Invisible;
            _textureView                        = FindViewById <TextureView>(Resource.Id.textureView);
            _textureView.SurfaceTextureListener = this;
            _surfaceView                        = FindViewById <SurfaceView>(Resource.Id.surfaceView);
            takePhoto = FindViewById <Button>(Resource.Id.captureImage);
            _surfaceView.SetZOrderOnTop(true);
            txt = FindViewById <TextView>(Resource.Id.place_items_hint);
            //set the background to transparent

            _surfaceView.Holder.SetFormat(Format.Transparent);
            holder = _surfaceView.Holder;

            takePhoto.Click     += TakePhoto_Click;
            analyseButton.Click += analyseButton_Click;
            retakeButton.Click  += RetakeButton_Click;
        }
Exemplo n.º 15
0
        /// <summary>
        /// Construct a new surface.
        /// </summary>
        /// <param name="sIdentifier">The unique identifier for this surface.  Cannot be null.  If this is not unique, it will not be checked until the surface is registered with an authority.</param>
        public Surface(String sIdentifier)
        {
            // If the identifier is not valid, throw an error.
            if (sIdentifier == null || sIdentifier.Length == 0)
            {
                throw new Exception("Surface identifier cannot be empty.");
            }

            // Otherwise set the value.  HOWEVER.. this is not authorised by the authority.  It will be checked on registration.
            this.Authority_SetIdentifier(sIdentifier);

            // Load the debug for this surface.
            //pDebugImageControl = new Image();
            //pDebugImageControl.Source = new BitmapImage(new Uri("pack://application:,,,/UbiDisplays;component/Interface/Images/DebugImage.png"));

            // Generate a key to access the projected surface.
            sProjectionDisplayKey = System.Guid.NewGuid().ToString();

            // A surface control.
            pSurfaceContent           = new SurfaceView();
            pSurfaceContent.ShowDebug = true;

            // Create a projected display for this surface.
            pProjectionDisplay         = ProjectionRenderer.AddDisplay(sProjectionDisplayKey, pSurfaceContent);//, pDebugImageControl);
            pProjectionDisplay.Visible = true;
        }
Exemplo n.º 16
0
        public CameraAnalyzer(SurfaceView surfaceView)
        {
            cameraEventListener = new CameraEventsListener();
            cameraController    = new CameraController(surfaceView, cameraEventListener);

            InitTensorflowLineService();

            var outputInfo = new SKImageInfo(
                TensorflowLiteService.ModelInputSize,
                TensorflowLiteService.ModelInputSize,
                SKColorType.Rgba8888);

            inputScaled        = new SKBitmap(outputInfo);
            inputScaledRotated = new SKBitmap(outputInfo);

            colors     = inputScaledRotated.GetPixels();
            colorCount = TensorflowLiteService.ModelInputSize * TensorflowLiteService.ModelInputSize;

            stopwatch = new Stopwatch();

            cameraFPSCounter = new FPSCounter((x) => {
                Stats.CameraFps = x.fps;
                Stats.CameraMs  = x.ms;
            });

            processingFPSCounter = new FPSCounter((x) => {
                Stats.ProcessingFps = x.fps;
                Stats.ProcessingMs  = x.ms;
            });
        }
Exemplo n.º 17
0
 public CameraAnalyzer(SurfaceView surfaceView, IScannerSessionHost scannerHost)
 {
     _scannerHost         = scannerHost;
     _cameraEventListener = new CameraEventsListener();
     _cameraController    = new CameraController(surfaceView, _cameraEventListener, scannerHost);
     Torch = new Torch(_cameraController, surfaceView.Context);
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            cameraView     = FindViewById <SurfaceView>(Resource.Id.surface_view);
            textView       = FindViewById <TextView>(Resource.Id.text_view);
            btnCheckResult = FindViewById <Button>(Resource.Id.checkResult);
            resultView     = FindViewById <TextView>(Resource.Id.result_view);

            TextRecognizer textRecognizer = new TextRecognizer.Builder(ApplicationContext).Build();

            if (!textRecognizer.IsOperational)
            {
                Log.Error("Main Activity", "Dependencias não estao prontas");
            }
            else
            {
                cameraSource = new CameraSource.Builder(ApplicationContext, textRecognizer)
                               .SetFacing(CameraFacing.Back)
                               .SetRequestedPreviewSize(1280, 1024)
                               .SetRequestedFps(2.0f)
                               .SetAutoFocusEnabled(true)
                               .Build();

                cameraView.Holder.AddCallback(this);
                textRecognizer.SetProcessor(this);
                tts = new TextToSpeech(this, this);
                btnCheckResult.Click += BtnCheckResult_Click;
            }
        }
Exemplo n.º 19
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            sv   = FindViewById <SurfaceView>(Resource.Id.campreview);
            txt  = FindViewById <TextView>(Resource.Id.txt);
            iv   = FindViewById <ImageView>(Resource.Id.img);
            face = new FaceDetector.Builder(ApplicationContext)
                   .SetTrackingEnabled(true)
                   .SetLandmarkType(LandmarkDetectionType.All)
                   .SetClassificationType(ClassificationType.All)
                   .SetMode(FaceDetectionMode.Fast)
                   .Build();



            cameraSource = new CameraSource.Builder(this, face)
                           .SetRequestedPreviewSize(640, 480)
                           .SetFacing(CameraFacing.Front)
                           .SetRequestedFps(3)
                           .Build();


            sv.Holder.AddCallback(this);

            face.SetProcessor(this);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Sets the global references to UI elements and event handlers for those elements.
        /// </summary>
        private void setupViewElements()
        {
            mVideoView     = (SurfaceView)findViewById(R.id.video);
            mTitleText     = (TextView)findViewById(R.id.titleText);
            mPositionText  = (TextView)findViewById(R.id.positionText);
            mDurationText  = (TextView)findViewById(R.id.durationText);
            mSubtitlesText = (TextView)findViewById(R.id.subtitlesText);
            mSeekBar       = (SeekBar)findViewById(R.id.videoPosition);
            mPlayButton    = (ImageButton)findViewById(R.id.playPause);
            mMuteButton    = (ImageButton)findViewById(R.id.mute);
            mSeekBar.OnSeekBarChangeListener = this;
            mPlayButton.OnClickListener      = this;
            mPositionText.Text = "00:00";

            mProgressDialog                  = new ProgressDialog(this);
            mProgressDialog.Message          = "Buffering...";
            mProgressDialog.Cancelable       = true;
            mProgressDialog.OnCancelListener = new OnCancelListenerAnonymousInnerClassHelper(this);

            View stopButton = findViewById(R.id.stop);

            stopButton.OnClickListener  = this;
            mMuteButton.OnClickListener = this;

            mDevicePicker                        = (DevicePicker)FragmentManager.findFragmentById(R.id.playerPicker);
            mDevicePicker.DeviceType             = SmcDevice.TYPE_AVPLAYER;
            mDevicePicker.DeviceSelectedListener = this;
        }
Exemplo n.º 21
0
        private void StopAll()
        {
            Log.Debug(TAG, "stopAll");

            if (vieAndroidAPI != null)
            {
                if (voERunning)
                {
                    voERunning = false;
                    stopVoiceEngine();
                }

                if (viERunning)
                {
                    viERunning = false;
                    viEAndroidJavaAPI.StopRender(channel);
                    viEAndroidJavaAPI.StopReceive(channel);
                    viEAndroidJavaAPI.StopSend(channel);
                    viEAndroidJavaAPI.RemoveRemoteRenderer(channel);
                    viEAndroidJavaAPI.ViE_DeleteChannel(channel);
                    channel = -1;
                    viEAndroidJavaAPI.StopCamera(cameraId);
                    viEAndroidJavaAPI.Terminate();
                    mLlRemoteSurface.RemoveView(remoteSurfaceView);
                    mLlLocalSurface.RemoveView(svLocal);
                    remoteSurfaceView = null;
                    svLocal           = null;
                }
            }
        }
Exemplo n.º 22
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ScanCodeQR);

            _surfaceView = FindViewById <SurfaceView>(Resource.Id.cameraView);
            _txtResult   = FindViewById <TextView>(Resource.Id.txtResult);

            // Traemos la barra toobar
            Toolbar toolBar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolBar);

            // Una marca atrás en el icono en ActionBar
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            // Creo el detector qr
            _barcodeDetector = new BarcodeDetector.Builder(this)
                               .SetBarcodeFormats(BarcodeFormat.QrCode)
                               .Build();

            // Creo la camara
            _cameraSource = new CameraSource.Builder(this, _barcodeDetector)
                            .SetRequestedPreviewSize(1600, 1024)
                            .SetAutoFocusEnabled(true)
                            .Build();

            _surfaceView.Holder.AddCallback(this);
            _barcodeDetector.SetProcessor(this);
        }
Exemplo n.º 23
0
        public virtual void SetupVideo(Guid id)
        {
            global::Android.App.Application.SynchronizationContext.Post(_ =>
            {
                AgoraVideoViewHolder <FrameLayout> container = _containers.FirstOrDefault(a => a.GUID == id);
                if (container == null)
                {
                    return;
                }

                SurfaceView layout = RtcEngine.CreateRendererView(container.NativeView.Context);
                layout.SetZOrderMediaOverlay(true);
                container.NativeView.AddView(layout);
                VideoCanvas canvas            = new VideoCanvas(layout, (int)container.VideoView.Mode, (int)container.StreamUID);
                container.VideoView.IsOffline = false;
                if (container.StreamUID == 0 || container.StreamUID == _myId)
                {
                    _agoraEngine?.SetupLocalVideo(canvas);
                    _agoraEngine?.StartPreview();
                }
                else
                {
                    _agoraEngine?.SetupRemoteVideo(canvas);
                }
                container.NativeView.Visibility = ViewStates.Visible;
            }, null);
        }
Exemplo n.º 24
0
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        SetContentView(Resource.Layout.activity_camera);
        // Create your application here
        image = FindViewById<ImageView>(Resource.Id.imageView_Photo);
        fotoButton = FindViewById<ImageView>(Resource.Id.imageView_foto);
        preview = FindViewById<SurfaceView>(Resource.Id.surfaceView_Photo);


        /*image.DrawingCacheEnabled = true;
        image.Measure(MeasureSpec.MakeMeasureSpec(200, MeasureSpecMode.Exactly),
                        MeasureSpec.MakeMeasureSpec(200, MeasureSpecMode.Exactly));
        image.Layout(0, 0, image.MeasuredWidth, image.MeasuredHeight);
        image.BuildDrawingCache(true);
        Bitmap layoutBitmap = Bitmap.CreateBitmap(image.DrawingCache);
        image.DrawingCacheEnabled = false;*/

        fotoButton.SetOnClickListener(new OnClickListener()
        {
            Parent = this
        });

        previewHolder = preview.Holder;
        previewHolder.AddCallback(
            new SurfaceCalback()
            {
                Parent = this
            });

        previewHolder.SetType(SurfaceType.PushBuffers);

        previewHolder.SetFixedSize(Window.WindowManager.DefaultDisplay.Width,
                                   Window.WindowManager.DefaultDisplay.Height);
    }
Exemplo n.º 25
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_scanner);
            cameraView = FindViewById <SurfaceView>(Resource.Id.surface_view);
            textView   = FindViewById <TextView>(Resource.Id.text_view);

            // null the static strings
            LotteryTextValidation.OnValidationComplete();

            TextRecognizer textRecog = new TextRecognizer.Builder(ApplicationContext).Build();

            if (!textRecog.IsOperational)
            {
                Log.Error("ReceiptLotteryScan activity", "depencecies are not activated");
            }
            else
            {
                cameraSource = new CameraSource.Builder(ApplicationContext, textRecog)
                               .SetFacing(CameraFacing.Back)
                               .SetRequestedPreviewSize(1280, 1024)
                               .SetRequestedFps(2.0f)
                               .SetAutoFocusEnabled(true)
                               .Build();

                cameraView.Holder.AddCallback(this);
                textRecog.SetProcessor(this);
            }
        }
Exemplo n.º 26
0
 /// <summary>
 /// Setups the video.
 /// </summary>
 /// <param name="uid">Uid.</param>
 public virtual void SetupVideo(uint uid)
 {
     global::Android.App.Application.SynchronizationContext.Post(_ =>
     {
         AgoraVideoViewHolder <FrameLayout>[] containers = _containers.Where(a => a.StreamUID == uid).ToArray();
         if (containers.Length == 0)
         {
             return;
         }
         containers.ToList().ForEach(container => {
             SurfaceView layout = RtcEngine.CreateRendererView(container.NativeView.Context);
             layout.SetZOrderMediaOverlay(true);
             container.NativeView.AddView(layout);
             VideoCanvas canvas            = new VideoCanvas(layout, (int)container.VideoView.Mode, (int)uid);
             container.VideoView.IsOffline = false;
             if (_agoraEngine != null)
             {
                 if (uid == 0 || uid == _myId)
                 {
                     _agoraEngine.SetupLocalVideo(canvas);
                     _agoraEngine.StartPreview();
                 }
                 else
                 {
                     _agoraEngine.SetupRemoteVideo(canvas);
                 }
             }
             container.NativeView.Visibility = ViewStates.Visible;
         });
     }, null);
 }
Exemplo n.º 27
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            cameraView = FindViewById <SurfaceView>(Resource.Id.surface_view);
            textView   = FindViewById <TextView>(Resource.Id.text_view);

            TextRecognizer textRecognizer = new TextRecognizer.Builder(ApplicationContext).Build();

            if (!textRecognizer.IsOperational)
            {
                Log.Error("MainActivity Activity", "Detector dependencies are not yet available");
            }
            else
            {
                cameraSource = new CameraSource.Builder(ApplicationContext, textRecognizer)
                               .SetFacing(CameraFacing.Back)
                               .SetRequestedPreviewSize(1280, 1024)
                               .SetRequestedFps(2.0f)
                               .SetAutoFocusEnabled(true)
                               .Build();

                cameraView.Holder.AddCallback(this);
                textRecognizer.SetProcessor(this);
            }
        }
Exemplo n.º 28
0
        private ViewGroup CreateVideoView(SurfaceView surface)
        {
            try
            {
                RelativeLayout layout = new RelativeLayout(Context)
                {
                    Id = surface.GetHashCode()
                };

                LayoutParams videoLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
                layout.AddView(surface, videoLayoutParams);

                TextView text = new TextView(Context)
                {
                    Id = layout.GetHashCode()
                };
                LayoutParams textParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
                textParams.AddRule(LayoutRules.AlignParentBottom, 1);
                textParams.BottomMargin = MStatMarginBottom;
                textParams.LeftMargin   = StatLeftMargin;
                text.SetTextColor(Color.White);
                text.SetTextSize(ComplexUnitType.Sp, StatTextSize);

                layout.AddView(text, textParams);
                return(layout);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(null);
            }
        }
Exemplo n.º 29
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //Set your main view here
            SetContentView(Resource.Layout.activity_scanner);
            _cameraView      = FindViewById <SurfaceView>(Resource.Id.surface_view);
            _textView        = FindViewById <TextView>(Resource.Id.text_view);
            _transparentView = FindViewById <SurfaceView>(Resource.Id.transparent_view);

            _transparentView.SetZOrderOnTop(true);
            _transparentView.Holder.SetFormat(Format.Transparent);

            _numerator = _prevCount = 0;
            //ReceiptTextValidation.OnValidationComplete();


            var textRecognizer = new TextRecognizer.Builder(ApplicationContext).Build();

            if (!textRecognizer.IsOperational)
            {
                Log.Error("Scan Activity", "Detector dependencies not yet available");
            }
            else
            {
                _cameraSource = new CameraSource.Builder(ApplicationContext, textRecognizer)
                                .SetFacing(CameraFacing.Back)
                                .SetRequestedPreviewSize(1280, 1024)
                                .SetRequestedFps(2.0f)
                                .SetAutoFocusEnabled(true)
                                .Build();
                _cameraView.Holder.AddCallback(this);
                textRecognizer.SetProcessor(this);
            }
        }
Exemplo n.º 30
0
        public CameraPreview(Context context)
            : base(context)
        {
            _surfaceView        = new SurfaceView(context);
            _surfaceView.Touch += (sender, args) =>
            {
                var x = args.Event.GetX();
                var y = args.Event.GetY();

                var touchRect = new Android.Graphics.Rect(
                    (int)(x - 100),
                    (int)(y - 100),
                    (int)(x + 100),
                    (int)(y + 100));


                var targetFocusRect = new Android.Graphics.Rect(
                    touchRect.Left * 2000 / this.Width - 1000,
                    touchRect.Top * 2000 / this.Height - 1000,
                    touchRect.Right * 2000 / this.Width - 1000,
                    touchRect.Bottom * 2000 / this.Height - 1000);

                this.DoTouchFocus(targetFocusRect);
            };

            AddView(_surfaceView);

            _windowManager = Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>();

            IsPreviewing = false;
            _holder      = _surfaceView.Holder;
            _holder.AddCallback(this);
        }
		/// <summary>
		/// Sets the global references to UI elements and event handlers for those elements.
		/// </summary>
		private void setupViewElements()
		{
			mVideoView = (SurfaceView) findViewById(R.id.video);
			mTitleText = (TextView) findViewById(R.id.titleText);
			mPositionText = (TextView) findViewById(R.id.positionText);
			mDurationText = (TextView) findViewById(R.id.durationText);
			mSubtitlesText = (TextView) findViewById(R.id.subtitlesText);
			mSeekBar = (SeekBar) findViewById(R.id.videoPosition);
			mPlayButton = (ImageButton) findViewById(R.id.playPause);
			mMuteButton = (ImageButton) findViewById(R.id.mute);
			mSeekBar.OnSeekBarChangeListener = this;
			mPlayButton.OnClickListener = this;
			mPositionText.Text = "00:00";

			mProgressDialog = new ProgressDialog(this);
			mProgressDialog.Message = "Buffering...";
			mProgressDialog.Cancelable = true;
			mProgressDialog.OnCancelListener = new OnCancelListenerAnonymousInnerClassHelper(this);

			View stopButton = findViewById(R.id.stop);
			stopButton.OnClickListener = this;
			mMuteButton.OnClickListener = this;

			mDevicePicker = (DevicePicker) FragmentManager.findFragmentById(R.id.playerPicker);
			mDevicePicker.DeviceType = SmcDevice.TYPE_AVPLAYER;
			mDevicePicker.DeviceSelectedListener = this;
		}