Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        balloonygenManagerPtr = GameObject.Find("LibOmniProCamManager").GetComponent <OmniProCamDeviceManager>();
        if (balloonygenManagerPtr == null)
        {
            Destroy(gameObject);
        }

        debugText1 = transform.Find("DebugText1").GetComponent <Text>();
        debugText2 = transform.Find("DebugText2").GetComponent <Text>();
        debugText3 = transform.Find("DebugText3").GetComponent <Text>();

        omniProCamDataArrayPtr = balloonygenManagerPtr.getOmniProCamDataArrayPtr();

        imagePtr = GameObject.Find("CameraImage").GetComponent <Image>();
    }
	// Update is called once per frame
	void Update () {
    
    /* スケールの微調整 */
    if (!Input.GetKey(KeyCode.O)) {

      /* 縦スケールの微調整 */
      if (Input.GetKey(KeyCode.E)) {
        scale.y += 0.1f * Time.deltaTime;
        transform.localScale = scale;
      } else if (Input.GetKey(KeyCode.D)) {
        scale.y -= 0.1f * Time.deltaTime;
        transform.localScale = scale;
      }
      /* 縦スケールの微調整 */
      if (Input.GetKey(KeyCode.F)) {
        scale.x += 0.1f * Time.deltaTime;
        transform.localScale = scale;
      } else if (Input.GetKey(KeyCode.A)) {
        scale.x -= 0.1f * Time.deltaTime;
        transform.localScale = scale;
      }

    /* オフセットの設定 */
    }else {

      /* 縦オフセットの微調整 */
      if (Input.GetKey(KeyCode.E)) {
        offset.y += 0.05f * Time.deltaTime;
        transform.position = new Vector3(offset.x, 0.0f, offset.y);
      } else if (Input.GetKey(KeyCode.D)) {
        offset.y -= 0.05f * Time.deltaTime;
        transform.position = new Vector3(offset.x, 0.0f, offset.y);
      }
      

      /* 横オフセットの微調整 */
      if (Input.GetKey(KeyCode.F)) {
        offset.x += 0.05f * Time.deltaTime;
        transform.position = new Vector3(offset.x, 0.0f, offset.y);
      } else if (Input.GetKey(KeyCode.A)) {
        offset.x -= 0.05f * Time.deltaTime;
        transform.position = new Vector3(offset.x, 0.0f, offset.y);
      }
    }

    /* 縦オフセットの微調整 */
    if (Input.GetKey(KeyCode.E)) {
      offset.y += 0.05f * Time.deltaTime;
      transform.position = new Vector3(offset.x, 0.0f, offset.y);
    }

    /* 2値化閾値 */
    if (Input.GetKey(KeyCode.UpArrow)) {
      binarizingThreshold += 1.0f;
      if (binarizingThreshold >= 255.0f) {
        binarizingThreshold = 255;
      }
      LibOmniProCam.setBinarizingThreshold(binarizingThreshold);
      print("BinarizingThreshold: " + binarizingThreshold);
    } else if (Input.GetKey(KeyCode.DownArrow)) {
      binarizingThreshold -= 1.0f;
      if (binarizingThreshold <= 0.0f) {
        binarizingThreshold = 0;
      }
      LibOmniProCam.setBinarizingThreshold(binarizingThreshold);
      print("BinarizingThreshold: " + binarizingThreshold);
    }

    ///* 高さ */
    //if (Input.GetKey(KeyCode.PageUp)) {
    //  transform.Translate(0.0f, 0.1f * Time.deltaTime, 0.0f);
    //} else if (Input.GetKey(KeyCode.PageDown)) {
    //  transform.Translate(0.0f, -0.1f * Time.deltaTime, 0.0f);
    //}

    /* 書き出し */
    if (Input.GetKeyDown(KeyCode.Alpha0)) {
      if (omniProCamDeviceManagerPtr.getCameraTextureType() == CameraTextureType.CAMERA_TEXTURE_TYPE_BINARIZED) {
        omniProCamDeviceManagerPtr.setCameraTextureType(CameraTextureType.CAMERA_TEXTURE_TYPE_SRC);
        print("CameraTextureType: Src");
      } else {
        omniProCamDeviceManagerPtr.setCameraTextureType(CameraTextureType.CAMERA_TEXTURE_TYPE_BINARIZED);
        print("CameraTextureType: Binarized");
      }
    }

    OmniProCamData[] ptr = omniProCamDeviceManagerPtr.getOmniProCamDataArrayPtr();
    foreach (OmniProCamData i in ptr) {
      if (i.id != 0) {
      }
    }

    if (omniProCamDeviceManagerPtr.getCameraTextureType() == CameraTextureType.CAMERA_TEXTURE_TYPE_BINARIZED) {
      meshRenderer.material.SetTexture("_MainTex", omniProCamDeviceManagerPtr.getBinarizedCameraImageTexturePtr().texture);
    } else {
      meshRenderer.material.SetTexture("_MainTex", omniProCamDeviceManagerPtr.getSrcCameraImageTexturePtr().texture);
    }
  }