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;
    }
Beispiel #2
0
        public MainWindow()
        {
            InitializeComponent();

            CaptureDeviceList oCaptureDeviceList = new CaptureDeviceList();

            MyCaptureDevice = oCaptureDeviceList[0];
            MyCaptureDevice.SetCaptureListener(this);
            MyCaptureDevice.PrepareCapture(800, 600, 30.0f);

            INyARMarkerSystemConfig oMarkerSystemConfig = new NyARMarkerSystemConfig(800, 600);

            this.ARMarkerSystem = new NyARD3dMarkerSystem(oMarkerSystemConfig);
            this.ARMarkerSystem.ThresholdValue = Threshold;
            this.ARCameraSensor = new NyARDirectShowCamera(MyCaptureDevice);

            //public int addARMarker(INyARRgbRaster i_raster, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size)
            this.MarkerID_Hiro  = this.ARMarkerSystem.addARMarker(AR_CODE_FILE1, 16, 25, 80);
            this.MarkerID_KanJi = this.ARMarkerSystem.addARMarker(AR_CODE_FILE2, 16, 25, 80);
            this.MarkerID_VTT   = this.ARMarkerSystem.addARMarker(AR_CODE_FILE3, 16, 25, 80);
            this.MarkerID_ABB   = this.ARMarkerSystem.addARMarker(AR_CODE_FILE4, 16, 25, 80);
            this.Marker_Hello   = this.ARMarkerSystem.addARMarker(AR_CODE_FILE5, 16, 25, 80);

            this.Loaded += MainWindow_Loaded;

            this.BtnPauseZm.Click += BtnPauseZm_Click;
            this.BtnStartZm.Click += BtnStartZm_Click;
            this.BtnClearZm.Click += BtnClearZm_Click;
        }
Beispiel #3
0
        public override void setup(CaptureDevice i_cap)
        {
            Device d3d = this.size(SCREEN_WIDTH, SCREEN_HEIGHT);

            i_cap.PrepareCapture(SCREEN_WIDTH, SCREEN_HEIGHT, 30.0f);
            INyARMarkerSystemConfig cf = new NyARMarkerSystemConfig(SCREEN_WIDTH, SCREEN_HEIGHT);

            d3d.RenderState.ZBufferEnable = true;
            d3d.RenderState.Lighting      = false;
            d3d.RenderState.CullMode      = Cull.CounterClockwise;
            this._ms = new NyARD3dMarkerSystem(cf);
            //recommended be NyARBufferType.BYTE1D_B8G8R8X8_32 or NyARBufferType.CS_BITMAP
            this._ss = new NyARDirectShowCamera(i_cap, NyARBufferType.OBJECT_CS_Bitmap);
            this._rs = new NyARD3dRender(d3d, this._ms);
            this.mid = this._ms.addARMarker(AR_CODE_FILE, 16, 25, 80);

            //set View mmatrix
            this._rs.loadARViewMatrix(d3d);
            //set Viewport matrix
            this._rs.loadARViewPort(d3d);
            //setD3dProjectionMatrix
            this._rs.loadARProjectionMatrix(d3d);
            this._ss.start();
            //should be NyARBufferType.BYTE1D_B8G8R8X8_32 or NyARBufferType.CS_BITMAP
            this._raster = new NyARBitmapRaster(64, 64, NyARBufferType.OBJECT_CS_Bitmap);
        }
Beispiel #4
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.");
        }
    }
Beispiel #5
0
        public CameraPnl1()
        {
            InitializeComponent();

            this.CameraWidth  = this.Width;
            this.CameraHeight = this.Height;

            CaptureDeviceList oCaptureDeviceList = new CaptureDeviceList();

            MyCaptureDevice = oCaptureDeviceList[0];
            MyCaptureDevice.SetCaptureListener(this);
            MyCaptureDevice.PrepareCapture((int)this.CameraWidth, (int)this.CameraHeight, 30.0f);

            INyARMarkerSystemConfig oMarkerSystemConfig = new NyARMarkerSystemConfig((int)this.CameraWidth, (int)this.CameraHeight);

            this.ARMarkerSystem = new NyARD3dMarkerSystem(oMarkerSystemConfig);
            this.ARCameraSensor = new NyARDirectShowCamera(MyCaptureDevice);

            this.MarkerID_Hiro  = this.ARMarkerSystem.addARMarker(AR_CODE_FILE1, 16, 25, 80);
            this.MarkerID_KanJi = this.ARMarkerSystem.addARMarker(AR_CODE_FILE2, 16, 25, 80);
            this.MarkerID_VTT   = this.ARMarkerSystem.addARMarker(AR_CODE_FILE3, 16, 25, 80);
            this.MarkerID_ABB   = this.ARMarkerSystem.addARMarker(AR_CODE_FILE4, 16, 25, 80);
            this.Marker_Hello   = this.ARMarkerSystem.addARMarker(AR_CODE_FILE5, 16, 25, 80);

            this.Loaded += CameraPnl1_Loaded;
        }
    // 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.");
        }
    }
Beispiel #7
0
        public override void setup(CaptureDevice i_cap)
        {
            Device d3d = this.size(SCREEN_WIDTH, SCREEN_HEIGHT);

            i_cap.PrepareCapture(SCREEN_WIDTH, SCREEN_HEIGHT, 30.0f);
            INyARMarkerSystemConfig cf = new NyARMarkerSystemConfig(SCREEN_WIDTH, SCREEN_HEIGHT);

            d3d.RenderState.ZBufferEnable = true;
            d3d.RenderState.Lighting      = false;
            d3d.RenderState.CullMode      = Cull.CounterClockwise;
            this._ms = new NyARD3dMarkerSystem(cf);
            this._ss = new NyARDirectShowCamera(i_cap);
            this._rs = new NyARD3dRender(d3d, this._ms);
            this.mid = this._ms.addARMarker(AR_CODE_FILE, 16, 25, 80);
//            this.mid = this._ms.addPsARPlayCard(1,80);
//            this.mid = this._ms.addARMarker(new Bitmap("../../../../../data/hiro.png"), 16, 25, 80); // you can use PNG style marker too.
            //this.mid = this._ms.addNyIdMarker(0, 80);// For Id  marker #0

            //set View mmatrix
            this._rs.loadARViewMatrix(d3d);
            //set Viewport matrix
            this._rs.loadARViewPort(d3d);
            //setD3dProjectionMatrix
            this._rs.loadARProjectionMatrix(d3d);
            this._ss.start();
        }
    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);
    }
        public MainWindow()
        {
            InitializeComponent();

            CaptureDeviceList oCaptureDeviceList = new CaptureDeviceList();

            MyCaptureDevice = oCaptureDeviceList[0];
            MyCaptureDevice.SetCaptureListener(this);
            MyCaptureDevice.PrepareCapture(800, 600, 30.0f);

            INyARMarkerSystemConfig oMarkerSystemConfig = new NyARMarkerSystemConfig(800, 600);

            this.ARMarkerSystem = new NyARD3dMarkerSystem(oMarkerSystemConfig);
            this.ARCameraSensor = new NyARDirectShowCamera(MyCaptureDevice);

            this.MarkerID_Hiro  = this.ARMarkerSystem.addARMarker(AR_CODE_FILE1, 16, 25, 80);
            this.MarkerID_KanJi = this.ARMarkerSystem.addARMarker(AR_CODE_FILE2, 16, 25, 80);
            this.MarkerID_VTT   = this.ARMarkerSystem.addARMarker(AR_CODE_FILE3, 16, 25, 80);
            this.MarkerID_ABB   = this.ARMarkerSystem.addARMarker(AR_CODE_FILE4, 16, 25, 80);
            this.Marker_Hello   = this.ARMarkerSystem.addARMarker(AR_CODE_FILE5, 16, 25, 80);

            this.Loaded += MainWindow_Loaded;

            this.BtnPauseZm.Click += BtnPauseZm_Click;
            this.BtnStartZm.Click += BtnStartZm_Click;
            this.BtnClearZm.Click += BtnClearZm_Click;
        }
Beispiel #10
0
        public override void setup(CaptureDevice i_cap)
        {
            Device d3d = this.size(SCREEN_WIDTH, SCREEN_HEIGHT);
            INyARMarkerSystemConfig cf = new NyARMarkerSystemConfig(SCREEN_WIDTH, SCREEN_HEIGHT);

            d3d.RenderState.ZBufferEnable = true;
            d3d.RenderState.Lighting      = false;
            d3d.RenderState.CullMode      = Cull.CounterClockwise;
            this._ms = new NyARD3dMarkerSystem(cf);
            this._ss = new NyARSensor(cf.getScreenSize());
            this._rs = new NyARD3dRender(d3d, this._ms);
            this.mid = this._ms.addARMarker(AR_CODE_FILE, 16, 25, 80);
            //set View mmatrix
            this._rs.loadARViewMatrix(d3d);
            //set Viewport matrix
            this._rs.loadARViewPort(d3d);
            //setD3dProjectionMatrix
            this._rs.loadARProjectionMatrix(d3d);
            Bitmap src   = new Bitmap(TEST_IMAGE);
            Bitmap input = new Bitmap(src.Width, src.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb);

            using (Graphics g = Graphics.FromImage(input))
            {
                g.DrawImage(src, 0, 0);
            }
            this._ss.update(new NyARBitmapRaster(input));
        }
Beispiel #11
0
    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);
    }
Beispiel #12
0
 private void setup(CaptureDevice i_cap)
 {
     Device d3d = this.size(SCREEN_WIDTH, SCREEN_HEIGHT);
     i_cap.PrepareCapture(SCREEN_WIDTH, SCREEN_HEIGHT, 30.0f);
     INyARMarkerSystemConfig cf = new NyARMarkerSystemConfig(SCREEN_WIDTH, SCREEN_HEIGHT);
     d3d.RenderState.ZBufferEnable = true;
     d3d.RenderState.Lighting = false;
     d3d.RenderState.CullMode = Cull.CounterClockwise;
     this._ms = new NyARD3dMarkerSystem(cf);
     this._ss = new NyARDirectShowCamera(i_cap);
     this._rs = new NyARD3dRender(d3d, this._ms);
     this.mid = this._ms.addARMarker(AR_CODE_FILE, 16, 25, 80);
     this._rs.loadARViewMatrix(d3d);
     this._rs.loadARViewPort(d3d);
     this._rs.loadARProjectionMatrix(d3d);
     this._ss.start();
 }
    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();
    }
        public MainWindow()
        {
            InitializeComponent();

            CaptureDeviceList oCaptureDeviceList = new CaptureDeviceList();

            MyCaptureDevice = oCaptureDeviceList[0];
            //MyCaptureDevice.SetCaptureListener(this);
            MyCaptureDevice.PrepareCapture(800, 600, 30.0f);

            INyARMarkerSystemConfig cf = new NyARMarkerSystemConfig(800, 600);

            this._ms = new NyARD3dMarkerSystem(cf);
            this.mid = this._ms.addARMarker(AR_CODE_FILE, 16, 25, 80);

            this._ss = new NyARDirectShowCamera(MyCaptureDevice);

            this.Loaded += MainWindow_Loaded;
        }
    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);
    }
Beispiel #16
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>());
    }
Beispiel #17
0
    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(
            new MemoryStream(((TextAsset)Resources.Load("patt_hiro", typeof(TextAsset))).bytes),
            16, 25, 80);
        //setup background
        this._bg_panel = GameObject.Find("Plane");
        this._bg_panel.GetComponent <Renderer>().material.mainTexture = tex;
        this._ms.setARBackgroundTransform(this._bg_panel.transform);

        //setup camera projection
        this._ms.setARCameraProjection(this.GetComponent <Camera>());
    }
Beispiel #18
0
        public SimpleLiteMain(Form i_form, CaptureDevice i_dev)
        {
            //setup camera
            i_dev.PrepareCapture(SCREEN_WIDTH, SCREEN_HEIGHT, 30.0f);

            //setup form
            i_form.ClientSize = new Size(SCREEN_WIDTH, SCREEN_HEIGHT);

            //setup AR
            INyARMarkerSystemConfig cf = new NyARMarkerSystemConfig(SCREEN_WIDTH, SCREEN_HEIGHT);

            this._ms = new NyARD3dMarkerSystem(cf);
            this._ss = new NyARDirectShowCamera(i_dev);
            this.mid = this._ms.addARMarker(AR_CODE_FILE, 16, 25, 80);

            //setup directx

            //3dデバイスを準備する
            this._d3d = NyARD3dUtil.createD3dDevice(i_form);
            this._d3d.RenderState.ZBufferEnable = true;
            this._d3d.RenderState.Lighting      = false;
            //ビューポートとビューの位置
            this._d3d.Transform.View = NyARD3dUtil.getARView();
            this._d3d.Viewport       = NyARD3dUtil.getARViewPort(SCREEN_WIDTH, SCREEN_HEIGHT);
            //Projectionの設定
            this._ms.setProjectionMatrixClipping(10, 10000);
            Matrix pm = new Matrix();

            NyARD3dUtil.toCameraFrustumRH(this._ms.getARParam(), 10, 10000, ref pm);
            this._d3d.Transform.Projection = pm;

            //カラーキューブの描画インスタンス
            this._cube = new ColorCube(this._d3d, 40);

            //背景サーフェイスを作成
            this._surface = new NyARD3dSurface(this._d3d, SCREEN_WIDTH, SCREEN_HEIGHT);
        }
    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;
            }
        }
    }
Beispiel #20
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;
    }
Beispiel #21
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();
    }
        public void InitTracker(params object[] configs)
        {
            if (!(configs.Length == 3 || configs.Length == 5))
            {
                throw new MarkerException("Problem in InitTracker in NewNyAR");
            }

            int imgWidth = 0;
            int imgHeight = 0;
            try
            {
                imgWidth = (int)configs[0];
                imgHeight = (int)configs[1];
                configFilename = (String)configs[2];
                if (configs.Length == 5)
                {
                    threshold = (int)configs[3];
                    continuousMode = (bool)configs[4];
                }
                else
                {
                    threshold = 100;
                    continuousMode = false;
                }
            }
            catch (Exception)
            {
                throw new MarkerException("Problem in InitTracker in NewNyAR");
            }

            nyARIntSize = new NyARIntSize(imgWidth, imgHeight);

            param = new NyARParam();
            param.loadARParam(TitleContainer.OpenStream(configFilename));
            param.changeScreenSize(nyARIntSize.w, nyARIntSize.h);

            camProjMat = GetProjectionMatrix(param, zNearPlane, zFarPlane);

            INyARMarkerSystemConfig arMarkerSystemConfig = new NyARMarkerSystemConfig(param);
            markerSystem = new NyARMarkerSystem(arMarkerSystemConfig);

            initialized = true;
        }