private void PrepareCamera() { camTexture = new WebCamTexture() { requestedWidth = 1600, requestedHeight = 900, requestedFPS = 40f }; camTexture?.Play(); }
protected virtual void OnEnable() { if (m_webCamTexture == null) { m_startVideoCorutine = StartCoroutine(StartVideo()); return; } OnUpdateWebCamTexture?.Invoke(m_webCamTexture); m_webCamTexture?.Play(); }
// Use this for initialization void Start() { _webTex = new WebCamTexture(); _webTex.Play(); GetComponent <Renderer>().material.mainTexture = _webTex; testQR = Resources.Load("qr20170307141344906") as Texture2D; #if UNITY_UWP barReader = new BarcodeReader(); barReader.AutoRotate = true; barReader.TryInverted = true; barReader.Options.PureBarcode = false; barReader.Options.Hints.Add(DecodeHintType.TRY_HARDER, true); barReader.Options.PossibleFormats = new BarcodeFormat[] { BarcodeFormat.QR_CODE }; #endif // testQRFromResource(); }
private void Start() { foundQr = false; if (decodingSuccessfully == null) { decodingSuccessfully = new UnityEvent(); } thread = new Thread(o => { }); screenRect = new Rect(); camTexture = new WebCamTexture { requestedHeight = Screen.height, requestedWidth = Screen.width }; if (camTexture != null) { camTexture.Play(); } background.texture = camTexture; }
void Start() { once = true; create = false; WebCamDevice[] devices = WebCamTexture.devices; // display all cameras for (var i = 0; i < devices.Length; i++) { Debug.Log(devices[i].name); } webcamTexture = new WebCamTexture(devices[0].name, Width, Height, FPS); material.mainTexture = webcamTexture; webcamTexture.Play(); if (!Directory.Exists("Application.persistentDataPath" + "/photo")) { // フォルダが存在しないなら作成 Directory.CreateDirectory(Application.persistentDataPath + "/photo"); } }
void StartPlaying() { if (!m_cameraTexture) { m_cameraTexture = CreateWebcamTexture(); //m_cameraTexture = WebCamHelper.CreateWebcamTexture(WebCamFacing.Back, this.gameObject); //m_cameraTexture.Play(); } else { m_cameraTexture.Play(); } if (m_cameraTexture) { GetComponent <Renderer>().material.mainTexture = m_cameraTexture; m_startPlaying = false; } }
// Use this for initialization void Start() { // Get available cameras WebCamDevice[] myDevices = WebCamTexture.devices; for (int i = 0; i < myDevices.Length; i++) { Debug.Log(myDevices[i].name); } // create texture for web cam feed myWebcamTexture = new WebCamTexture(); // if cam found use the first available cam if (myDevices.Length > 0) { myWebcamTexture.deviceName = myDevices[0].name; myWebcamTexture.Play(); } }
public void ChangeCamera() /* 追加4 */ { int cameras = webCamDevice.Length; //カメラの個数 if (cameras <= 1) { return; // カメラが1台しかなかったら実行せず終了 } selectCamera++; if (selectCamera >= cameras) { selectCamera = 0; } webCamTexture.Stop(); // カメラを停止 webCamTexture = new WebCamTexture(webCamDevice[selectCamera].name); //カメラを変更 rawImage.texture = webCamTexture; webCamTexture.Play(); // 別カメラを開始 }
public int FPS = 60; //30; void Start() { //var euler = transform.localRotation.eulerAngles; //transform.localRotation = Quaternion.Euler( euler.x, euler.y, euler.z - 90 ); var devices = WebCamTexture.devices; if (devices.Length > 0) { var webcamTexture = new WebCamTexture(Width, Height, FPS); renderer.material.mainTexture = webcamTexture; webcamTexture.Play(); } else { Debug.Log("Webカメラが検出できませんでした"); return; } }
public void StartWebcam(bool front_facing) { if (!initialized_manager) { InitWebcam(front_facing); } else if (webcamTexture == null) { webcamTexture = GetManagedWebCamTexture(front_facing); } if (webcamTexture != null) { webcamTexture.requestedWidth = Constants.CAMERA_REQUESTED_WIDTH; webcamTexture.requestedHeight = Constants.CAMERA_REQUESTED_HEIGHT; webcamTexture.requestedFPS = 60.0f; webcamTexture.Play(); } }
/// <summary> /// Play Web Camera /// </summary> private void CameraPlayStart() { WebCamDevice[] devices = WebCamTexture.devices; webCamTexture = new WebCamTexture(devices[0].name); var sd = VideoScreen.GetComponent <RectTransform>(); VideoScreen.texture = webCamTexture; webCamTexture.Play(); sd.sizeDelta = new Vector2(videoScreenWidth, videoScreenWidth * webCamTexture.height / webCamTexture.width); var aspect = (float)webCamTexture.width / webCamTexture.height; VideoBackground.transform.localScale = new Vector3(aspect, 1, 1) * VideoBackgroundScale; VideoBackground.GetComponent <Renderer>().material.mainTexture = webCamTexture; InitMainTexture(); }
// Use this for initialization void Start() { RawImage rawImage = GetComponent <RawImage>(); WebCamTexture webcamTexture = new WebCamTexture(); //webcamTexture.deviceName = WebCamTexture.devices[0].name; WebCamDevice[] devices = WebCamTexture.devices; Debug.Log("Num Devices: " + devices.Length); for (int i = 0; i < devices.Length; i++) { Debug.Log(devices[i].name); } webcamTexture.deviceName = "Logitech HD Webcam C615"; rawImage.texture = webcamTexture; rawImage.material.mainTexture = webcamTexture; webcamTexture.Play(); }
void Start() { for (int i = 0; i < target.Length; i++) { devices = WebCamTexture.devices; WebCamTexture webcamTexture = new WebCamTexture(); if (devices.Length > 0) { webcamTexture.deviceName = devices[i].name; target[i].material.mainTexture = webcamTexture; webcamTexture.Play(); } } }
public override bool ModLateUpdate(MegaModContext mc) { if (Application.isPlaying) { if (map == null) { map = new WebCamTexture(WebWidth, WebHeight, WebRate); if (map) { map.Play(); } else { Debug.Log("Couldnt create WebCamTexture"); } } } return(Prepare(mc)); }
void Start() { currentState = ProgramState.ManualControl; WebCamTexture webTex = new WebCamTexture(WebCamTexture.devices[1].name); webTex.Play(); texReader = new WebCamTextureReader(webTex); //texReader = new ScreenShotTextureReader(); parser = new ImageParser(); if (!isTraining) { serialPort = new SerialPort("COM4"); serialPort.Open(); } if (isTraining) { threader.messageQueue = new ConcurrentQueue <string>(); ThreadStart start = new ThreadStart(threader.runTuner); Thread t = new Thread(start); t.Start(); } //var hidden = new float[][]{new float[]{-0.06903733f,-0.1204211f,-0.1170338f,0.03330595f,-0.0929533f,0.1004087f,0.0253228f,-0.07049648f,0.1561288f,-0.2057665f},new float[]{-0.1833734f,0.2184264f,0.04389104f,0.03153691f,0.1989222f,-0.004495893f,-0.1988735f,-0.05761508f,-0.03419961f,-0.1252105f},new float[]{-0.1174469f,0.06082164f,0.1511514f,-0.07508145f,0.1869553f,0.2032531f,0.08316454f,-0.07734036f,0.160016f,-0.2196597f},new float[]{-0.04042799f,0.12335f,-0.2520556f,-0.04117061f,0.1304957f,-0.01909676f,0.07300739f,0.05919087f,0.02102444f,-0.09814784f},new float[]{-0.1872339f,-0.1362969f,0.1683453f,-0.01297639f,0.07160946f,0.04766374f,0.1250072f,0.1642009f,0.09859828f,-0.07657336f},new float[]{0.0426106f,0.1403711f,-0.1820064f,-0.06172101f,0.1371788f,0.03265697f,-0.0272984f,-0.09486318f,0.08233191f,-0.02668947f}}; //var output = new float[]{0.1153422f,-0.08480756f,-0.03375334f,0.1751222f,0.1993017f,0.1691856f}; //var hidden = new float[][]{new float[]{0.1062265f,0.07877557f,0.1296688f,0.1801857f,0.155361f,0.08026402f,5.229413E-05f,0.0513033f,-0.04129005f,0.1580591f},new float[]{0.07237879f,-0.08428323f,-0.1284456f,0.1626194f,0.1416797f,0.2010917f,-0.04338667f,0.1170366f,-0.05595298f,0.04115711f},new float[]{-0.0725678f,0.0803528f,-0.1890458f,-0.01033701f,-0.1815529f,0.0845101f,0.04547426f,0.1759871f,0.1553514f,0.05655741f},new float[]{-0.03995487f,0.186867f,-0.1791575f,-0.05288832f,0.009598507f,0.09033263f,0.008156282f,0.09895851f,-0.02606005f,0.0123509f},new float[]{-0.1431304f,0.03786864f,-0.1379245f,-0.1383549f,-0.2064656f,0.05489919f,-0.1603064f,-0.1823927f,0.1994664f,0.0003644727f},new float[]{-0.1313158f,-0.01504898f,-0.07030262f,-0.186277f,0.1034396f,-0.1876001f,0.06108657f,0.1755974f,0.2439985f,-0.1074236f}}; //var output = new float[]{-0.1634287f,0.1086006f,0.07287102f,0.1285644f,0.06330933f,-0.145795f}; //var hidden = new float[][]{new float[]{0.1493298f,0.01999732f,0.1369107f,0.1883943f,-0.1532951f,0.1624803f,0.1441682f,0.08189679f,-0.1258692f,0.1400606f},new float[]{0.1411773f,0.1465782f,-0.1582646f,0.09787317f,-0.1013228f,0.1742776f,-0.09175301f,-0.04335905f,-0.1535288f,-0.1726231f},new float[]{0.1423891f,0.1568068f,-0.1309288f,-0.16624f,-0.179458f,-0.04458414f,-0.07536326f,0.1750511f,0.06456359f,0.1614914f},new float[]{-0.06910742f,0.1849477f,-0.1562149f,-0.02061264f,0.09389784f,0.1115483f,0.1832086f,0.1280793f,0.06631156f,0.007651481f},new float[]{0.1185598f,0.1117894f,-0.1006476f,0.01884162f,0.04223451f,-0.06615675f,-0.03255002f,-0.1742624f,0.06808273f,-0.08383059f},new float[]{0.1309216f,-0.005340355f,0.1106042f,0.07571947f,-0.07535377f,0.204163f,-0.02816167f,-0.1554123f,0.1706816f,-0.04058816f}}; //var output = new float[]{-0.07528235f,0.04620438f,0.04189136f,0.08600978f,0.1298999f,-0.2040185f}; var hidden = new float[][] { new float[] { 0.194341f, 0.1434416f, 0.0713096f, 0.1653562f, 0.1112117f, 0.1232969f, -0.01119053f, 0.03627405f, -0.1254188f, 0.01899251f, -0.05036948f }, new float[] { 0.05425321f, -0.1496129f, 0.0816373f, 0.1543122f, -0.1064251f, 0.1125381f, 0.08268484f, 0.1927576f, 0.2012903f, 0.2134653f, 0.05713469f }, new float[] { 0.03931943f, 0.1033663f, -0.3848397f, -0.07148883f, -0.03369519f, 0.06521149f, 0.01828165f, -0.1288408f, -0.01749198f, -0.07911009f, 0.06041071f }, new float[] { -0.08144363f, 0.101594f, -0.175469f, -0.1271559f, 0.1225737f, -0.08820423f, -0.1741386f, 0.1383524f, 0.07709136f, -0.08639109f, -0.06383685f }, new float[] { -0.04410164f, 0.1367995f, 0.05679908f, 0.1721974f, -0.1239951f, -0.2085233f, 0.02573769f, -0.02817038f, -0.07766398f, -0.1140089f, -0.08351984f }, new float[] { -0.1507141f, 0.008166309f, 0.1841051f, -0.0453295f, 0.03497292f, -0.08636673f, -0.02734959f, -0.1324452f, -0.00981016f, -0.167251f, -0.07732157f } }; var output = new float[] { -0.0354594f, 0.09784601f, 0.1386255f, 0.06091305f, 0.01426123f, -0.05693473f }; ai = new AI(hidden, output); InitGrid(); addNewPiece(0); provider = new ImageProvider(); drawGrid(grid1); }
void Start() { string detectionPath = Path.Combine(Application.streamingAssetsPath, faceModelFile); faceDetect = new FaceDetect(detectionPath); string cameraName = WebCamUtil.FindName(new WebCamUtil.PreferSpec() { isFrontFacing = false, kind = WebCamKind.WideAngle, }); webcamTexture = new WebCamTexture(cameraName, 1280, 720, 30); cameraView.texture = webcamTexture; webcamTexture.Play(); Debug.Log($"Starting camera: {cameraName}"); draw = new PrimitiveDraw(Camera.main, gameObject.layer); }
// .. COROUTINES IEnumerator EnableReaderRoutine() { if (isReaderEnabled) { yield break; } LastResult = string.Empty; prevResult = string.Empty; cameraFeedGrab = null; camTexture.Play(); W = camTexture.width; H = camTexture.height; yield return(new WaitForSeconds(0.5f)); isReaderEnabled = true; }
void Start() { myCam = (texture)plan.GetComponent <texture>(); //GameObject.GetComponent<T>() // Checks how many and which cameras are available on the device if (WebCamTexture.devices.Length > 1) { for (int cameraIndex = 0; cameraIndex < WebCamTexture.devices.Length; cameraIndex++) { // We want the back camera if (WebCamTexture.devices[cameraIndex].name != "Integrated Camera") { //webCameraTexture = new WebCamTexture(cameraIndex, Screen.width, Screen.height); webCameraTexture = new WebCamTexture(WebCamTexture.devices[cameraIndex].name, 1000, 1000); // Here we flip the GuiTexture by applying a localScale transformation // works only in Landscape mode //myCameraTexture.transform.localScale = new Vector3(1,1,1); } } } else { webCameraTexture = new WebCamTexture(WebCamTexture.devices[0].name, 1000, 1000, 60); } myCam.textures = webCameraTexture; myCam.textures = webCameraTexture; //print(webCameraTexture.height); //print(webCameraTexture.width); // Starts the camera webCameraTexture.Play(); }
void Start() { if (!AffdexUnityUtils.ValidPlatform()) { return; } detector = GetComponent <Detector>(); devices = WebCamTexture.devices; if (devices.Length > 0) { SelectCamera(isFrontFacing); if (device.name != "Null") { cameraTexture = new WebCamTexture(device.name, targetWidth, targetHeight, (int)sampleRate); cameraTexture.Play(); } } }
// ------------------------------------------------------------------------------- void OnApplicationFocus(bool status) { // track when losing/recovering focus bool handle_focus_loss = false; if (handle_focus_loss) { #if (UNITY_STANDALONE || UNITY_EDITOR) if (m_webcamTexture != null && status == false) { m_webcamTexture.Stop(); // you can pause as well } else if (m_webcamTexture != null && status == true) { m_webcamTexture.Play(); } #endif } }
IEnumerator Start() { cameraMat = plane.GetComponent <MeshRenderer>().material; decoder = GetComponent <WebCamDecoder>(); var devices = WebCamTexture.devices; var deviceName = devices[0].name; cameraTexture = new WebCamTexture(deviceName, (int)(Screen.width * 0.5f), (int)(Screen.height * 0.5f)); cameraTexture.Play(); yield return(StartCoroutine(decoder.StartDecoding(cameraTexture))); cameraMat.mainTexture = cameraTexture; // adjust texture orientation; plane.transform.rotation = plane.transform.rotation * Quaternion.AngleAxis(cameraTexture.videoRotationAngle, Vector3.up); }
// Use this for initialization void Start() { GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); Debug.Log("Connected"); if (backCam == null) { backCam = new WebCamTexture(230, 200); } GetComponent <Renderer>().material.mainTexture = backCam; if (!backCam.isPlaying) { backCam.Play(); } StartCoroutine("UpdateSocketData"); }
// Use this for initialization void Start() { //An integer that stores the number of connected webcams int numOfCams = WebCamTexture.devices.Length; //Initialize the nameWebCams array to hold the same number of strings as there are webcams this.nameWebCams = new string[numOfCams]; //Get the name of each connected camera and store it into the 'nameWebCams' array for (int i = 0; i < numOfCams; i++) { this.nameWebCams[i] = WebCamTexture.devices[i].name; } rd = GetComponent <Renderer>(); webCamTexture = new WebCamTexture(); rd.material.mainTexture = webCamTexture; webCamTexture.Play(); }
void Start() { // Debug print print(selectedCam); print(WebCamTexture.devices[selectedCam].name); // Initialize the webCamTexture and apply the webcam stream on the object webCamTexture = new WebCamTexture(); renderer.material.mainTexture = webCamTexture; webCamTexture.deviceName = WebCamTexture.devices[selectedCam].name; // Start streaming the images captured by the webcam into the texture webCamTexture.Play(); // Initialisation of the bridge components ALVARBridge.alvar_init(webCamTexture.width, webCamTexture.height); data = new Color32[webCamTexture.width * webCamTexture.height]; imageData = new int[data.Length * 3]; }
private IEnumerator StartCamera() { yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam)); if (Application.HasUserAuthorization(UserAuthorization.WebCam)) { WebCamDevice[] devices = WebCamTexture.devices; string deviceName = ""; if (devices.Length > 0) { deviceName = devices[0].name; } webTexture = new WebCamTexture(deviceName); rawImage.texture = webTexture; webTexture.Play(); } }
public virtual void Awake() { WebCamDevice[] devices = WebCamTexture.devices; Debug.Log("Devices: " + devices.Length + "\n"); if (devices != null && devices.Length > 0) { // print available webcams StringBuilder sbWebcams = new StringBuilder(); sbWebcams.Append("Available webcams:").AppendLine(); foreach (WebCamDevice device in devices) { sbWebcams.Append(device.name).AppendLine(); } Debug.Log(sbWebcams.ToString()); // get 1st webcam name, if not set if (string.IsNullOrEmpty(webcamName)) { webcamName = devices[0].name; } // create webcam tex webcamTex = new WebCamTexture(webcamName); OnApplyTexture(webcamTex); bTexResolutionSet = false; } if (flipHorizontally) { Vector3 scale = transform.localScale; transform.localScale = new Vector3(-scale.x, scale.y, scale.z); } if (HasCamera()) { webcamTex.Play(); } }
private void Start() { client = new NetworkClient(); ControllerData.InitClient(); barcodeReader = new BarcodeReader(); delay = 0; screenRect = new Rect(0, 0, Screen.width, Screen.height); camTexture = new WebCamTexture(GetCamera().name) { requestedFPS = 30, requestedWidth = Screen.width, requestedHeight = Screen.height }; if (camTexture != null) { camTexture.Play(); } }
// Use this for initialization void Start() { if (Application.isMobilePlatform) { GameObject cameraParent = new GameObject("camParent"); cameraParent.transform.position = this.transform.position; this.transform.parent = cameraParent.transform; cameraParent.transform.Rotate(Vector3.right, 90); } Input.gyro.enabled = true; WebCamTexture webCameraTexture = new WebCamTexture(); webCameraPlane.GetComponent <MeshRenderer>().material.mainTexture = webCameraTexture; webCameraTexture.Play(); }
IEnumerator Start() { yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam)); if (Application.HasUserAuthorization(UserAuthorization.WebCam) == false) { Debug.LogFormat("no camera."); yield break; } Debug.LogFormat("camera ok."); WebCamDevice[] devices = WebCamTexture.devices; if (devices == null || devices.Length == 0) { yield break; } webCam = new WebCamTexture(devices[0].name, Screen.width, Screen.height, 30); rawImage.texture = webCam; webCam.Play(); }
IEnumerator Start() { rawImage = GetComponent <RawImage>(); aspectFitter = GetComponent <AspectRatioFitter>(); // Request microphone and camera yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone)); if (!Application.HasUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone)) { yield break; } // Start the WebCamTexture string cameraName = null; foreach (var camera in WebCamTexture.devices) { if (useFrontCamera && camera.isFrontFacing) { cameraName = camera.name; break; } } cameraTexture = new WebCamTexture(cameraName, 1280, 720); cameraTexture.Play(); yield return(new WaitUntil(() => cameraTexture.width != 16 && cameraTexture.height != 16)); // Workaround for weird bug on macOS // Borrow the GreyWorld shader because it supports rotation and mirroring rawImage.texture = cameraTexture; rawImage.material = new Material(Shader.Find("Hidden/NatCorder/GreyWorld")); // Orient the preview panel rawImage.material.SetFloat("_Rotation", cameraTexture.videoRotationAngle * Mathf.PI / 180f); rawImage.material.SetFloat("_Scale", cameraTexture.videoVerticallyMirrored ? -1 : 1); // Scale the preview panel aspectFitter.aspectMode = AspectRatioFitter.AspectMode.HeightControlsWidth; if (cameraTexture.videoRotationAngle == 90 || cameraTexture.videoRotationAngle == 270) { aspectFitter.aspectRatio = (float)cameraTexture.height / cameraTexture.width; } else { aspectFitter.aspectRatio = (float)cameraTexture.width / cameraTexture.height; } }
void PlayCamera(WebCamTexture texture) { renderer.material.mainTexture = texture; texture.Play(); }