public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); AssetManager assets = Activity.Assets; var filesToCopy = new string[] { "runtime_data/openalpr.conf" , "runtime_data/region/eu.xml" }; var AndroidDataDir = Android.App.Application.Context.DataDir.AbsolutePath; var runtimeFolder = new Java.IO.File(AndroidDataDir, "/files/runtime_data"); var renamedRuntimeFolder = new Java.IO.File(AndroidDataDir, "runtime_data"); runtimeFolder.RenameTo(renamedRuntimeFolder); var list = renamedRuntimeFolder.List(); OpenALPRConfigFile = AndroidDataDir + "/runtime_data/openalpr.conf"; var f = new Java.IO.File(AndroidDataDir); var flist = f.List(); var lib = new Java.IO.File(f, "lib"); var liblist = lib.List(); mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); OpenALPRInstance = new OpenALPR(this.Activity, AndroidDataDir, OpenALPRConfigFile, "eu", "ua"); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); }
public DroidCameraPreview(Context context, CameraOptions option) : base(context) { CameraOption = option; var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var nativePath = Context.GetExternalFilesDir(Android.OS.Environment.DirectoryDocuments); // Camera Setup File = new Java.IO.File(path, "pic.jpg"); CaptureCallback = new CameraCaptureListener(this); mOnImageAvailableListener = new ImageAvailableListener(this); mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); mTextureView = new Camera2Basic.AutoFitTextureView(context); AddView(mTextureView); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); State = CameraState.Stopped; }
protected async override void OnElementChanged(ElementChangedEventArgs <CameraPreview> e) { if (Xamarin.Forms.DesignMode.IsDesignModeEnabled) { return; } if (e.OldElement != null) // Clear old element event { } if (e.NewElement != null) { await RequestCameraPermission.RequestPermissionsAsync(); e.NewElement.StartRecording = (() => { TakePicture(); }); e.NewElement.StopRecording = (() => { CloseCamera(); }); if (Control == null) { Activity = this.Context as Activity; frameLayout = new FrameLayout(Context); frameLayout.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent); autoFitTextureView = new AutoFitTextureView(Context); autoFitTextureView.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent); frameLayout.AddView(autoFitTextureView); SetNativeControl(frameLayout); } mTextureView = Control.GetChildAt(0) as AutoFitTextureView; mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this, autoFitTextureView); //mFile = new File(Activity.GetExternalFilesDir(null), $"{Element.Filename}.jpg"); //var path = System.IO.Path.Combine( // System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), // $"{Element.Filename}" //); string pathyo = DependencyService.Get <IMediaFolder>().Path; var path = System.IO.Path.Combine( pathyo, Element.Filename); mFile = new File( path ); mCaptureCallback = new CameraCaptureListener(this); mOnImageAvailableListener = new ImageAvailableListener(this, mFile); StartTheCamera(); } base.OnElementChanged(e); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); mStateListener = new CameraStateListener () { Fragment = this }; mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener (this); ORIENTATIONS.Append ((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append ((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append ((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append ((int)SurfaceOrientation.Rotation270, 180); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _stateCallback = new CameraStateListener(this); _mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); mStateListener = new CameraStateListener() { Fragment = this }; mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); }
public CameraWidget(Context Context, ObservableCollection <File> Photos) : base(Context) { context = Context; mTextureView = new AutoFitTextureView(Context); mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); mTextureView.SurfaceTextureListener = mSurfaceTextureListener; mStateCallback = new CameraStateListener(this); StartBackgroundThread(); // mTextureView.SetBackgroundColor(Color.Black); SetBackgroundColor(Color.Black); mCaptureCallback = new CameraCaptureListener(this); mOnImageAvailableListener = new ImageAvailableListener(this, Photos, Context); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Bundle b = (savedInstanceState ?? this.Activity.Intent.Extras); this.requestId = b.GetInt(ExtraId, 0); var targetFilenameString = b.GetString(ExtraFilename); if (!string.IsNullOrEmpty(targetFilenameString)) { this.targetFilename = targetFilenameString; } else { this.targetFilename = "_____ccuiphoto.jpg"; } this.tracer.Debug("OnCreate: this.targetFilename={0}", this.targetFilename); var pathString = b.GetString(ExtraPath); if (!string.IsNullOrEmpty(pathString)) { this.path = pathString; } else { this.path = null; } this.tracer.Debug("OnCreate: this.path={0}", this.path); this.facing = new Integer(b.GetInt(ExtraCameraFacingDirection)); this.tracer.Debug("OnCreate: this.facing={0} (Integer)", this.facing.ToString()); this.cameraStateListener = new CameraStateListener { Fragment = this }; this.mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); Orientations.Append((int)SurfaceOrientation.Rotation0, 90); Orientations.Append((int)SurfaceOrientation.Rotation90, 0); Orientations.Append((int)SurfaceOrientation.Rotation180, 270); Orientations.Append((int)SurfaceOrientation.Rotation270, 180); }
protected override void OnElementChanged(ElementChangedEventArgs <Views.Renderers.CameraPreview> e) { if (Xamarin.Forms.DesignMode.IsDesignModeEnabled) { return; } if (e.OldElement != null) // Clear old element event { } if (e.NewElement != null) { e.NewElement.StartRecording = (() => { TakePicture(); }); e.NewElement.StopRecording = (() => { CloseCamera(); }); if (Control == null) { Activity = this.Context as Activity; SetNativeControl(new AutoFitTextureView(Context)); } mTextureView = Control as AutoFitTextureView; mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); //mFile = new File(Activity.GetExternalFilesDir(null), $"{Element.Filename}.jpg"); //var path = System.IO.Path.Combine( // System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), // $"{Element.Filename}" //); var path = System.IO.Path.Combine( DependencyService.Get <IMediaFolder>().Path, Element.Filename); mFile = new File( path ); mCaptureCallback = new CameraCaptureListener(this); mOnImageAvailableListener = new ImageAvailableListener(this, mFile); StartTheCamera(); } base.OnElementChanged(e); }
public DroidCameraPreview(Context context, CameraOptions option) : base(context) { CameraOption = option; // Camera Setup File = new Java.IO.File(Context.GetExternalFilesDir(null), "pic.jpg"); CaptureCallback = new CameraCaptureListener(this); mOnImageAvailableListener = new ImageAvailableListener(this, File); mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); mTextureView = new Camera2Basic.AutoFitTextureView(context); AddView(mTextureView); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); }
public XCameraCaptureView(Context context, CameraOptions option) : base(context) { cameraOption = option; // TODO Move to Initialize mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); mTextureView = new AutoFitTextureView(context); AddView(mTextureView); var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); File = new File(path, "pic.jpg"); CaptureCallback = new CameraCaptureListener(this); mOnImageAvailableListener = new ImageAvailableListener(this); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); mStateCallback = new CameraStateListener() { owner = this }; mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); var file = new File(Activity.GetExternalFilesDir(null), "pic.jpg"); this.mOnImageAvailableListener = new ImageAvailableListener(scanModule) { Owner = this, File = file }; //this.mCaptureCallback = new CameraCaptureListener() { Owner = this, File = file}; }
public CameraController2() { mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); mStateCallback = new CameraStateListener(this); mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); AppPreference appPreference = new AppPreference(); CvInvoke.UseOpenCL = false; //appPreference.UseOpenCL; string oclDeviceName = appPreference.OpenClDeviceName; if (!string.IsNullOrEmpty(oclDeviceName)) { CvInvoke.OclSetDefaultDevice(oclDeviceName); Log.Error(TAG, "\t\t --OclSetDefaultDevice: " + oclDeviceName); } mFile = new Java.IO.File(GetExternalFilesDir(null), "derp.jpg"); ISharedPreferences preference = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); string appVersion = PackageManager.GetPackageInfo(PackageName, Android.Content.PM.PackageInfoFlags.Activities).VersionName; if (!preference.Contains("cascade-data-version") || !preference.GetString("cascade-data-version", null).Equals(appVersion) || !(preference.Contains("cascade-eye-data-path") || preference.Contains("cascade-face-data-path"))) { AndroidFileAsset.OverwriteMethod overwriteMethod = AndroidFileAsset.OverwriteMethod.AlwaysOverwrite; FileInfo eyeFile = AndroidFileAsset.WritePermanantFileAsset(this, "haarcascade_eye.xml", "cascade", overwriteMethod); FileInfo faceFile = AndroidFileAsset.WritePermanantFileAsset(this, "haarcascade_frontalface_alt_tree.xml", "cascade", overwriteMethod); Log.Error(TAG, "\t\t --eyeFile.FullName: " + eyeFile.FullName); Log.Error(TAG, "\t\t --faceFile.FullName: " + faceFile.FullName); //save tesseract data path ISharedPreferencesEditor editor = preference.Edit(); editor.PutString("cascade-data-version", appVersion); editor.PutString("cascade-eye-data-path", eyeFile.FullName); editor.PutString("cascade-face-data-path", faceFile.FullName); editor.Commit(); } eyeXml = preference.GetString("cascade-eye-data-path", null); faceXml = preference.GetString("cascade-face-data-path", null); Log.Error(TAG, "\t\t --eyeXml: " + eyeXml); Log.Error(TAG, "\t\t --faceXml: " + faceXml); //face = new CascadeClassifier(faceXml); //eye = new CascadeClassifier(eyeXml); // Hide the window title and go fullscreen. RequestWindowFeature(WindowFeatures.NoTitle); Window.AddFlags(WindowManagerFlags.Fullscreen); SetContentView(Resource.Layout.take_photo_surface_view); mTextureView = (AutoFitTextureView)FindViewById(Resource.Id.CameraView); mTransparentView = (SurfaceView)FindViewById(Resource.Id.TransparentView); mTransparentView.SetZOrderOnTop(true); mTransparentView.BringToFront(); mTransparentView.Holder.SetFormat(Android.Graphics.Format.Transparent); mTransparentView.Holder.AddCallback(this); var manager = GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); var size = new Android.Graphics.Point(); manager.DefaultDisplay.GetSize(size); screenX = size.X / 2; screenY = size.Y / 2; L = screenX - 200; T = screenY - 200; R = screenX + 200; B = screenY + 200; mStateCallback = new CameraStateListener() { owner = this }; mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this); mOnImageAvailableListener = new ImageAvailableListener() { Owner = this }; // fill ORIENTATIONS list ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270); ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180); }