void Start()
    {
        // Init model
        string detectionPath = Path.Combine(Application.streamingAssetsPath, poseDetectionModelFile);

        poseDetect = new PoseDetect(detectionPath);
        string landmarkPath = Path.Combine(Application.streamingAssetsPath, poseLandmarkModelFile);

        poseLandmark = new PoseLandmarkDetect(landmarkPath);

        // Init camera
        string cameraName = WebCamUtil.FindName(new WebCamUtil.PreferSpec()
        {
            isFrontFacing = false,
            kind          = WebCamKind.WideAngle,
        });

        webcamTexture      = new WebCamTexture(cameraName, 1280, 720, 30);
        cameraView.texture = webcamTexture;
        webcamTexture.Play();
        Debug.Log($"Starting camera: {cameraName}");

        // Init frame
        frame = Instantiate(framePrefab, Vector3.zero, Quaternion.identity, cameraView.transform);

        draw = new PrimitiveDraw()
        {
            color = Color.blue,
        };
    }
Example #2
0
    private void Start()
    {
        // Init model
        poseDetect   = new PoseDetect(poseDetectionModelFile);
        poseLandmark = new PoseLandmarkDetect(poseLandmarkModelFile, landmarkOptions);

        draw = new PrimitiveDraw(Camera.main, gameObject.layer);
        viewportLandmarks = new Vector4[PoseLandmarkDetect.LandmarkCount];

        cancellationToken = this.GetCancellationTokenOnDestroy();

        GetComponent <WebCamInput>().OnTextureUpdate.AddListener(OnTextureUpdate);
    }
    void Start()
    {
        // Init model
        string detectionPath = Path.Combine(Application.streamingAssetsPath, poseDetectionModelFile);
        string landmarkPath  = Path.Combine(Application.streamingAssetsPath, poseLandmarkModelFile);

        switch (mode)
        {
        case Mode.UpperBody:
            poseDetect   = new PoseDetectUpperBody(detectionPath);
            poseLandmark = new PoseLandmarkDetectUpperBody(landmarkPath);
            break;

        case Mode.FullBody:
            poseDetect   = new PoseDetectFullBody(detectionPath);
            poseLandmark = new PoseLandmarkDetectFullBody(landmarkPath);
            break;

        default:
            throw new System.NotSupportedException($"Mode: {mode} is not supported");
        }

        // Init camera
        string cameraName = WebCamUtil.FindName(new WebCamUtil.PreferSpec()
        {
            isFrontFacing = false,
            kind          = WebCamKind.WideAngle,
        });

        webcamTexture      = new WebCamTexture(cameraName, 1280, 720, 30);
        cameraView.texture = webcamTexture;
        webcamTexture.Play();
        Debug.Log($"Starting camera: {cameraName}");

        draw        = new PrimitiveDraw(Camera.main, gameObject.layer);
        worldJoints = new Vector3[poseLandmark.JointCount];

        cancellationToken = this.GetCancellationTokenOnDestroy();
    }
    void Start()
    {
        // Init model
        poseDetect   = new PoseDetect(poseDetectionModelFile);
        poseLandmark = new PoseLandmarkDetect(poseLandmarkModelFile);

        // Init camera
        string cameraName = WebCamUtil.FindName(new WebCamUtil.PreferSpec()
        {
            isFrontFacing = false,
            kind          = WebCamKind.WideAngle,
        });

        webcamTexture      = new WebCamTexture(cameraName, 1280, 720, 30);
        cameraView.texture = webcamTexture;
        webcamTexture.Play();
        Debug.Log($"Starting camera: {cameraName}");

        draw        = new PrimitiveDraw(Camera.main, gameObject.layer);
        worldJoints = new Vector4[PoseLandmarkDetect.JointCount];

        cancellationToken = this.GetCancellationTokenOnDestroy();
    }