コード例 #1
0
        /* DsXRGB32Rasterの内容を保持しているテクスチャにコピーします。
         * i_rasterのサイズは、このインスタンスに指定したテクスチャサイズ(コンストラクタ等に指定したサイズ)と同じである必要です。
         * ラスタデータはテクスチャの左上を基点にwidth x heightだけコピーされ、残りの部分は更新されません。
         */
        public void CopyFromXRGB32(DsBGRX32Raster i_raster)
        {
            //BUFFERFORMAT_BYTE1D_B8G8R8X8_32しか受けられません。
            Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8X8_32));
            GraphicsStream texture_rect;

            try
            {
                byte[] buf = (byte[])i_raster.getBuffer();
                // テクスチャをロックする
                texture_rect = this.m_texture.LockRectangle(0, LockFlags.None);
                //テクスチャのピッチって何?
                int cp_size = this.m_width * 4;
                int sk_size = (this.m_texture_width - this.m_width) * 4;
                int s       = 0;
                for (int r = this.m_height - 1; r >= 0; r--, s++)
                {
                    texture_rect.Write(buf, s * cp_size, cp_size);
                    texture_rect.Seek(sk_size, System.IO.SeekOrigin.Current);
                }
            }
            finally
            {
                //テクスチャをアンロックする
                this.m_texture.UnlockRectangle(0);
            }
            return;
        }
コード例 #2
0
ファイル: ABGRAcapture.cs プロジェクト: AbdBelf/MARS_project
        public bool InitializeApplication(Form1 topLevelForm, CaptureDevice i_cap_device)
        {
            //キャプチャを作る(QVGAでフレームレートは30)
            i_cap_device.SetCaptureListener(this);
            i_cap_device.PrepareCapture(SCREEN_WIDTH, SCREEN_HEIGHT, 30);
            this._cap = i_cap_device;

            //ARの設定

            //ARラスタを作る(DirectShowキャプチャ仕様)。
            this._raster = new DsBGRX32Raster(i_cap_device.video_width, i_cap_device.video_height, i_cap_device.video_width * i_cap_device.video_bit_count / 8);



            //3dデバイスを準備する
            this._device = PrepareD3dDevice(topLevelForm);

            // ライトを無効
            this._device.RenderState.Lighting = false;

            //背景サーフェイスを作成
            this._surface = new NyARSurface_XRGB32(this._device, SCREEN_WIDTH, SCREEN_HEIGHT);

            return(true);
        }
コード例 #3
0
ファイル: WUW.cs プロジェクト: Clonedpirate1/ProjectDigitus
        private void buttonBookDemo_Click(object sender, EventArgs e)
        {
            if (bookDemo == false)
            {
                StopOtherApps(this, e);
                bookDemo = true;
                labelDemoName.Text = "Book";
                buttonBookDemo.Text = "Stop Book";
                labelDemoInstructions.Enabled = true;
                labelDemoInstructions.Text = "Book Demo Instructions:\n\n"
                    + "Book \n";

                //pictureBoxAlbum.Show();
                lblResult.Hide();

                //NYAR
                //initialize nyar components.
                NyARParam ap = new NyARParam();
                ap.loadARParamFromFile(AR_CAMERA_FILE);
                ap.changeScreenSize(SCREEN_WIDTH, SCREEN_HEIGHT);
                _raster = new DsBGRX32Raster(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH * 32 / 8);
                _utils = new NyARD3dUtil();

                // For each pattern
                NyARCode code1 = new NyARCode(16, 16);
                code1.loadARPattFromFile(AR_CODE_FILE1);
                _ar1 = new NyARSingleDetectMarker(ap, code1, 80.0);
                _ar1.setContinueMode(false);

                NyARCode code2 = new NyARCode(16, 16);
                code2.loadARPattFromFile(AR_CODE_FILE2);
                _ar2 = new NyARSingleDetectMarker(ap, code2, 80.0);
                _ar2.setContinueMode(false);

                NyARCode code3 = new NyARCode(16, 16);
                code3.loadARPattFromFile(AR_CODE_FILE3);
                _ar3 = new NyARSingleDetectMarker(ap, code3, 80.0);
                _ar3.setContinueMode(false);

                NyARCode code4 = new NyARCode(16, 16);
                code4.loadARPattFromFile(AR_CODE_FILE4);
                _ar4 = new NyARSingleDetectMarker(ap, code4, 80.0);
                _ar4.setContinueMode(false);
            }
            else
            {
                bookDemo = false;
                labelDemoName.Text = "WUW";
                buttonBookDemo.Text = "Book";
                Cursor = Cursors.Arrow;
                labelDemoInstructions.Enabled = false;
                labelDemoInstructions.Text = "";
                ResetEnvironment();

                //pictureBoxAlbum.Hide();
                lblResult.Show();
            }
        }
コード例 #4
0
ファイル: NyARCore.cs プロジェクト: thaisrezendeb/brincAR
 public DsBGRX32Raster InstanceRaster(int videowidth, int videoheight)
 {
     raster = new DsBGRX32Raster(videowidth, videoheight);
     return(raster);
 }
コード例 #5
0
        /// <summary>
        /// Initilizes the marker tracker with a set of configuration parameters.
        /// Five parameters are expected: int imgWidth, int imgHeight, String cameraFilename, 
        /// int threshold, bool continuousMode
        /// </summary>
        /// <param name="configs">A set of configuration parameters</param>
        public void InitTracker(params Object[] configs)
        {
            if (!(configs.Length == 3 || configs.Length == 5))
                throw new MarkerException(GetInitTrackerUsage());

            int img_width = 0;
            int img_height = 0;
            try
            {
                img_width = (int)configs[0];
                img_height = (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(GetInitTrackerUsage());
            }

            raster = new DsBGRX32Raster(img_width, img_height);

            param = new NyARParam();
            param.loadARParam(TitleContainer.OpenStream(configFilename));
            param.changeScreenSize(img_width, img_height);

            camProjMat = GetProjectionMatrix(param, zNearPlane, zFarPlane);

            initialized = true;
        }
コード例 #6
0
        public void ProcessImage(IVideoCapture captureDevice, byte[] imagePtr)
        {
            if (captureDevice.Format != ImageFormat.B8G8R8A8_32)
                throw new MarkerException("Only ImageFormat.B8G8R8A8_32 format is acceptable for NyARToolkitTracker");

            // initialize the detector right before the image processing
            if (!started)
            {
                nyARSensor = new NyARSensor(nyARIntSize);

                nyARRaster = new DsBGRX32Raster(nyARIntSize.w, nyARIntSize.h);
                nyARSensor.update(nyARRaster);
                started = true;
            }

            nyARRaster.SetBuffer(imagePtr);
            nyARSensor.update(nyARRaster);
            nyARSensor.updateTimeStamp();
            
            markerSystem.update(nyARSensor);
            
            UpdateMarkerTransforms();
        }
コード例 #7
0
        public bool InitializeApplication(Form1 topLevelForm, CaptureDevice i_cap_device)
        {
            //キャプチャを作る(QVGAでフレームレートは30)
            i_cap_device.SetCaptureListener(this);
            i_cap_device.PrepareCapture(SCREEN_WIDTH, SCREEN_HEIGHT, 30);
            this._cap = i_cap_device;

            //ARの設定

            //ARラスタを作る(DirectShowキャプチャ仕様)。
            this._raster = new DsBGRX32Raster(i_cap_device.video_width, i_cap_device.video_height, i_cap_device.video_width * i_cap_device.video_bit_count / 8);

            //3dデバイスを準備する
            this._device = PrepareD3dDevice(topLevelForm);

            // ライトを無効
            this._device.RenderState.Lighting = false;

            //背景サーフェイスを作成
            this._surface = new NyARSurface_XRGB32(this._device, SCREEN_WIDTH, SCREEN_HEIGHT);

            return true;
        }