void Awake() { //setup unity webcam WebCamDevice[] devices= WebCamTexture.devices; if (devices.Length<=0){ Debug.LogError("No Webcam."); return; } WebCamTexture w=new WebCamTexture(320,240,15); //Make WebcamTexture wrapped Sensor. this._ss=NyARUnityWebCam.createInstance(w); //Make configulation by Sensor size. NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(this._ss.width,this._ss.height); this._ms=new NyARUnityMarkerSystem(config); //mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80); //This line loads a marker from texture mid=this._ms.addARMarker((Texture2D)(Resources.Load("MarkerHiro", typeof(Texture2D))),16,25,80); //setup background this._bg_panel=GameObject.Find("Plane"); this._bg_panel.renderer.material.mainTexture=w; this._ms.setARBackgroundTransform(this._bg_panel.transform); //setup camera projection this._ms.setARCameraProjection(this.camera); return; }
// Use this for initialization void Awake() { //setup unity webcam WebCamDevice[] devices= WebCamTexture.devices; WebCamTexture w; if (devices.Length > 0){ w=new WebCamTexture(320, 240, 15); this._ss=new NyARUnityWebCam(w); NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(w.requestedWidth,w.requestedHeight); this._ms=new NyARUnityMarkerSystem(config); //mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80); //This line loads a marker from texture midHiro=this._ms.addARMarker((Texture2D)(Resources.Load("MarkerHiro", typeof(Texture2D))),16,25,80); midKanji=this._ms.addARMarker((Texture2D)(Resources.Load("MarkerKanji", typeof(Texture2D))),16,25,80); //setup background this._bg_panel=GameObject.Find("Plane"); this._bg_panel.renderer.material.mainTexture=w; this._ms.setARBackgroundTransform(this._bg_panel.transform); //setup camera projection this._ms.setARCameraProjection(this.camera); }else{ Debug.LogError("No Webcam."); } }
void Awake() { //setup unity webcam WebCamDevice[] devices= WebCamTexture.devices; if (devices.Length <= 0){ Debug.LogError("No Webcam."); return; } WebCamTexture w=new WebCamTexture(320,240,15); //Make WebcamTexture wrapped Sensor. this._ss=NyARUnityWebCam.createInstance(w); //Make configulation by Sensor size. NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(this._ss.width,this._ss.height); this._ms=new NyARUnityMarkerSystem(config); mid=this._ms.addARMarker( new StreamReader(new MemoryStream(((TextAsset)Resources.Load("patt_hiro",typeof(TextAsset))).bytes)), 16,25,80); //setup background this._bg_panel=GameObject.Find("Plane"); this._bg_panel.renderer.material.mainTexture=w; this._ms.setARBackgroundTransform(this._bg_panel.transform); //setup camera projection this._ms.setARCameraProjection(this.camera); GameObject.Find("Cube").renderer.material.mainTexture=new Texture2D(64,64); }
void Awake() { // Check PS Eye number try { int psEyeCount = PSEyeTexture.CLEyeGetCameraCount(); switch (psEyeCount) { case 0: Debug.LogError("No PS Eye found"); return; case 1: Debug.LogError("Only one PS Eye found"); return; } } catch (Exception e) { Debug.LogError("Oops..., Failed at loading CLEyeMulticam.dll. Please relaunch Unity!"); Debug.LogError(e.ToString()); return; } // Make PS Eye texture var PsEyeTexture = new PSEyeTexture(PsEyeId, FrameRate, true); psEye_ = new NyARUnityPSEye(PsEyeTexture); // Marker system var config = new NyARMarkerSystemConfig(PsEyeTexture.Width, PsEyeTexture.Height); markerSystem_ = new NyARUnityMarkerSystem(config); // Load marker from texture var markerTexture = (Texture2D)(Resources.Load(MarkerName, typeof(Texture2D))); markerId_ = markerSystem_.addARMarker(markerTexture, 16, 25, 80); // Marker layer MarkerObject.layer = Layer; for (int i = 0; i < MarkerObject.transform.GetChildCount(); ++i) { MarkerObject.transform.GetChild(i).gameObject.layer = Layer; } // Set camera background Background.renderer.material.mainTexture = PsEyeTexture.Texture; Background.layer = Layer; ARCamera.cullingMask &= ~(1 << HiddenLayer); markerSystem_.setARBackgroundTransform(Background.transform); markerSystem_.setARCameraProjection(ARCamera); }
void Awake() { //setup texture Texture2D tex= (Texture2D)Resources.Load("320x240ABGR", typeof(Texture2D)); this._ss=new NyARUnitySensor(tex.width,tex.height); this._ss.update(tex); NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(tex.width,tex.height); this._ms=new NyARUnityMarkerSystem(config); this._ms.setConfidenceThreshold(0.1); mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80); //setup background this._bg_panel=GameObject.Find("Plane"); this._bg_panel.renderer.material.mainTexture=tex; this._ms.setARBackgroundTransform(this._bg_panel.transform); //setup camera projection this._ms.setARCameraProjection(this.camera); }
IEnumerator Start () { yield return Application.RequestUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone); if(Application.HasUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone)){ Debug.Log("Authorized"); }else{ Debug.Log("not Authorized"); } //setup unity webcam WebCamDevice[] devices= WebCamTexture.devices; if (devices.Length <=0){ Debug.LogError("No Webcam."); yield break; } WebCamTexture w=new WebCamTexture(320,240,15); //Make WebcamTexture wrapped Sensor. this._ss=NyARUnityWebCam.createInstance(w); //Make configulation by Sensor size. NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(this._ss.width,this._ss.height); this._ms=new NyARUnityMarkerSystem(config); //mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80); //This line loads a marker from texture mid=this._ms.addARMarker((Texture2D)(Resources.Load("MarkerHiro", typeof(Texture2D))),16,25,80); //setup background this._bg_panel=GameObject.Find("Plane"); this._bg_panel.renderer.material.mainTexture=w; this._ms.setARBackgroundTransform(this._bg_panel.transform); //setup camera projection this._ms.setARCameraProjection(this.camera); //start sensor this._ss.start(); }
void Window (int id) { GUI.Box (new Rect (0, 0, Screen.width - 20, Screen.height - 20), ""); GUILayout.Label ("Select webcam to start recording"); WebCamDevice[] devices = WebCamTexture.devices; for (int i=0; i< devices.Length; i++) { if (GUILayout.Button (devices [i].name)) { WebCamTexture w = new WebCamTexture (devices [i].name, 320, 240, 15); //Make WebcamTexture wrapped Sensor. this._ss = NyARUnityWebCam.createInstance (w); //Make configulation by Sensor size. NyARMarkerSystemConfig config = new NyARMarkerSystemConfig (this._ss.width, this._ss.height); this._ms = new NyARUnityMarkerSystem (config); //mid=this._ms.addARMarker("./Assets/Data/patt.hiro",16,25,80); //This line loads a marker from texture mid = this._ms.addARMarker ((Texture2D)(Resources.Load ("MarkerHiro", typeof(Texture2D))), 16, 25, 80); //setup background this._bg_panel = GameObject.Find ("Plane"); this._bg_panel.GetComponent<Renderer> ().material.mainTexture = w; this._ms.setARBackgroundTransform (this._bg_panel.transform); //setup camera projection this._ms.setARCameraProjection (this.GetComponent<Camera> ()); //start sensor this._ss.start (); // Begin recording on the screen webSelected = true; show = false; return; } } }
void Awake() { if (WebCamTexture.devices.Length <= 0) { return; } var wcTexture = new WebCamTexture(320, 240, 15); _device = NyARUnityWebCam.CreateInstance(wcTexture); _panel.material.mainTexture = wcTexture; var config = new NyARMarkerSystemConfig(_device.width, _device.height); _arSystem = new NyARUnityMarkerSystem(config); _arSystem.setARBackgroundTransform(_panel.transform); _arSystem.setARCameraProjection(_camera); foreach (var model in GetModels()) { model.MarkerSetup(this); } _device.Start(); }