Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
galaxis::camera Namespace Reference

Functions

cv::Mat getOptimalCameraMatrix ()
 
cv::Mat getPerspectiveTransform ()
 

Variables

const cv::Mat matrixD_mtx = (cv::Mat1d(3, 3) << 4.1762556576818139e+02, 0, 2.5803041199757405e+02, 0, 4.1789334832209283e+02, 8.3395313510144476e+01, 0, 0, 1)
 
const cv::Mat matrixK_dist = (cv::Mat1d(1, 5) << -4.1009180456714284e-01, 2.4282612421196481e-01, -5.4943175865065086e-03, 2.2892992455263131e-03, -1.0344846386273387e-01)
 

Function Documentation

◆ getOptimalCameraMatrix()

cv::Mat galaxis::camera::getOptimalCameraMatrix ( )

Definition at line 6 of file CameraCalibration.cpp.

6  {
7  // https://docs.opencv.org/3.4/d9/d0c/group__calib3d.html#ga7a6c4e032c97f03ba747966e6ad862b1
8  return cv::getOptimalNewCameraMatrix(matrixD_mtx, matrixK_dist, cv::Size(256,512), 1); //, cv::Size(256,512));
9 }

References matrixD_mtx, and matrixK_dist.

Referenced by StopLineDetection::StopLineDetection().

Here is the caller graph for this function:

◆ getPerspectiveTransform()

cv::Mat galaxis::camera::getPerspectiveTransform ( )

Definition at line 11 of file CameraCalibration.cpp.

11  {
12  // top view
13  // pts1 = np.float32( [[112.0,123.5],[437.0,130.0],[327.5,46.0],[213.0,44.5]])
14  // pts2 = np.float32( [[148, 174], [148+256, 174], [148+256, 174-152], [148, 174-152]])
15  // cv::Mat matrixTopView_1 = (cv::Mat1d(2, 4) << 112.0,123.5, 437.0,130.0, 327.5,46.0, 213.0,44.5);
16  // cv::Mat matrixTopView_2 = (cv::Mat1d(2, 4) << 148, 174, 148+256, 174, 148+256, 174-152, 148, 174-152);
17 
18  // std::cout << matrixTopView_1.size() << std::endl;
19  // std::cout << matrixTopView_2.size() << std::endl;
20  // return cv::getPerspectiveTransform(matrixTopView_1, matrixTopView_2);
21 
22  // top view transform matrix:
23  // [[ 6.04105082e+01 1.70937149e+02 -1.63898624e+04]
24  // [-2.05272012e+00 1.60637541e+02 -6.10401861e+03]
25  // [-5.84629918e-03 6.25657111e-01 1.00000000e+00]]
26  return (cv::Mat1d(3, 3) <<
27  6.04105082e+01, 1.70937149e+02, -1.63898624e+04,
28  -2.05272012e+00, 1.60637541e+02, -6.10401861e+03,
29  -5.84629918e-03, 6.25657111e-01, 1.00000000e+00
30  );
31 
32  // inverted top view transform matrix
33  // [[ 1.57596937e-02, -4.12850966e-02, 6.29421326e+00],
34  // [ 1.49447281e-04, -1.40223872e-04, 1.59349124e+00],
35  // [-1.36686947e-06, -1.53632964e-04, 3.98187279e-02]]
36 
37  // backwards
38  // _, IM = cv2.invert(M)
39  // x1 = 159
40  // y1 = 99
41  // coord = [x1, y1] + [1]
42  // P = np.float32(coord)
43 
44  // x, y, z = np.dot(IM, P)
45  // #Divide x and y by z to get 2D in frame {A}
46  // new_x = x/z
47  // new_y = y/z
48 }

Referenced by StopLineDetection::StopLineDetection().

Here is the caller graph for this function:

Variable Documentation

◆ matrixD_mtx

const cv::Mat galaxis::camera::matrixD_mtx = (cv::Mat1d(3, 3) << 4.1762556576818139e+02, 0, 2.5803041199757405e+02, 0, 4.1789334832209283e+02, 8.3395313510144476e+01, 0, 0, 1)

Allied Vision Camera Camera Matrix

%YAML:1.0

K: !!opencv-matrix rows: 3 cols: 3 dt: d data: [ 4.1762556576818139e+02, 0., 2.5803041199757405e+02, 0., 4.1789334832209283e+02, 8.3395313510144476e+01, 0., 0., 1. ] D: !!opencv-matrix rows: 1 cols: 5 dt: d data: [ -4.1009180456714284e-01, 2.4282612421196481e-01, -5.4943175865065086e-03, 2.2892992455263131e-03, -1.0344846386273387e-01 ]

Definition at line 28 of file CameraCalibration.hpp.

Referenced by getOptimalCameraMatrix(), and StopLineDetection::on_stop_line_detection_callback().

◆ matrixK_dist

const cv::Mat galaxis::camera::matrixK_dist = (cv::Mat1d(1, 5) << -4.1009180456714284e-01, 2.4282612421196481e-01, -5.4943175865065086e-03, 2.2892992455263131e-03, -1.0344846386273387e-01)
galaxis::camera::matrixK_dist
const cv::Mat matrixK_dist
Definition: CameraCalibration.hpp:30
galaxis::camera::matrixD_mtx
const cv::Mat matrixD_mtx
Definition: CameraCalibration.hpp:28