void OnApplicationQuit() { if (_ready) { OpenCVHand.Close(); } }
void Update() { if (!_ready) { return; } if (!_initialize) { bool init = false; OpenCVHand.SetFilters(ref init); _initialize = init; } else { int X = 0, Y = 0; OpenCVHand.Detect(ref X, ref Y, ref fingerNum); counts++; calculatedHandPosition = new Vector2(X, Y); if (counts > 200) { calculatedFingerNumber = fingerNum; Debug.Log("finger : " + calculatedFingerNumber); } //Debug.Log("X : " + X); //Debug.Log("Y : " + Y); } }
void Start() { int camWidth = 0, camHeight = 0; int result = OpenCVHand.Init(ref camWidth, ref camHeight); fingerNum = 0; counts = 0; calculatedFingerNumber = 0; if (result == -1) { Debug.LogWarningFormat("[{0}] Failed to open camera stream.", GetType()); return; } CameraResolution = new Vector2(camWidth, camHeight); OpenCVHand.SetScale(DetectionDownScale); _ready = true; }