/// <summary> /// Sort of like a constuctor, works like a 'main'. /// </summary> private void Start() { onChanged = false; cameraTexture = new CameraTexture(xResolution, yResolution); colorSpace.SetScale(cameraTexture.GetScale()); }
protected CameraTexture[] cameraTextureArray = new CameraTexture[2]; // 0: src image, 1: binarized image // Use this for initialization void Awake() { /* 設定ファイル読み込み */ try { print("Start loading OmniProCam config parameters..."); using (StreamReader streamReader = new StreamReader(settingFilePath)) { while (streamReader.EndOfStream == false) { sdkType = int.Parse(streamReader.ReadLine()); maxObjects = int.Parse(streamReader.ReadLine()); roi.x = float.Parse(streamReader.ReadLine()); roi.y = float.Parse(streamReader.ReadLine()); roi.width = float.Parse(streamReader.ReadLine()); roi.height = float.Parse(streamReader.ReadLine()); maxSizeThreshold = int.Parse(streamReader.ReadLine()); minSizeThreshold = int.Parse(streamReader.ReadLine()); print("Parameters have been loaded from " + settingFilePath); print(" SDK Type: " + sdkType + " MaxObjects: " + maxObjects + ", ROI.x: " + roi.x + ", ROI.y: " + roi.y + ", ROI.width: " + roi.width + ", ROI.height: " + roi.height + ", MaxSizeThreshold: " + maxSizeThreshold + ", MinSizeThreshold: " + minSizeThreshold); } // while /* 初期化 */ print("Start initializing OmniProCam devices..."); LibOmniProCam.setCameraSDKType(sdkType); int returnedValue = LibOmniProCam.initialize((int)roi.x, (int)roi.y, (int)roi.width, (int)roi.height, maxSizeThreshold, minSizeThreshold, maxObjects); if (returnedValue == 0) { print("LibOmniProCam has been initialized!"); isInitialized = true; } else { print("Failed to initialize LibOmniProCam: " + returnedValue.ToString()); isInitialized = false; Destroy(gameObject); } } /* 結果データ初期化 */ resultOmniProCamData = new OmniProCamData[maxObjects]; /* カメラ画像配列の初期化 */ cameraTextureArray[0] = new CameraTexture((int)roi.width, (int)roi.height); // src cameraTextureArray[1] = new CameraTexture((int)roi.width, (int)roi.height); // src LibOmniProCam.setShutterSpeed((int)shutterSpeedUSec); LibOmniProCam.setGain(gain); LibOmniProCam.setBinarizingThreshold(50.0f); } catch (Exception e) { print("OmniProCam config file(" + settingFilePath + ") could not be loaded(" + e.ToString() + ")"); Destroy(gameObject); } } // Awake
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } cameraImage = GetComponent <RawImage>(); }
void Awake() { timeWaited = timeToWait; vision = GetComponent<CreatureSight>(); cam = visionCamera.GetComponent<CameraTexture>(); lastPosMarker = new GameObject(name+" Last Known Position Marker"); aiPath = GetComponent<AIPath>(); anim = GetComponent<Animator>(); anim.SetBool("Enraged", false); anim.SetBool("Run", false); anim.SetBool("Walk", false); anim.SetBool("Attack", false); anim.SetBool("Search", false); anim.SetBool("Absorb", false); GetNearestWaypoint(); }
void Update() { // image(img, 0, 0); //Displays images to the screen // loadPixels(); // Loads the pixel data for the display window into the pixels[] array // texture = pixels; sourceimage = CameraTexture.GetTexture2D(); //texture = new Color[width * height]; int counter = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { texture[counter] = sourceimage.GetPixel(x, y); counter++; } } Newframe(); int px = 0; int py = 0; for (int i = 0; i < pixels.Length; i++) { // todo: use Texture2D.SetPixels instead.. targettexture.SetPixel(px, py, ripple[i]); px++; if (px >= width) { px = 0; py++; } } //updatePixels(); //Updates the display window with the data in the pixels[] array targettexture.Apply(); // left mouse button is pressed down if (Input.GetMouseButton(0)) { // raycast to mousecursor location /* * RaycastHit hit; * if (!Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, raycastDistance, raycastMask.value)) * return; */ // get real coordinates //Vector2 pixelUV = hit.textureCoord; Vector3 pixelUV = Camera.main.WorldToViewportPoint(Input.mousePosition) * 10; pixelUV.x -= 5; pixelUV.y -= 5; // then apply waves on that position Disturb((int)pixelUV.x, (int)pixelUV.y); } }