コード例 #1
0
    /// <summary>
    /// 補正対象のテクスチャが初期化された際に補正用の設定を初期化する
    /// </summary>
    /// <param name="texture"></param>
    private void VideoCaptureController_ChangeTextureEvent(TextureHolderBase sender, Texture texture)
    {
        rgbMat = new Mat(texture.height, texture.width, CvType.CV_8UC3);
        if (this.texture != null)
        {
            if (this.texture.width != texture.width || this.texture.height != texture.height)
            {
                DestroyImmediate(this.texture);
                this.texture = null;
            }
        }
        if (this.texture == null)
        {
            this.texture = new Texture2D(texture.width, texture.height, TextureFormat.RGB24, false);
        }

        newCameraMatrix = Calib3d.getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, videoCaptureController.RGBMat.size(), 0, videoCaptureController.RGBMat.size());
        if (isFisheye)
        {
            Calib3d.fisheye_initUndistortRectifyMap(this.cameraMatrix, this.distCoeffs, new Mat(), newCameraMatrix, videoCaptureController.RGBMat.size(), CvType.CV_32FC1, mapX, mapY);
        }
        else
        {
            Calib3d.initUndistortRectifyMap(this.cameraMatrix, this.distCoeffs, new Mat(), newCameraMatrix, videoCaptureController.RGBMat.size(), CvType.CV_32FC1, mapX, mapY);
        }

        //

        OnTextureInitialized(GetTexture());
    }
コード例 #2
0
 private void TextureHolder_InitializedEvent(TextureHolderBase sender, Texture texture)
 {
     Close();
     grayMat      = new Mat(texture.height, texture.width, CvType.CV_8UC1);
     rgbMat       = new Mat(texture.height, texture.width, CvType.CV_8UC3);
     this.texture = new Texture2D(texture.width, texture.height, TextureFormat.RGB24, false);
     OnTextureInitialized(this.texture);
 }
コード例 #3
0
    private void VideoCaptureController_ChangeTextureEvent(TextureHolderBase sender, Texture texture)
    {
        var frameSize = new Vector2(camera.orthographicSize * 2 * camera.aspect, camera.orthographicSize * 2);
        var size      = EMath.GetShrinkFitSize(new Vector2(texture.width, texture.height), frameSize);

        this.transform.localScale     = new Vector3(size.x, size.y, 1f);
        renderer.material.mainTexture = textureHolder.GetTexture();
    }
コード例 #4
0
 private void VideoCaptureController_TextureUpdatedEvent(TextureHolderBase sender, Texture texture)
 {
     if (!this.enabled)
     {
         return;
     }
     if (!this.gameObject.activeInHierarchy)
     {
         return;
     }
     videoCaptureController.RGBMat.copyTo(rgbMat);
     Imgproc.cvtColor(rgbMat, grayMat, Imgproc.COLOR_RGB2GRAY);
     calibrator.Draw(grayMat, rgbMat);
     Core.flip(rgbMat, rgbMat, 0);
     Utils.fastMatToTexture2D(rgbMat, this.texture);
 }
コード例 #5
0
 private void VideoCaptureController_ChangeTextureEvent(TextureHolderBase sender, Texture texture)
 {
     Init();
 }
コード例 #6
0
 private void VideoCaptureController_RefreshTextureEvent(TextureHolderBase sender, Texture texture)
 {
     //Calib3d.undistort(videoCaptureController.RGBMat, rgbMat, cameraMatrix, distCoeffs, newCameraMatrix);
     Refresh();
 }
コード例 #7
0
 private void TextureHolder_ChangeTextureEvent(TextureHolderBase sender, Texture texture)
 {
     Init(new Vector2(texture.width, texture.height));
     renderer.material.mainTexture = texture;
 }