} /** * この関数は、参照元から歪みパラメータ値をコピーします。 * @param i_ref * コピー元のオブジェクト。 */ public void copyFrom(INyARCameraDistortionFactor i_ref) { NyARCameraDistortionFactorV4 src = (NyARCameraDistortionFactorV4)i_ref; this._k1 = src._k1; this._k2 = src._k2; this._p1 = src._p1; this._p2 = src._p2; this._fx = src._fx; this._fy = src._fy; this._x0 = src._x0; this._y0 = src._y0; this._s = src._s; }
/** * intrinsic_matrixとdistortion_coeffsからインスタンスを初期化する。 * @param i_w * カメラパラメータ生成時の画面サイズ * @param i_h * カメラパラメータ生成時の画面サイズ * @param i_intrinsic_matrix 3x3 matrix このパラメータは、OpenCVのcvCalibrateCamera2関数が出力するintrinsic_matrixの値と合致します。 * @param i_distortion_coeffs 4x1 vector このパラメータは、OpenCVのcvCalibrateCamera2関数が出力するdistortion_coeffsの値と合致します。 */ public ParamLoader(int i_w, int i_h, double[] i_intrinsic_matrix, double[] i_distortion_coeffs) { this.size = new NyARIntSize(i_w, i_h); //dist factor NyARCameraDistortionFactorV4 v4dist = new NyARCameraDistortionFactorV4(); v4dist.setValue(this.size, i_intrinsic_matrix, i_distortion_coeffs); double s = v4dist.getS(); this.dist_factor = v4dist; //projection matrix this.pmat = new NyARPerspectiveProjectionMatrix(); NyARDoubleMatrix33 r = new NyARDoubleMatrix33(); r.setValue(i_intrinsic_matrix); r.m00 /= s; r.m01 /= s; r.m10 /= s; r.m11 /= s; this.pmat.setValue(r, new NyARDoublePoint3d()); }
/** * intrinsic_matrixとdistortion_coeffsからインスタンスを初期化する。 * @param i_camera_width * カメラパラメータ生成時の画面サイズ * @param i_camera_height * カメラパラメータ生成時の画面サイズ * @param i_intrinsic_matrix 3x3 matrix このパラメータは、OpenCVのcvCalibrateCamera2関数が出力するintrinsic_matrixの値と合致します。 * @param i_distortion_coeffs 4x1 vector このパラメータは、OpenCVのcvCalibrateCamera2関数が出力するdistortion_coeffsの値と合致します。 */ public ParamLoader(int i_camera_width, int i_camera_height, double[] i_intrinsic_matrix, double[] i_distortion_coeffs, int i_screen_width, int i_screen_height) { double x_scale = (double)i_screen_width / (double)(i_camera_width); // scale = (double)xsize / (double)(source->xsize); double y_scale = (double)i_screen_height / (double)(i_camera_height); // scale = (double)ysize / (double)(source->ysize); this.size = new NyARIntSize(i_camera_width, i_camera_height); //dist factor(倍率1倍の基準点) NyARCameraDistortionFactorV4 v4dist = new NyARCameraDistortionFactorV4(i_camera_width, i_camera_height, i_intrinsic_matrix, i_distortion_coeffs, x_scale, y_scale); double s = v4dist.getS(); //projection matrix NyARDoubleMatrix33 r = new NyARDoubleMatrix33(); r.setValue(i_intrinsic_matrix); r.m00 /= s; r.m01 /= s; r.m10 /= s; r.m11 /= s; NyARPerspectiveProjectionMatrix pm = new NyARPerspectiveProjectionMatrix(); pm.setValue(r, new NyARDoublePoint3d()); pm.changeScale(x_scale, y_scale); this.dist_factor = v4dist; this.pmat = pm; }