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.GetComponent <Renderer>().material.mainTexture = w;
        this._ms.setARBackgroundTransform(this._bg_panel.transform);

        //setup camera projection
        this._ms.setARCameraProjection(this.GetComponent <Camera>());
        return;
    }
Exemple #2
0
    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(
                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);
        }
        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);
    }
    // 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.");
        }
    }
Exemple #5
0
    void Awake()
    {
        //setup unity webcam
        WebCamDevice[] devices = WebCamTexture.devices;
        if (devices.Length <= 0)
        {
            UnityEngine.Debug.LogError("No Webcam.");
            return;
        }
        WebCamTexture w = new WebCamTexture(640, 480, 30);

        //Make WebcamTexture wrapped Sensor.
        this._ss = NyARUnityWebCam.createInstance(w);
        //Make configulation by Sensor size.
        NyARNftSystemConfig config = new NyARNftSystemConfig(
            new MemoryStream(((TextAsset)Resources.Load("camera_para5", typeof(TextAsset))).bytes),
            this._ss.width, this._ss.height);

        this._ns = new NyARUnityNftSystem(config);
        //This line loads a marker from texture
        mid = this._ns.addNftTarget(new MemoryStream(((TextAsset)Resources.Load("infinitycat", typeof(TextAsset))).bytes), 160);

        //setup background
        this._bg_panel = GameObject.Find("Plane");
        this._bg_panel.GetComponent <Renderer>().material.mainTexture = w;
        this._ns.setARBackgroundTransform(this._bg_panel.transform);

        //setup camera projection
        this._ns.setARCameraProjection(this.GetComponent <Camera>());
        return;
    }
Exemple #6
0
    void Start()
    {
        var devices = WebCamTexture.devices;

        if (devices.Length > 0)
        {
            //取得できたカメラデバイスをリスト
            Debug.Log(
                devices.Length + " camera devices were found.\n" +
                string.Join("\n", devices.Select(d => " - " + d.name).ToArray()));
        }
        else
        {
            Debug.LogError("no camera device was found.");
            Debug.Break();
        }

        //カメラを取得、無効な組み合わせの場合は最初のカメラが取得される
        //var webcam = new WebCamTexture(CameraName, CameraWidth, CameraHeight, CameraFps);
        var webcam = new WebCamTexture(640, 480, 30);

        Debug.Log(
            webcam.deviceName + " was selected.\n" +
            webcam.requestedWidth + "x" + webcam.requestedHeight + "x" + webcam.requestedFPS + " is reqested.");

        //NyARの初期化
        _nyarWebCam   = new NyARUnityWebCam(webcam);
        _markerSystem = new NyARUnityMarkerSystem(new NyARMarkerSystemConfig(webcam.requestedWidth, webcam.requestedHeight));

        //NyIDマーカーの登録
        foreach (var k in _nyIdPosRotMap.Keys)
        {
            _nyIdMap.Add(_markerSystem.addNyIdMarker(k, MarkerSize), k);
        }

        //カメラ画像取得開始
        _nyarWebCam.start();

        //[Debug]
        //var bg = GameObject.Find("Plane");
        //bg.renderer.material.mainTexture = webcam;
        //_markerSystem.setARBackgroundTransform(bg.transform);
        //_markerSystem.setARCameraProjection(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();
    }
Exemple #8
0
    void Awake()
    {
        WebCamDevice[] devices = WebCamTexture.devices;
        if (devices.Length <= 0)
        {
            Debug.LogError("No Webcam.");
            return;
        }

        WebCamTexture w = new WebCamTexture(320, 240, 15);

        _ss = NyARUnityWebCam.createInstance(w);
        NyARMarkerSystemConfig config = new NyARMarkerSystemConfig(_ss.width, _ss.height);

        _ms = new NyARUnityMarkerSystem(config);
        mid = _ms.addARMarker(
            new MemoryStream(((TextAsset)Resources.Load("patt_hiro", typeof(TextAsset))).bytes),
            16, 25, 80);
        _bg_panel = GameObject.Find("Plane");
        _bg_panel.GetComponent <Renderer>().material.mainTexture = w;
        _ms.setARBackgroundTransform(_bg_panel.transform);
        _ms.setARCameraProjection(GetComponent <Camera>());
    }
    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;
            }
        }
    }
Exemple #10
0
    void Awake()
    {
        //setup unity webcam
        WebCamDevice[] devices = WebCamTexture.devices;

        if (devices.Length <= 0)
        {
            Debug.LogError("No Webcam.");
            return;
        }
        WebCamTexture w = new WebCamTexture(1920, 1080, 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);
        mid1     = this._ms.addARMarker(
            new MemoryStream(((TextAsset)Resources.Load("patt_hiro", typeof(TextAsset))).bytes),
            16, 25, 80);
        mid2 = this._ms.addARMarker(
            new MemoryStream(((TextAsset)Resources.Load("patt_kanji", typeof(TextAsset))).bytes),
            16, 25, 80);
        for (int i = 0; i < 256; i++)
        {
            mid [i] = this._ms.addNyIdMarker(i + 1, 40);
        }
        //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>());
        return;
    }
Exemple #11
0
    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();
    }
 void Awake()
 {
     this._ss = null;
 }