Beispiel #1
0
 // Timer acts as our image capture rate. I currently set this to something
 // like 3 seconds because of the high overhead of processing but as we get quicker
 // we'll be able to lower it substantially.
 void FixedUpdate()
 {
     timer += Time.deltaTime;
     if (timer > processRate)
     {
         timer = 0;
         if (imageCapture.setupComplete == false)
         {
             return;
         }
         Color32[] lastFrame = imageCapture.GetColor();
         ProcessImage(lastFrame);
     }
 }
Beispiel #2
0
    // Search every pixel in the lastFrame array and check if it's
    // within out accepted range of target color.
    void ProcessImage()
    {
        Color32[] lastFrame = imageCapture.GetColor();
        // print(lastFrame.Length);
        for (int i = 0; i < lastFrame.Length; i++)
        {
            if (inRange(lastFrame[i], targetColor))
            {
                int loc = GetX(i);
                selector.anchoredPosition = new Vector3(-88, positions[loc], 0);

                float y = GetY(i);
                float clamppedValue;
                float maxStep;
                if (loc == 0)
                {
                    clamppedValue = 510 * y;
                    maxStep       = 10;
                }
                else if (loc == 1)
                {
                    clamppedValue = 8 * y + 2;
                    maxStep       = 0.1f;
                }
                else
                {
                    clamppedValue = 10 * y;
                    maxStep       = 0.3f;
                }
                float sloppedValue = clamppedValue > lightSliders[loc].value ? maxStep : -maxStep;

                print(clamppedValue + " " + lightSliders[loc] + " " + sloppedValue);
                lightSliders[loc].value = lightSliders[loc].value + sloppedValue;
                break;
            }
        }
    }