private void OnLoadModel(object sender, RoutedEventArgs e)
        {
            PoseNet posenet = new PoseNet();

            using (var graph = new TFGraph())
            {
                graph.Import(File.ReadAllBytes("Resources\\frozen_model.bytes"));
                var    session = new TFSession(graph);
                string input   = "photo.jpg";
                var    tensor  = ImageUtil.CreateTensorFromImageFile(input);
                var    runner  = session.GetRunner();

                runner.AddInput(graph["image"][0], tensor);
                runner.Fetch(
                    graph["heatmap"][0],
                    graph["offset_2"][0],
                    graph["displacement_fwd_2"][0],
                    graph["displacement_bwd_2"][0]
                    );
                var result           = runner.Run();
                var heatmap          = (float[, , , ])result[0].GetValue(jagged: false);
                var offsets          = (float[, , , ])result[1].GetValue(jagged: false);
                var displacementsFwd = (float[, , , ])result[2].GetValue(jagged: false);
                var displacementsBwd = (float[, , , ])result[3].GetValue(jagged: false);

                var poses = posenet.DecodeMultiplePoses(
                    heatmap, offsets,
                    displacementsFwd,
                    displacementsBwd,
                    outputStride: 16, maxPoseDetections: 15,
                    scoreThreshold: 0.001f, nmsRadius: 20);
            }
        }
Exemple #2
0
    void Start()
    {
        string path = Path.Combine(Application.streamingAssetsPath, fileName);

        poseNet = new PoseNet(path);
        // Init camera
        string cameraName = WebCamUtil.FindName();

        webcamTexture = new WebCamTexture(cameraName, 640, 480, 30);
        webcamTexture.Play();
        cameraView.texture = webcamTexture;
        glDrawer.OnDraw   += OnGLDraw;
    }
Exemple #3
0
    private void Start()
    {
        poseNet = new PoseNet(fileName);

        draw = new PrimitiveDraw(Camera.main, gameObject.layer)
        {
            color = Color.green,
        };

        cancellationToken = this.GetCancellationTokenOnDestroy();

        var webCamInput = GetComponent <WebCamInput>();

        webCamInput.OnTextureUpdate.AddListener(OnTextureUpdate);
    }
    void Start()
    {
        string path = Path.Combine(Application.streamingAssetsPath, fileName);

        poseNet = new PoseNet(path);

        // Init camera
        string cameraName = WebCamUtil.FindName();

        webcamTexture = new WebCamTexture(cameraName, 640, 480, 30);
        webcamTexture.Play();
        cameraView.texture = webcamTexture;

        draw = new PrimitiveDraw()
        {
            color = Color.green,
        };
    }
    // Use this for initialization
    void Start()
    {
        _camera = GetComponent <Camera>();


        WebCamDevice[] devices = WebCamTexture.devices;

        if (devices.Length > 1)
        {
            webcamTexture = new WebCamTexture(devices[1].name, Screen.width, (Screen.height / 2), FPS);
        }
        else
        {
            webcamTexture = new WebCamTexture(devices[0].name, Screen.width, (Screen.height / 2), FPS);
        }

        if (posenet == null)
        {
            posenet        = new PoseNet();
            debugText.text = "Model Loaded";
        }

        //    GetComponent<Renderer>().material.mainTexture = webcamTexture;

        m_Display.material.mainTexture = webcamTexture;

        //    model = ModelLoader.LoadFromStreamingAssets(modelName + ".bytes");

        //   worker = BarracudaWorkerFactory.CreateWorker(BarracudaWorkerFactory.Type.Compute, model);

        webcamTexture.Play();

        //    gl = GameObject.Find("GLRenderer").GetComponent<GLRenderer>();

        gl = GameObject.FindGameObjectWithTag("GLRenderer").GetComponent <GLRenderer>();

        //    StartCoroutine(PoseUpdateFromStart());

        Debug.Log("Made it to the end of start");

        //    worker.Dispose();
    }