示例#1
0
 internal static extern void showBinaryFeed(HSVRange hsv_range, Thresholds thresholds);
示例#2
0
    void Update()
    {
        if (!_ready)
        {
            return;
        }

        // all DLL calls have to be in an unsafe block
        unsafe {
            //OpenCVInterop.capture();
            // use SPACE key to make mask of current HSV values in the ROIs
            if (!trackingPosition && Input.GetKeyDown(KeyCode.Space))
            {
                hsvRange = OpenCVInterop.getMaskRange();
                Debug.Log(hsvRange.minH);
                Debug.Log(hsvRange.maxH);
                Debug.Log(hsvRange.minS);
                Debug.Log(hsvRange.maxS);
            }
            // draw contour if the mask has been confirmed and get the hand center
            if (trackingPosition)
            {
                if (!drawingMode)
                {
                    OpenCVInterop.drawHandContour(removeBackground, backgroundRemoveOffset);
                    OpenCVInterop.getHandCenter(ref handPos);
                    //Debug.Log(handPos.X);
                    //Debug.Log(handPos.Y);
                    int detectedFingerTipsCount = 0;
                    fixed(Position *allFingerTips = fingerTips)
                    {
                        OpenCVInterop.getFingerTips(allFingerTips, ref detectedFingerTipsCount);
                        //Debug.Log(detectedFingerTipsCount);
                        gestureCache.Add(detectedFingerTipsCount);
                        currentCount = gestureCache.GetCachedGesture();
                        Debug.Log(currentCount);
                    }
                }
                else
                {
                    OpenCVInterop.drawIndex(removeBackground, backgroundRemoveOffset);
                    int detectedFingerTipsCount = 0;
                    fixed(Position *allFingerTips = fingerTips)
                    {
                        OpenCVInterop.getFingerTips(allFingerTips, ref detectedFingerTipsCount);
                        //Debug.Log(detectedFingerTipsCount);
                        gestureCache.Add(detectedFingerTipsCount);
                        currentCount = gestureCache.GetCachedGesture();
                        Debug.Log(currentCount);
                    }

                    OpenCVInterop.getFurthestFingertip(ref furthestFingertip);
                }
            }
            // if mask has not been confirmed show the normal feed with the ROIs
            else
            {
                OpenCVInterop.showOverlayFeed(removeBackground, backgroundRemoveOffset);
            }
            //Debug.Log(handPos.X);
            //Debug.Log(handPos.Y);
            // always show the binary mask preview
            //Debug.Log("Threshold" + thresholds.highThreshold);
            OpenCVInterop.showBinaryFeed(hsvRange, thresholds);

            // press RETURN key to confirm mask
            if (Input.GetKeyDown(KeyCode.Return))
            {
                trackingPosition = true;
            }
        }
    }