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); } }
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; }
void SetupUserInterface() { activity = this.Context as Activity; view = activity.LayoutInflater.Inflate(ObjectDetectionApp.Droid.Resource.Layout.CameraLayout, this, false); transparentView = view.FindViewById <SurfaceView>(ObjectDetectionApp.Droid.Resource.Id.transparentView); transparentView.SetZOrderOnTop(true); holderTransparent = transparentView.Holder; holderTransparent.SetFormat(Format.Transparent); textureView = view.FindViewById <TextureView>(ObjectDetectionApp.Droid.Resource.Id.textureView); textureView.SurfaceTextureListener = this; }
private void StartVideoViewInBackground() { var windowManager = GetSystemService(WindowService).JavaCast <IWindowManager>(); var layoutParams = new WindowManagerLayoutParams(1, 1, WindowManagerTypes.SystemOverlay, WindowManagerFlags.WatchOutsideTouch, Format.Translucent); layoutParams.Gravity = GravityFlags.Top | GravityFlags.Left; prevImage = new SurfaceView(this); prevImage.SetZOrderOnTop(true); windowManager.AddView(prevImage, layoutParams); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); _textureView = (TextureView)FindViewById(Resource.Id.textureView); _textureView.SurfaceTextureListener = this; _surfaceView = (SurfaceView)FindViewById(Resource.Id.surfaceview); //set to top layer _surfaceView.SetZOrderOnTop(true); //set the background to transparent _surfaceView.Holder.SetFormat(Format.Transparent); holder = _surfaceView.Holder; _surfaceView.Touch += _surfaceView_Touch; }
public bool Start(CameraFacing cameraId, GotchaAFrame gotchaAFrameFromCamera) { bool result = true; this.IsStopped = false; this.GotchaAFrameCallback = gotchaAFrameFromCamera; try { using (Handler handler = new Handler(Looper.MainLooper)) { handler.Post(() => { cameraPreviewCallback = new MyCameraPreviewCallback(PictureDefaultFilename, GotchaAFrameFromCamera); surfaceView = new SurfaceView(Application.Context); windowManager = Application.Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); WindowManagerLayoutParams parameters = new WindowManagerLayoutParams( 1, 1, WindowManagerTypes.SystemOverlay, WindowManagerFlags.WatchOutsideTouch, Android.Graphics.Format.Translucent); surfaceHolder = surfaceView.Holder; surfaceView.SetZOrderOnTop(true); surfaceHolder.SetFormat(Android.Graphics.Format.Translucent); surfaceHolderCallback = new MySurfaceHolderCallback(surfaceHolder, cameraPreviewCallback); surfaceHolderCallback.cameraId = cameraId; surfaceHolder.AddCallback(surfaceHolderCallback); windowManager.AddView(surfaceView, parameters); }); } } catch (Exception e) { Log.Error(TAG, "Error: " + e.StackTrace); result = false; } return(result); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_camera); _textureView = (TextureView)FindViewById(Resource.Id.textureView); _textureView.SurfaceTextureListener = this; // что тут происходит?? _surfaceView = (SurfaceView)FindViewById(Resource.Id.surfaceview); //set to top layer _surfaceView.SetZOrderOnTop(true); //set the background to transparent _surfaceView.Holder.SetFormat(Android.Graphics.Format.Transparent); // что тут происходит?? holder = _surfaceView.Holder; // что тут происходит?? _surfaceView.Touch += SurfaceView_Touch; // Получаю клиентов в радиусе 500. GetUsersLoc(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); // 防止發生預期錯誤用: StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.SetVmPolicy(builder.Build()); // 顯示最上方的app名稱 //Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); //SetSupportActionBar(toolbar); FindViewById <Button>(Resource.Id.btn_rec).Click += Rec_Click; FindViewById <Button>(Resource.Id.btn_view).Click += View_Click; // 跑馬燈 TextView tv = FindViewById <TextView>(Resource.Id.mytv); tv.Selected = true; // 設定使用說明的按鈕 AlertDialog.Builder alert_tips = new AlertDialog.Builder(this); // For Button_Tips AlertDialog.Builder alert_initial = new AlertDialog.Builder(this); // For initial tips dialog if (show_time == 0) { alert_initial.SetTitle("使用順序"); alert_initial.SetMessage("1. 測謊規則 -> 開始測謊 -> 查看影像.\n2. 請詳細閱讀\u201C測謊規則\u201C.\n3. 閱讀完畢後,即可\u201C開始測謊\u201C.\n4. \u201C查看影像\u201C可預覽影像,方便確認影像品質!"); alert_initial.SetIcon(Android.Resource.Drawable.IcDialogInfo); alert_initial.SetPositiveButton(" ok", new EventHandler <DialogClickEventArgs>((sender, e) => { })); alert_initial.Show(); show_time++; } FindViewById <Button>(Resource.Id.btn_tips).Click += (sender, e) => { alert_tips.SetTitle("測謊說明"); alert_tips.SetMessage("1. 確保受測者臉部完全包覆於黃色提示框內.\n" + "2. 請確保問題可讓受測者於6秒內回答完畢,敘述問題完畢後,即可按下**開始測謊**錄製影像,6秒後將自動停止錄影.\n" + "3. 錄製完畢後,按下**查看影像**預覽影像品質.\n" + "4. 請確認影片品質並檢查Wi-Fi功能是否開啟,無誤即可按下**上傳檔案**,等待數秒後即獲得測謊結果.\n" + "5. 最後,由衷的邀請您按下**填寫回饋單**,給予我們寶貴的建議,謝謝體驗!!!"); alert_tips.SetIcon(Android.Resource.Drawable.IcDialogInfo); alert_tips.Show(); }; alert_tips.SetPositiveButton(" ok", new EventHandler <DialogClickEventArgs>((sender, e) => { })); // 相機與錄製功能設定 _MediaRecorder = new MediaRecorder(); Camera = Camera.Open(); surfaceView = FindViewById <SurfaceView>(Resource.Id.surfaceView); _Holder = surfaceView.Holder; _SurfaceHolderCallBack = new SurfaceHolderCallBack(this, Camera, _MediaRecorder); _Holder.AddCallback(_SurfaceHolderCallBack); _Holder.SetType(SurfaceType.PushBuffers); // For rectangle on surfaceview sv_rec = FindViewById <SurfaceView>(Resource.Id.surface_rec); holder = sv_rec.Holder; sv_rec.Holder.SetFormat(Android.Graphics.Format.Transparent); holder.SetFormat(Android.Graphics.Format.Transparent); sv_rec.SetZOrderMediaOverlay(true); sv_rec.SetZOrderOnTop(true); holder.AddCallback(this); } // End of OnCreate()