OpenCV

Calibration

//

Q&A

Q1:为什么 projectPoints 含有畸变系数?

A1:其得到的是考虑了畸变的二维图像点

在计算重投影误差时,由于真值考虑上了畸变模型(opencv检测到的棋盘格2D点),则三维的投影点也需要考虑上畸变模型。

# 使用OpenCV 3D->2D的接口的话需要去一次畸变才是自己写的重投影
re_projection, _ = cv2.projectPoints(corners_world[:, :3].astype(np.float32), rvec, tvec, self.intri_matrix, self.distor)
undistor_img_cv = cv2.undistortPoints(src=np.squeeze(re_projection), cameraMatrix=self.intri_matrix,
                                                  distCoeffs=self.distor,
                                                  P=self.intri_matrix)

undistor_img_ours, _ = self.lidar_to_img(corners_world[:, :3])

Camera

  • 打开笔记本内置相机

// TODO

Element

//

Geometry

#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>

// 判断点是否在某个闭合轮廓中
// region need float
std::vector<cv::Point2f> region = {{452, 385}, {830, 385}, {393, 540}, {900, 540}};
cv::Point2d bottom_middle_point = {452, 399};
int ret = cv::pointPolygonTest(region, point, false);

Image

// 读取图片
std::string file_name = "";
cv::imread(file_name);

Key

//

Mat

// Point2f -> Point2d
std::vector<cv::Point2f> vector1;
std::vector<cv::Point2d> vector2;
for (auto & point : vector1) {
   vector2.push_back(cv::Point2d((int) point.x, (int) point.y));
}

Smooth

# 一、腐蚀操作
def dilate(img):
    kernel = np.ones((3, 3), dtype=np.uint8)
    img = cv2.dilate(img, kernel, iterations=3)
    return img

# 二、高斯滤波
img = cv2.GaussianBlur(img, (5, 5), 0, 0, cv2.BORDER_DEFAULT)

Window

//

Q&A

Q1:xkbcommon: ERROR: failed to add default include path .../anaconda3/envs/.../share/X11/xkb

A1:添加环境变量 XKB_CONFIG_ROOT=/usr/share/X11/xkb

Q2&A2:qt.qpa.plugin:Could not load the Qt platform plugin “xcb“