/// <summary>
        /// Called when this activity is created.
        /// </summary>
        /// <param name="bundle"></param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Result);

            // Toolbar
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "OthelloHelper";

            // Inputs
            image_path = Intent.Extras.GetString("image_path");
            Log.Info(TAG, $"Path : {image_path}");
            isWhite     = Intent.Extras.GetBoolean("is_white");
            playerColor = isWhite ? "white" : "black";
            float rotationAngle = Intent.Extras.GetFloat("rotation_angle");

            // Views
            textResult      = FindViewById <TextView>(Resource.Id.textResult);
            textResult.Text = "Player " + playerColor + " should play on cell ...";
            imageView       = FindViewById <ImageView>(Resource.Id.imageView);

            try
            {
                // Get bitmap
                bitmap = MediaStore.Images.Media.GetBitmap(ContentResolver, Android.Net.Uri.Parse(image_path));
                bitmap = ResizeBitmap(bitmap);

                // Rotate if angle is different than 0
                if (rotationAngle != 0f)
                {
                    var matrix = new Matrix();
                    matrix.PostRotate(rotationAngle);
                    bitmap = Bitmap.CreateBitmap(bitmap, 0, 0, bitmap.Width, bitmap.Height, matrix, true);
                }
                Log.Info(TAG, $"Bitmap : {bitmap}. ByteCount : {bitmap.ByteCount}");
                imageView.SetImageBitmap(bitmap);
            }
            catch
            {
                Log.Warn(TAG, $"Can't create bitmap");
            }

            // Init OpenCV
            if (!OpenCVLoader.InitDebug())
            {
                Log.Debug(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
                OpenCVLoader.InitAsync(OpenCVLoader.OpencvVersion300, this, this);
            }
            else
            {
                Log.Debug(TAG, "OpenCV library found inside package. Using it!");
                OnManagerConnected(LoaderCallbackInterface.Success);
            }
        }
        protected override void OnResume()
        {
            base.OnResume();

            if (!OpenCVLoader.InitDebug())
            {
                OpenCVLoader.InitAsync(OpenCVLoader.OpencvVersion300, this, this);
            }
            else
            {
                OnManagerConnected(LoaderCallbackInterface.Success);
            }
        }
Example #3
0
 protected override void OnResume()
 {
     base.OnResume();
     if (!OpenCVLoader.InitDebug())
     {
         Log.Debug(Tag, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
         OpenCVLoader.InitAsync(OpenCVLoader.OpencvVersion300, this, mLoaderCallback);
     }
     else
     {
         Log.Debug(Tag, "OpenCV library found inside package. Using it!");
         mLoaderCallback.OnManagerConnected(LoaderCallbackInterface.Success);
     }
 }