Ejemplo n.º 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());
    }
Ejemplo n.º 2
0
 public void OnUpdateIntrinsic(Mat cameraMatrix, Mat distCoeffs)
 {
     Clear();
     this.cameraMatrix = cameraMatrix;
     this.distCoeffs   = distCoeffs;
     newCameraMatrix   = Calib3d.getOptimalNewCameraMatrix(cameraMatrix, distCoeffs, videoCaptureController.RGBMat.size(), 0, videoCaptureController.RGBMat.size());
     Calib3d.initUndistortRectifyMap(this.cameraMatrix, this.distCoeffs, new Mat(), newCameraMatrix, videoCaptureController.RGBMat.size(), CvType.CV_32FC1, mapX, mapY);
 }