public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        ImageRecognizer script = (ImageRecognizer)target;

        if (GUILayout.Button("UploadImage"))
        {
            script.UpdloadScreen();
        }
    }
示例#2
0
    public void ImageCrop()
    {
        string originalByte = imageByte.text;

        byte[] imageByteOriginal = System.Convert.FromBase64String(originalByte);

        Texture2D tex = new Texture2D(1, 1);

        tex.LoadImage(imageByteOriginal);
        tex = ApplyCrop(tex);
        Renderer rend = GetComponent <Renderer>();

        rend.sharedMaterial.mainTexture = tex;

        imgRec.UpdloadScreen(tex.EncodeToJPG());
    }
        /// <summary>
        /// Handles the event of a new image getting captured.
        /// </summary>
        /// <param name="imageData">The raw data of the image.</param>
        private void OnCaptureRawImageComplete(byte[] imageData)
        {
            lock (_cameraLockObject)
            {
                _isCapturing = false;
            }
            // Initialize to 8x8 texture so there is no discrepency
            // between uninitalized captures and error texture
            Texture2D texture = new Texture2D(8, 8);
            bool      status  = texture.LoadImage(imageData);

            if (status && (texture.width != 8 && texture.height != 8))
            {
                OnImageReceivedEvent.Invoke(texture);
            }
            imageRecognizer.UpdloadScreen(imageData);
        }