Beispiel #1
0
    private void Update()
    {
        //クリック座標を白く塗りつぶす
        if (Input.GetMouseButton(0))
        {
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out var hit, 100.0f))
            {
                var pixel = new Vector2(hit.textureCoord.x * width, hit.textureCoord.y * height);
                Draw(Vector2Int.RoundToInt(pixel));
            }

            texture.SetPixels(buffer);
            texture.Apply();
        }

        //塗りつぶした部分を1としてfloatの配列に代入
        for (int i = 0; i < buffer.Length; i++)
        {
            input[i] = buffer[i].r;
        }

        //推論
        var num = mnistInference.Inference(input);

        answer.text = num.ToString();
    }