├── Programming ├── C++ │ ├── Ceres.md │ ├── Eigen.md │ ├── More.md │ ├── OpenCV.md │ ├── Sophus.md │ ├── cmake.md │ └── 数据结构.md ├── Markdown.md ├── Matlab │ ├── Automatic Control Theory.md │ ├── Linear algebra.md │ ├── More.md │ └── Probability Theory.md └── Python │ ├── More.md │ ├── Picture_Plot │ ├── matplotlib_pyplot.md │ └── seaborn.md │ ├── numpy.md │ ├── pandas.md │ ├── sklearn.md │ ├── tensorflow.md │ └── 数据结构.md ├── README.md ├── Rapberry_Pi ├── Berryconda.md ├── 创建wifi热点&开启SSH&putty连接.md ├── 升级python版本.md ├── 安装tensorflow.md ├── 更换下载源.md ├── 直流电机相关.md ├── 相机&opencv_python.md ├── 网球追踪技术原理.md └── 超声波传感器.md ├── StudyNotes ├── LoopClosing.md ├── ORB-SLAM2.md ├── PCA.md ├── ROS.md ├── SVD.md ├── Simscape.md ├── caffe.md ├── calc.md ├── flann.md └── 相机标定.md ├── TX2 └── 基本使用.md ├── Ubuntu ├── Anaconda & vscode & TensorFlow.md ├── GRUB2.md ├── Github.md ├── NVIDIA driver.md ├── OpenAI-baselines.md ├── Python&软链接&pip.md ├── ROS.md ├── SLAM相关.md ├── Terminal常用命令.md ├── VScode.md ├── apt-get & pip换国内源.md ├── caffe.md ├── firefox.md ├── gym.md ├── matebook修改boot启动顺序.md ├── nvidiadriver_cuda_cudnn.md ├── opencv.md ├── peek-ubuntu录屏软件.md ├── pppoe拨号上网.md ├── pytorch.md ├── shadowsocks.md ├── tty.md ├── 个人主页jekyll+GitHub Pages.md ├── 常用文件夹固定到File左侧.md ├── 微信.md ├── 思维导图软件.md ├── 搜狗输入法.md ├── 服务器上的配置.md ├── 用不用sudo的区别.md ├── 翻译软件GoldenDict.md ├── 解决ubuntu安装软件has install-snap change in progress错误.md ├── 解决ubuntu改变win系统时间.md ├── 解决ubuntu触控板右键失灵.md └── 运行可执行文件.md └── WIN ├── EndNote.md ├── Latex相关.md ├── Onedrive.md ├── PPT.md ├── PS.md ├── Python.md ├── SSR+AmyTelecom.md ├── SolidConverter.md ├── Word.md ├── XJTU-VPN.pdf ├── Zotero ├── cmd.md ├── mathpix.md ├── ssh.md ├── win10电脑半夜自动开机.md ├── 删除文件.md └── 邮件客户端.md /Programming/C++/Ceres.md: -------------------------------------------------------------------------------- 1 | # Ceres 库相关 2 | 3 | ## 头文件 4 | ``` 5 | #include 6 | ``` -------------------------------------------------------------------------------- /Programming/C++/Eigen.md: -------------------------------------------------------------------------------- 1 | # C++ Eigen 相关 2 | ## 头文件 3 | ``` 4 | #include // Eigen 核心部分 5 | #include // 稠密矩阵的代数运算(逆,特征值等) 6 | #include // Eigen/Geometry 模块提供了各种旋转和平移的表示 7 | ``` 8 | 9 | ## Eigen常规使用 10 | ```c++ 11 | // Eigen 核心部分 12 | #include 13 | // 稠密矩阵的代数运算(逆,特征值等) 14 | #include 15 | 16 | // Eigen 中所有向量和矩阵都是Eigen::Matrix,它是一个模板类。它的前三个参数为:数据类型,行,列 17 | // 声明一个2*3的float矩阵 18 | Matrix matrix_23; 19 | 20 | // 同时,Eigen 通过 typedef 提供了许多内置类型,不过底层仍是Eigen::Matrix 21 | // 例如 Vector3d 实质上是 Eigen::Matrix,即三维向量 22 | Vector3d v_3d; 23 | // 这是一样的 24 | Matrix vd_3d; 25 | 26 | // Matrix3d 实质上是 Eigen::Matrix 27 | Matrix3d matrix_33 = Matrix3d::Zero(); //初始化为零 28 | // 如果不确定矩阵大小,可以使用动态大小的矩阵 29 | Matrix matrix_dynamic; 30 | // 更简单的 31 | MatrixXd matrix_x; 32 | // 这种类型还有很多,我们不一一列举 33 | 34 | // 下面是对Eigen阵的操作 35 | // 输入数据(初始化) 36 | matrix_23 << 1, 2, 3, 4, 5, 6; 37 | // 输出 38 | cout << "matrix 2x3 from 1 to 6: \n" << matrix_23 << endl; 39 | 40 | // 用()访问矩阵中的元素 41 | cout << "print matrix 2x3: " << endl; 42 | for (int i = 0; i < 2; i++) { 43 | for (int j = 0; j < 3; j++) cout << matrix_23(i, j) << "\t"; 44 | cout << endl; 45 | } 46 | 47 | // 矩阵和向量相乘(实际上仍是矩阵和矩阵) 48 | v_3d << 3, 2, 1; 49 | vd_3d << 4, 5, 6; 50 | 51 | // 但是在Eigen里你不能混合两种不同类型的矩阵,像这样是错的 52 | // Matrix result_wrong_type = matrix_23 * v_3d; 53 | // 应该显式转换 54 | Matrix result = matrix_23.cast() * v_3d; 55 | cout << "[1,2,3;4,5,6]*[3,2,1]=" << result.transpose() << endl; 56 | 57 | Matrix result2 = matrix_23 * vd_3d; 58 | cout << "[1,2,3;4,5,6]*[4,5,6]: " << result2.transpose() << endl; 59 | 60 | // 同样你不能搞错矩阵的维度 61 | // 试着取消下面的注释,看看Eigen会报什么错 62 | // Eigen::Matrix result_wrong_dimension = matrix_23.cast() * v_3d; 63 | 64 | // 一些矩阵运算 65 | // 四则运算就不演示了,直接用+-*/即可。 66 | matrix_33 = Matrix3d::Random(); // 随机数矩阵 67 | cout << "random matrix: \n" << matrix_33 << endl; 68 | cout << "transpose: \n" << matrix_33.transpose() << endl; // 转置 69 | cout << "sum: " << matrix_33.sum() << endl; // 各元素和 70 | cout << "trace: " << matrix_33.trace() << endl; // 迹 71 | cout << "times 10: \n" << 10 * matrix_33 << endl; // 数乘 72 | cout << "inverse: \n" << matrix_33.inverse() << endl; // 逆 73 | cout << "det: " << matrix_33.determinant() << endl; // 行列式 74 | 75 | // 特征值 76 | // 实对称矩阵可以保证对角化成功 77 | SelfAdjointEigenSolver eigen_solver(matrix_33.transpose() * matrix_33); 78 | cout << "Eigen values = \n" << eigen_solver.eigenvalues() << endl; 79 | cout << "Eigen vectors = \n" << eigen_solver.eigenvectors() << endl; 80 | 81 | // 解方程 82 | // 我们求解 matrix_NN * x = v_Nd 这个方程 83 | // N的大小在前边的宏里定义,它由随机数生成 84 | // 直接求逆自然是最直接的,但是求逆运算量大 85 | 86 | Matrix matrix_NN 87 | = MatrixXd::Random(MATRIX_SIZE, MATRIX_SIZE); 88 | matrix_NN = matrix_NN * matrix_NN.transpose(); // 保证半正定 89 | Matrix v_Nd = MatrixXd::Random(MATRIX_SIZE, 1); 90 | 91 | clock_t time_stt = clock(); // 计时 92 | // 直接求逆 93 | Matrix x = matrix_NN.inverse() * v_Nd; 94 | cout << "time of normal inverse is " 95 | << 1000 * (clock() - time_stt) / (double) CLOCKS_PER_SEC << "ms" << endl; 96 | cout << "x = " << x.transpose() << endl; 97 | 98 | // 通常用矩阵分解来求,例如QR分解,速度会快很多 99 | time_stt = clock(); 100 | x = matrix_NN.colPivHouseholderQr().solve(v_Nd); 101 | cout << "time of Qr decomposition is " 102 | << 1000 * (clock() - time_stt) / (double) CLOCKS_PER_SEC << "ms" << endl; 103 | cout << "x = " << x.transpose() << endl; 104 | 105 | // 对于正定矩阵,还可以用cholesky分解来解方程 106 | time_stt = clock(); 107 | x = matrix_NN.ldlt().solve(v_Nd); 108 | cout << "time of ldlt decomposition is " 109 | << 1000 * (clock() - time_stt) / (double) CLOCKS_PER_SEC << "ms" << endl; 110 | cout << "x = " << x.transpose() << endl; 111 | ``` 112 | 113 | ## Eigen/Geometry 114 | ```cpp 115 | #include 116 | 117 | // 3D 旋转矩阵直接使用 Matrix3d 或 Matrix3f 118 | Matrix3d rotation_matrix = Matrix3d::Identity(); 119 | // 旋转向量使用 AngleAxis, 它底层不直接是Matrix,但运算可以当作矩阵(因为重载了运算符) 120 | AngleAxisd rotation_vector(M_PI / 4, Vector3d(0, 0, 1)); //沿 Z 轴旋转 45 度 121 | cout.precision(3); 122 | cout << "rotation matrix =\n" << rotation_vector.matrix() << endl; //用matrix()转换成矩阵 123 | // 也可以直接赋值 124 | rotation_matrix = rotation_vector.toRotationMatrix(); 125 | // 用 AngleAxis 可以进行坐标变换 126 | Vector3d v(1, 0, 0); 127 | Vector3d v_rotated = rotation_vector * v; 128 | cout << "(1,0,0) after rotation (by angle axis) = " << v_rotated.transpose() << endl; 129 | // 或者用旋转矩阵 130 | v_rotated = rotation_matrix * v; 131 | cout << "(1,0,0) after rotation (by matrix) = " << v_rotated.transpose() << endl; 132 | 133 | // 欧拉角: 可以将旋转矩阵直接转换成欧拉角 134 | Vector3d euler_angles = rotation_matrix.eulerAngles(2, 1, 0); // ZYX顺序,即roll pitch yaw顺序 135 | cout << "yaw pitch roll = " << euler_angles.transpose() << endl; 136 | 137 | // 欧氏变换矩阵使用 Eigen::Isometry 138 | Isometry3d T = Isometry3d::Identity(); // 虽然称为3d,实质上是4*4的矩阵 139 | T.rotate(rotation_vector); // 按照rotation_vector进行旋转 140 | T.pretranslate(Vector3d(1, 3, 4)); // 把平移向量设成(1,3,4) 141 | cout << "Transform matrix = \n" << T.matrix() << endl; 142 | 143 | // 用变换矩阵进行坐标变换 144 | Vector3d v_transformed = T * v; // 相当于R*v+t 145 | cout << "v tranformed = " << v_transformed.transpose() << endl; 146 | 147 | // 对于仿射和射影变换,使用 Eigen::Affine3d 和 Eigen::Projective3d 即可,略 148 | 149 | // 四元数 150 | // 可以直接把AngleAxis赋值给四元数,反之亦然 151 | Quaterniond q = Quaterniond(rotation_vector); 152 | cout << "quaternion from rotation vector = " << q.coeffs().transpose() 153 | << endl; // 请注意coeffs的顺序是(x,y,z,w),w为实部,前三者为虚部 154 | // 也可以把旋转矩阵赋给它 155 | q = Quaterniond(rotation_matrix); 156 | cout << "quaternion from rotation matrix = " << q.coeffs().transpose() << endl; 157 | // 使用四元数旋转一个向量,使用重载的乘法即可 158 | v_rotated = q * v; // 注意数学上是qvq^{-1} 159 | cout << "(1,0,0) after rotation = " << v_rotated.transpose() << endl; 160 | // 用常规向量乘法表示,则应该如下计算 161 | cout << "should be equal to " << (q * Quaterniond(0, 1, 0, 0) * q.inverse()).coeffs().transpose() << endl; 162 | 163 | // 旋转矩阵 转换为 旋转向量 164 | Eigen::AngleAxisd rotation_vector; 165 | rotation_vector.fromRotationMatrix(rotationMatrix); 166 | ``` 167 | 168 | 169 | 170 | ```cpp 171 | // 取旋转矩阵和平移向量 172 | Eigen::Matrix pose_t = frame_pose.translation(); 173 | Eigen::Matrix pose_R = frame_pose.rotationMatrix(); 174 | ``` 175 | 176 | ## 块操作 177 | 178 | ```cpp 179 | // 块操作 180 | A.block(i, j, p, q) 181 | A.block(i, j) 182 | ``` 183 | 184 | ## 给矩阵增加一列 185 | 186 | [参考](https://stackoverflow.com/questions/27404811/append-column-to-matrix-using-eigen-library) 187 | 188 | ``` 189 | mat.conservativeResize(mat.rows(), mat.cols()+1); 190 | mat.col(mat.cols()-1) = vec; 191 | ``` 192 | 193 | 194 | 195 | ## Eigen::aligned_allocator 196 | 197 | 如果STL容器中的元素是Eigen库数据结构,例如这里定义一个vector容器,元素是Matrix4d ,如下所示: 198 | ``` 199 | vector; 200 | ``` 201 | 202 | 这个错误也是和上述一样的提示,编译不会出错,只有在运行的时候出错。解决的方法很简单,定义改成下面的方式: 203 | ``` 204 | vector>; 205 | ``` 206 | 其实上述的这段代码才是标准的定义容器方法,只是我们一般情况下定义容器的元素都是C++中的类型,所以可以省略,这是因为在C++11标准中,aligned_allocator管理C++中的各种数据类型的内存方法是一样的,可以不需要着重写出来。但是在Eigen管理内存和C++11中的方法是不一样的,所以需要单独强调元素的内存分配和管理。 207 | 208 | ## EIGEN_MAKE_ALIGNED_OPERATOR_NEW 209 | 参考:[Structures Having Eigen Members](https://eigen.tuxfamily.org/dox/group__TopicStructHavingEigenMembers.html) 210 | 211 | -------------------------------------------------------------------------------- /Programming/C++/More.md: -------------------------------------------------------------------------------- 1 | 2 | # 拼接string 3 | 4 | eg: 5 | ``` 6 | #include 7 | 8 | string path = "./data/"+to_string(i+1)+".png"; 9 | ``` 10 | 11 | # std::chrono 计时 12 | 使用std::chrono,不要用ctime: 13 | ```c++ 14 | #include 15 | 16 | std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now(); 17 | 18 | std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now(); 19 | 20 | std::chrono::duration time_used = std::chrono::duration_cast > (t2 - t1); 21 | std::cout << time_used.count() << "s" << std::endl; 22 | ``` 23 | 24 | 更高精度: 25 | 26 | ```c++ 27 | auto t_start = std::chrono::high_resolution_clock::now(); 28 | auto t_end = std::chrono::high_resolution_clock::now(); 29 | auto time_used = std::chrono::duration_cast(t_end-t_start); 30 | std::cout << time_used.count() << "ms" << std::endl; 31 | ``` 32 | 33 | 34 | 35 | # 智能指针 36 | 37 | ``` 38 | #include 39 | ``` 40 | 41 | ### std::shared_ptr 42 | 43 | ``` 44 | // 删除 p 对 unimportant_ptr 的对象的指向,并不会删除 unimportant_ptr 的对象(计数器减1) 45 | std::shared_ptr p; 46 | p = unimportant_ptr; 47 | p.reset(); 48 | ``` 49 | 50 | 51 | 52 | # size_t 53 | 54 | size_t在32位系统和64位系统分别代表了unsigned int 与unsigned long 类型,这样的话方便代码在各类型机器中移植。 55 | 56 | 常用于循环中: 57 | ``` 58 | for (size_t i = 0; i < ...; i++) 59 | ``` 60 | 61 | # std::thread 62 | [Multithreading in C++ | GeeksforGeeks](https://www.geeksforgeeks.org/multithreading-in-cpp/) 63 | * 必看,适合第一次看 64 | 65 | [Learn C++ Multi-Threading in 5 Minutes](https://hackernoon.com/learn-c-multi-threading-in-5-minutes-8b881c92941f) 66 | * 相对更全面 67 | * 三种定义方法: 68 | * 函数指针 69 | * 使用 functor (Class operator) 70 | * lambda 函数 71 | * 防止多线程同时对某一共享源进行操作而出错 72 | * 使用 std::mutex & std::unlock_guard 73 | * 查看本机 CPU 的 core 个数 74 | 75 | [C++ std::thread | 菜鸟教程](https://www.runoob.com/w3cnote/cpp-std-thread.html) 76 | * 参考其中原址操作:若函数传入的是参数的reference,则调要时的参数传递要使用std::ref() 77 | 78 | 79 | ## 运行程序报错 undefined reference to 'pthread_create' 80 | 需要在 CMakeLists.txt 中对 FLAGS 进行设置,添加 -pthread 81 | ``` 82 | SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11 -pthread") 83 | ``` 84 | 85 | 使用 g++ 的话,同样需要在编译的时候在命令后添加 -pthread: 86 | ``` 87 | g++ xxx.cpp -pthread -std=c++11 88 | ``` 89 | 90 | ## string to int 91 | 92 | ``` 93 | int a; 94 | std::string b = std::stoi(a); 95 | ``` 96 | 97 | -------------------------------------------------------------------------------- /Programming/C++/OpenCV.md: -------------------------------------------------------------------------------- 1 | # OpenCV C++ 相关 2 | 3 | [OpenCV Tutorials](https://docs.opencv.org/master/d9/df8/tutorial_root.html) 4 | 5 | ## 头文件 6 | ``` 7 | #include // 核心功能,包括基本数据结构 8 | #include 9 | #include // 高层GUI图像交互 10 | #include // 特征提取、描述、匹配 11 | #include "opencv2/xfeatures2d.hpp" // 特征提取、描述、匹配 12 | ``` 13 | 14 | ## 清除 cv::Mat 15 | 16 | ``` 17 | cv::Mat m; 18 | m.release(); 19 | ``` 20 | 21 | ## 读取图像 22 | 23 | ``` 24 | Mat img = imread("file_name", 0); // 读取灰度图像,8位深度,1通道,数据类型uchar 25 | Mat img = imread("file_name", -1); // 读取原始图像,原通道,数据类型根据原始图像的类型来 26 | Mat img = imread("file_name", 1); // 读取彩色图像,8位深度,3通道 27 | ``` 28 | 29 | * IMREAD_UNCHANGED (<0) loads the image as is (including the alpha channel if present) 30 | * IMREAD_GRAYSCALE ( 0) loads the image as an intensity one 31 | * IMREAD_COLOR (>0) loads the image in the RGB format 32 | 33 | 34 | 参考: 35 | flag=-1,8位深度,原通道 36 | flag=0,8位深度,1通道 37 | flag=1, 8位深度 ,3通道 38 | flag=2,原深度,1通道 39 | flag=3, 原深度,3通道 40 | flag=4,8位深度 ,3通道 41 | 42 | 参考:[OpenCV之通道和位深的理解(CV_8UC1,CV_8SC1,CV_32FC1)](https://blog.csdn.net/u011028345/article/details/75415914) 43 | 44 | 45 | 46 | ## 新建图像 47 | ``` 48 | Mat img(height, width, CV_64F); // CV_64F: 64位浮点类型 49 | ``` 50 | 51 | ## 展示图像 52 | ``` 53 | cv::imshow("img_name", img); 54 | cv::waitKey(0); 55 | ``` 56 | 57 | ## 写入图像 58 | ``` 59 | cv::imwrite("file_name", img); 60 | // 如果img是double格式的,则需要×255后write 61 | cv::imwrite("file_name", img * 255); 62 | ``` 63 | 64 | ## 图像的基本信息 65 | ``` 66 | image.cols 67 | image.rows 68 | image.channels() 69 | image.type() // 图像的类型 70 | 71 | ``` 72 | ``` 73 | if(image.data == nullptr){} // 用来判断是否读取到图像 74 | ``` 75 | 76 | ## 使用图像中的一个像素 77 | 像素坐标(x, y):即第y行,第x列 78 | ``` 79 | // 注意,以下所有方式中的数据类型需要和图像的数据类型对应好 80 | // 方式1 81 | image.ptr(y)[x] 82 | // 如果是三通道图像 83 | image.ptr(y)[x * image.channels()][c] 84 | 85 | // 方式2:最慢 86 | image.at(y, x) 87 | ``` 88 | 双线性灰度插值:这种方式可能比上面的要快一些 89 | ``` 90 | inline float GetPixelValue(const cv::Mat &img, float x, float y) { 91 | // boundary check 92 | if (x < 0) x = 0; 93 | if (y < 0) y = 0; 94 | if (x >= img.cols) x = img.cols - 1; 95 | if (y >= img.rows) y = img.rows - 1; 96 | uchar *data = &img.data[int(y) * img.step + int(x)]; 97 | float xx = x - floor(x); 98 | float yy = y - floor(y); 99 | return float( 100 | (1 - xx) * (1 - yy) * data[0] + 101 | xx * (1 - yy) * data[1] + 102 | (1 - xx) * yy * data[img.step] + 103 | xx * yy * data[img.step + 1] 104 | ); 105 | } 106 | ``` 107 | 108 | ## 图像拷贝 109 | ``` 110 | image_clone = image.clone(); 111 | ``` 112 | 113 | ## 矩阵拼接 114 | eg: 令T2 = [R, t] 115 | ``` 116 | Mat T2; 117 | hconcat(R, t, T2); 118 | ``` 119 | 120 | ## 判断图像是否为空(空指针) 121 | ``` 122 | if (image.data == nullptr) 123 | ``` 124 | 125 | ## OpenCV随机数产生器 126 | ``` 127 | cv::RNG rng; 128 | rng.gaussian(sigma * sigma) // 服从(0, sigma^2)高斯分布的一个值 129 | ``` 130 | 131 | ## 灰度图 RGB图 之间转换 132 | 133 | ``` 134 | cv::cvtColor(srcimg, dstimg, cv::COLOR_BGR2GRAY); 135 | cv::cvtColor(srcimg, dstimg, cv::COLOR_GRAY2BGR); 136 | 137 | # RGB 同理,将 BGR 改为 RGB 即可 138 | ``` 139 | 140 | -------------------------------------------------------------------------------- /Programming/C++/Sophus.md: -------------------------------------------------------------------------------- 1 | # Sophus库相关 2 | 3 | ## Sophus常规使用 4 | ``` 5 | #include 6 | #include 7 | #include "sophus/se3.hpp" 8 | 9 | // 沿Z轴转90度的旋转矩阵 10 | Matrix3d R = AngleAxisd(M_PI / 2, Vector3d(0, 0, 1)).toRotationMatrix(); 11 | // 或者四元数 12 | Quaterniond q(R); 13 | Sophus::SO3d SO3_R(R); // Sophus::SO3d可以直接从旋转矩阵构造 14 | Sophus::SO3d SO3_q(q); // 也可以通过四元数构造 15 | // 二者是等价的 16 | cout << "SO(3) from matrix:\n" << SO3_R.matrix() << endl; 17 | cout << "SO(3) from quaternion:\n" << SO3_q.matrix() << endl; 18 | cout << "they are equal" << endl; 19 | 20 | // 使用对数映射获得它的李代数 21 | Vector3d so3 = SO3_R.log(); 22 | cout << "so3 = " << so3.transpose() << endl; 23 | // hat 为向量到反对称矩阵 24 | cout << "so3 hat=\n" << Sophus::SO3d::hat(so3) << endl; 25 | // 相对的,vee为反对称到向量 26 | cout << "so3 hat vee= " << Sophus::SO3d::vee(Sophus::SO3d::hat(so3)).transpose() << endl; 27 | 28 | // 增量扰动模型的更新 29 | Vector3d update_so3(1e-4, 0, 0); //假设更新量为这么多 30 | Sophus::SO3d SO3_updated = Sophus::SO3d::exp(update_so3) * SO3_R; 31 | cout << "SO3 updated = \n" << SO3_updated.matrix() << endl; 32 | 33 | cout << "*******************************" << endl; 34 | // 对SE(3)操作大同小异 35 | Vector3d t(1, 0, 0); // 沿X轴平移1 36 | Sophus::SE3d SE3_Rt(R, t); // 从R,t构造SE(3) 37 | Sophus::SE3d SE3_qt(q, t); // 从q,t构造SE(3) 38 | cout << "SE3 from R,t= \n" << SE3_Rt.matrix() << endl; 39 | cout << "SE3 from q,t= \n" << SE3_qt.matrix() << endl; 40 | // 李代数se(3) 是一个六维向量,方便起见先typedef一下 41 | typedef Eigen::Matrix Vector6d; 42 | Vector6d se3 = SE3_Rt.log(); 43 | cout << "se3 = " << se3.transpose() << endl; 44 | // 观察输出,会发现在Sophus中,se(3)的平移在前,旋转在后. 45 | // 同样的,有hat和vee两个算符 46 | cout << "se3 hat = \n" << Sophus::SE3d::hat(se3) << endl; 47 | cout << "se3 hat vee = " << Sophus::SE3d::vee(Sophus::SE3d::hat(se3)).transpose() << endl; 48 | 49 | // 最后,演示一下更新 50 | Vector6d update_se3; //更新量 51 | update_se3.setZero(); 52 | update_se3(0, 0) = 1e-4d; 53 | Sophus::SE3d SE3_updated = Sophus::SE3d::exp(update_se3) * SE3_Rt; 54 | cout << "SE3 updated = " << endl << SE3_updated.matrix() << endl; 55 | ``` -------------------------------------------------------------------------------- /Programming/C++/cmake.md: -------------------------------------------------------------------------------- 1 | ## cmake 相关 2 | 3 | ## CMakeLists 模板 4 | ``` 5 | 6 | cmake_minimum_required(VERSION 2.8) 7 | project(xxx) 8 | 9 | # 添加C++11标准支持 10 | set(CMAKE_CXX_FLAGS "-std=c++11") 11 | 12 | # 设置Debug模式或Release模式 13 | set(CMAKE_BUILD_TYPE "Debug") 14 | 15 | list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) 16 | 17 | 18 | # Eigen 19 | include_directories("/usr/include/eigen3") 20 | 21 | # OpenCV 22 | find_package(OpenCV REQUIRED) 23 | include_directories(${OpenCV_INCLUDE_DIR}) 24 | 25 | # Ceres 26 | find_package(Ceres REQUIRED) 27 | include_directories(${CERES_INCLUDE_DIRS}) 28 | 29 | 30 | add_executable(xxx xxx.cpp) 31 | target_link_libraries(xxx ${OpenCV_LIBS}) 32 | target_link_libraries(xxx ${CERES_LIBRARIES}) 33 | 34 | ``` 35 | 36 | ## find_package 相关 37 | 38 | 参考资料:[cmake教程4(find_package使用)](https://blog.csdn.net/haluoluo211/article/details/80559341) 39 | 40 | ## Debug 断点调试 41 | CMakeLists中: 42 | ``` 43 | set(CMAKE_BUILD_TYPE "Debug") 44 | ``` 45 | 46 | 不需要debug模式的话,就使用Release模式: 47 | ``` 48 | set(CMAKE_BUILD_TYPE "Release") 49 | ``` 50 | 不设置,默认是debug模式。 -------------------------------------------------------------------------------- /Programming/C++/数据结构.md: -------------------------------------------------------------------------------- 1 | # std::unordered_map 2 | 3 | 删除元素 4 | 5 | ``` 6 | auto n = people.erase ("Jim");// Returns 0 if key not found 7 | auto iter = people.find ("May") ; // Returns end iterator if key not found 8 | if(iter != people.end()) 9 | iter = people.erase (iter) ;// Returns iterator for element after "May" 10 | ``` 11 | 12 | -------------------------------------------------------------------------------- /Programming/Markdown.md: -------------------------------------------------------------------------------- 1 | 2 | ## Github flavored Markdown 3 | 4 | Github markdown 官方教程: 5 | [Mastering Markdown](https://guides.github.com/features/mastering-markdown/) 6 | 7 | 8 | ### 数学公式 9 | GitHub Flavored Markdown 曾经是支持 LaTeX 的,但是现在不支持了……因此若想在 README 或者评论中插入数学公式,就得使用另外的方式。 10 | 11 | CodeCogs 提供了一个[在线 LaTeX 编辑器](https://www.codecogs.com/latex/eqneditor.php),可以将输入的数学公式转换为图片,并自动生成 HTML 代码(也支持其他格式)。 12 | 13 | 其它可以安装 Mathjax 14 | 15 | 公式居中: 16 | ``` 17 | $$ xxx $$ 18 | ``` 19 | 20 | ### VScode中的图床插件:PicGo 21 | 22 | [PicGo](https://marketplace.visualstudio.com/items?itemName=Spades.vs-picgo),用vscode编辑markdown时,可以安装这个插件,从而很方便地上传并插入图像。 23 | 24 | 操作|快捷键 25 | ---|--- 26 | Uploading an image from clipboard | Ctrl + Alt + U 27 | Uploading images from explorer | Ctrl + Alt + E 28 | Uploading an image from input box | Ctrl + Alt + O 29 | 30 | 31 | ## 表格 32 | 33 | 一个快速编辑markdown和latex表格的网站:[Tables Generator](http://www.tablesgenerator.com/latex_tables) 34 | 35 | ## 常用命令 36 | 37 | ### 字体 38 | 加粗: 39 | ``` 40 | ** 内容 ** 41 | ``` 42 | 43 | 斜体: 44 | ``` 45 | * 内容 * 46 | ``` 47 | 48 | ### 图片 49 | 设置居中和宽度: 50 | ``` 51 |
52 | ``` 53 | 54 | ``` 55 |

56 | 57 |

58 | ``` -------------------------------------------------------------------------------- /Programming/Matlab/Automatic Control Theory.md: -------------------------------------------------------------------------------- 1 | # 经典控制理论 2 | ## 控制系统微分方程的数值解 3 | Matlab提供了一个采用龙格库塔法求解微分方程数值解的函数ode113(),具有很高的计算精度: 4 | ``` 5 | [t, y] = ode113('F', tspan, y0, options) 6 | % t是时间向量; 7 | % y是与t相互对应的方程的数值解; 8 | % 'F'是对于系统微分方程的描述,一般由用户编写特定的odefile()函数; 9 | % tspan是1*2的向量,表示计算开始和结束的时间; 10 | % y0是微分方程的初始条件; 11 | % options是控制精度的可选参数,由odeset()函数来设置,常用的参数值有'RelTol'(表示1e-3精度),'AbsTol'(表示1e-6精度)。 12 | ``` 13 | odefile()函数的功能是描述系统的微分方程和一些相关参数,提供ode113()的接口: 14 | ``` 15 | function F = odefile(t, y) 16 | ``` 17 | 注意:ode113()函数只接受一阶微分方程的形式,因此对于高阶微分方程,首先要化为若干个一阶微分方程,然后再使用odefile()函数。 18 | 19 | 20 | eg: 21 | 设系统的微分运动方程为:![](https://latex.codecogs.com/png.latex?%5Cinline%20M%20%5Cfrac%7B%5Cmathrm%7Bd%7D%5E2%20x%28t%29%7D%7B%5Cmathrm%7Bd%7D%20t%7D%20+%20B%5Cfrac%7B%5Cmathrm%7Bd%7D%20x%28t%29%7D%7B%5Cmathrm%7Bd%7D%20t%7D+Kx%28t%29%20%3Df%28t%29),式中,K=20,B=5,M=1,f(t)=30: 22 | 23 | 解:将二阶微分方程化为两个一阶微分方程的格式,然后求解,令: 24 | ![](https://latex.codecogs.com/gif.latex?%5Cinline%20%5Cleft%5C%7B%5Cbegin%7Bmatrix%7D%20x_1%28t%29%20%3D%20x%28t%29%20%5C%5C%20x_2%28t%29%20%3D%20%5Cfrac%7B%5Cmathrm%7Bd%7D%20x%28t%29%7D%7B%5Cmathrm%7Bd%7D%20t%7D%20%5Cend%7Bmatrix%7D%5Cright.) 25 | 26 | 则有:![](https://latex.codecogs.com/gif.latex?%5Cinline%20%5Cleft%5C%7B%5Cbegin%7Bmatrix%7D%20%5Cfrac%7B%5Cmathrm%7Bd%7D%20x_1%28t%29%7D%7B%5Cmathrm%7Bd%7D%20x%7D%20%3D%20x_2%28t%29%20%5C%5C%20%5Cfrac%7B%5Cmathrm%7Bd%7D%20x_2%28t%29%7D%7B%5Cmathrm%7Bd%7D%20x%7D%20%3D%20%5Cfrac%7B1%7D%7BM%7D%28f%28t%29-Bx_2%28t%29-Kx_1%28t%29%29%20%5Cend%7Bmatrix%7D%5Cright.) 27 | 28 | 根据上式编写odefile()函数: 29 | ``` 30 | function xt = F(t, x) 31 | ft = 30; M = 1; B=5; K = 20; 32 | xt = [x(2); 33 | 1/M*(ft-B*x(2)-K*x(1))]; 34 | ``` 35 | 仿真程序: 36 | ``` 37 | t0 = 0; tfinal = 5; 38 | tspan = [t0, tfinal]; % 设置仿真开始和结束的时间 39 | x0 = [0, 0]; % 系统初始值 40 | options = odeset('AbsTol', [1e-6;1e-6]); % 设置仿真精度 41 | [t, x] = ode113('F', tspan, x0, options); % 微分方程求解 42 | ``` 43 | 44 | 45 | ## 传递函数 46 | 简单模型: 47 | ``` 48 | num=[1,10]; 49 | den=[1,5,4,3,2]; 50 | G=tf(num,den) 51 | ``` 52 | 53 | 零极点模型: 54 | ``` 55 | KGain=K; %系统增益K 56 | Z=[1; 2; 3]; %零点 57 | P=[4; 5; 6]; %极点 58 | G=zpk(Z,P,KGain) 59 | ``` 60 | 61 | 求传递函数的零点和极点: 62 | ``` 63 | [z, p, k] = tf2zp(num, den) 64 | ``` 65 | 求传递函数的部分分式展开: 66 | ``` 67 | [r, p, k] = residue(num, den) 68 | % r为部分分式展开的各分式系数,p是系统的极点,k是常数项 69 | ``` 70 | 根据部分分式展开式求原传递函数表达式: 71 | ``` 72 | [num, den] = residue(r, p, k) 73 | ``` 74 | 75 | ## 控制系统的时域响应 76 | ### 单位阶跃和单位脉冲响应 77 | 单位阶跃响应: 78 | ``` 79 | step(sys1, sys2, ... , t) 80 | % sys1是传递函数描述 81 | % 在一张图上绘制出系统sys1,sys2...的阶跃响应曲线,t是时间向量(可选) 82 | step(sys1, 'y-', sys2, 'b--', ... , t) 83 | % 还可以指定每个系统响应曲线的颜色线性标记等 84 | 85 | 86 | [y, t] = step(sys1, sys2, ... , t) 87 | % t为时间向量,根据时间t计算出响应的响应值y 88 | ``` 89 | 90 | 单位脉冲响应: 91 | ``` 92 | impulse(sys1, sys2, ... , t) 93 | [y, t] = impulse(sys1, sys2, ... , t) 94 | ``` 95 | 使用方法与step()一致。 96 | 97 | ### 瞬态性能指标的计算 98 | ``` 99 | sys = tf(num, den); 100 | t = 0:0.0005:20; 101 | 102 | [y, t] = step(sys, t); % 求单位阶跃响应 103 | 104 | r1 = 1; 105 | while y(r1) < 1.00001 106 | r1 = r1+1; 107 | end 108 | rise_time = (r1-1) * 0.0005; % 计算上升时间 109 | 110 | [ymax, tp] = max(y); % 计算最大输出量值 111 | peak_time = (tp-1)*0.0005; % 计算峰值时间 112 | max_overshoot = ymax - 1; % 计算超调量 113 | 114 | s = 20/0.0005; 115 | while y(s)>0.98 && y(s)<1.02 116 | s = s - 1; 117 | end 118 | settle_time = (s-1)*0.0005; % 计算调整时间(误差带宽度取2%) 119 | ``` 120 | 121 | ### 对任意输入信号的响应 122 | 绘制单输入线性时不变系统的时间相应曲线: 123 | ``` 124 | lsim(sys1, sys2, sys3, ... ,r, t) 125 | % r为任意输入信号;t为时间向量 126 | 127 | y = lsim(sys1, sys2, sys3, ... ,r, t) 128 | ``` 129 | 130 | ### 控制系统的稳定性 131 | 直接使用 tf2zp() 或者求根函数 roots() ,求出零极点即可判断系统的稳定性。 132 | 133 | ## 根轨迹 134 | ### 绘制根轨迹 135 | ``` 136 | num = conv([1 1], [1,3]); % 分子系数数组,因子相乘形式 137 | den = [1 0 0 0]; % 分母系数数组 138 | 139 | rlocus(num,den); % 绘制根轨迹 140 | ``` 141 | 使用tf函数 142 | ``` 143 | h = tf(num, den); 144 | rlocus(h); % 绘制根轨迹 145 | ``` 146 | ## 系统的频域分析 147 | ### 伯德图 148 | ``` 149 | num = [2000 2000]; 150 | den = conv([1 0.5 0], [1 14 400]); 151 | bode(num, den) 152 | grid 153 | ``` 154 | 如果希望绘制频率范围从0.1rad/s到100rad/s的伯德图: 155 | ``` 156 | num = [2000 2000]; 157 | den = conv([1 0.5 0], [1 14 400]); 158 | w = logspace(-1,2,100) 159 | bode(num, den, w) 160 | grid 161 | ``` 162 | 163 | ### 极坐标图 164 | ``` 165 | num = [0 20 20 10]; 166 | den = conv([1 1 0], [1 10]); 167 | nyquist(num, den) 168 | ``` 169 | 只绘制w>0部分: 170 | ``` 171 | num = [0 20 20 10]; 172 | den = conv([1 1 0], [1 10]); 173 | [re, im] = nyquist(num, den); 174 | plot(re, im) 175 | axis ([-2 3 -3 1]) 176 | grid 177 | ``` 178 | 179 | ### 绘制具有延迟环节的系统频率特性 180 | #### 伯德图 181 | ![传递函数](https://latex.codecogs.com/gif.latex?G_k%28s%29%20%3D%20%5Cfrac%7Be%5E%7B-%20s%7D%7D%7Bs%28s+1%29%28s+2%29%29%29%7D) 182 | ``` 183 | num = [1]; 184 | den = conv([1 1 0], [1 2]); 185 | w = logspace(-2, 1, 100); 186 | [mag, phase, w] = bode(num, den, w); % 计算频率特性的幅值和相角 187 | 188 | %利用相频特性求加上延迟环节后的相频特性 189 | phase = phase - w*57.3 190 | 191 | %绘制幅频特性 192 | subplot(211),semilogx(w, 20*log10(mag)); 193 | v = [0.01, 10, -60, 40]; axis(v); 194 | grid 195 | 196 | %绘制相频特性 197 | subplot(212),semilogx(w, phase); 198 | axis([0.01 10 -270 -90]) 199 | grid 200 | ``` 201 | #### 极坐标图 202 | ``` 203 | num = [1]; 204 | den = conv([1 1 0], [1 2]); 205 | w = logspace(-2, 1, 100); 206 | [mag, phase, w] = bode(num, den, w); % 计算频率特性的幅值和相角 207 | 208 | %利用相频特性求加上延迟环节后的相频特性 209 | phase = phase - w*57.3 210 | 211 | %用极坐标曲线绘制函数画出Nyquist图 212 | polar(phase*pi/180, mag) 213 | axis([-2.5 1 -2 1]) 214 | grid 215 | ``` 216 | 217 | ### 求系统的稳定裕度 218 | ``` 219 | num = [2000 2000]; 220 | den = conv([1 0.5 0], [1 14 400]); 221 | margin(num,den) %画伯德图并计算幅值裕度和相位裕度 222 | ``` 223 | 224 | # 现代控制理论 225 | ## 建立系统模型 226 | 将传递函数转换为状态空间表达式: 227 | ``` 228 | [A, B, C, D] = tf2ss(num, den) % 分子多项式和分母多项式的系数 229 | [A, B, C, D] = zp2ss(z, p, k) % 系统的零点、极点、增益 230 | [A, B, C, D] = ssdata(sys) % sys为系统的传递函数表达式 231 | ``` 232 | 233 | 由状态空间表达式求解传递函数: 234 | ``` 235 | [num, den] = ss2tf(A, B, C, D) 236 | [z, p, k] = ss2zp(A, B, C, D) 237 | ``` 238 | ## 系统的时间响应 239 | 计算给定时刻的状态转移矩阵: 240 | ``` 241 | phi = expm(A*t) % t为求取相应时间的时刻,phi为t时刻的矩阵指数函数 242 | ``` 243 | 计算系统的状态响应和输出响应: 244 | ``` 245 | [y, x] = lsim(A, B, C, D, u, t, x0) 246 | % y为t0~t时刻的输出响应,x为t0~t时刻的状态响应,u为t0~t时刻的系统输入,t为t0~t时刻的时间向量,x0为系统初始状态 247 | ``` 248 | 249 | ## 能控性能观性 250 | 求取系统的能控性判别矩阵Qc; 251 | ``` 252 | Qc = ctrb(A, B) % A为系统矩阵,B为输入矩阵 253 | raQc = rank(Qc) % 判断Qc是否满秩 254 | ``` 255 | 求取系统的能观性判别矩阵Qo: 256 | ``` 257 | Qo = obsv(A, C) % A为系统矩阵,C为输出矩阵 258 | ``` 259 | ## 设计状态反馈和状态观测器 260 | ### 设计状态反馈 261 | 求解极点配置的反馈增益矩阵: 262 | ``` 263 | K = acker(A, B, p) 264 | % A为系统矩阵,B为输入矩阵,p是由期望的闭环极点组成的行向量 265 | % 仅适用于SISO系统的极点配置,期望的闭环极点中可以包含多重极点 266 | ``` 267 | ``` 268 | K = place(A, B, p) 269 | % 既适用于SISO系统的极点配置,也适用于MIMO系统的极点配置,但要求在期望的闭环极点中,极点的重数不大于矩阵B的秩。所以在SISO系统的极点配置中使用place()不能包含重极点 270 | ``` 271 | 272 | ### 设计状态观测器 273 | 观测器的设计与状态反馈的极点配置具有对偶性,所以可以直接求解其对偶系统的状态反馈矩阵K,然后将其转置,得到观测器的增益矩阵G: 274 | ``` 275 | K = acker(A', C', p) or K = place(A', C', p) 276 | G = K' 277 | ``` -------------------------------------------------------------------------------- /Programming/Matlab/Linear algebra.md: -------------------------------------------------------------------------------- 1 | # 计算行列式 2 | ``` 3 | D = det(A) 4 | ``` 5 | ### 计算带符号变量的行列式 6 | ``` 7 | syms a b c d; 8 | 9 | A = [1 a a^2 a^3; 10 | 1 b b^2 b^3; 11 | 1 c c^2 c^3; 12 | 1 d d^2 d^3]; 13 | 14 | D = det(A); % 该命令仅仅是按行列式定义展开 15 | factor(D) % 对展开的行列式进行因式分解 16 | ``` 17 | 18 | ### 解方程 19 | ``` 20 | syms x; 21 | 22 | A = [3 2 1 1; 23 | 3 2 2-x^2 1; 24 | 5 1 3 2; 25 | 7-x^2 1 3 2]; 26 | 27 | d = det(A); 28 | x = solve(d) 29 | ``` 30 | # 生成特殊矩阵 31 | ### 生成对角矩阵 32 | ``` 33 | diag(A) % 若A是一个矩阵,则提取A的对角元素生成一个列矩阵;若A是一个行矩阵或列矩阵,则以该矩阵的元素为对角元素生成一个对角矩阵 34 | ``` 35 | ### 生成单位矩阵 36 | ``` 37 | eye(n,n) 38 | ``` 39 | 40 | # 矩阵运算 41 | ``` 42 | A' % 矩阵A的转置 43 | A/B % AB^(-1) 44 | A\B % A^(-1)B 45 | reshape(a,m,n) % 在元素总数不变的情况下,将矩阵a改写成m行n列 46 | inv(A) % 求矩阵的逆 47 | tril(A) % 提取矩阵的下三角部分,生成下三角矩阵 48 | triu(A) % 提取矩阵的上三角部分,生成上三角矩阵 49 | [L,U,P] = lu(A) % 求矩阵的LU分解 50 | rank(A) % 求矩阵的秩 51 | 52 | det(A)*inv(A) % 求矩阵的伴随矩阵 53 | ``` 54 | 55 | # 向量运算 56 | ``` 57 | dot(a,b) % 数量积 58 | cross(a,b) % 向量积 59 | ``` 60 | 61 | # 线性方程组的求解 62 | ``` 63 | rref(A) % 求矩阵A的简化行阶梯型矩阵 64 | null(A) % 产生齐次方程组Ax=0的正交且单位化的基础解系 65 | null(A,'r') % 产生齐次方程组Ax=0的用最小整数表示各分量的基础解系 66 | ``` 67 | ## 求解Ax=b 68 | ``` 69 | A = [1 1 -3 -1; 70 | 3 -1 -3 4; 71 | 1 5 -9 -8]; 72 | b = [1;4;0]; 73 | 74 | Ab = [A b]; 75 | 76 | jtx_matrix = rref(Ab) % 化为简化行阶梯型矩阵 77 | ``` 78 | ## 求解Ax=0 79 | ``` 80 | A = [1 2 4 -3; 81 | 3 5 6 -4; 82 | 4 5 -2 3; 83 | 3 8 24 -19]; 84 | 85 | null(A) 86 | ``` 87 | 88 | # 矩阵特征值、特征向量 89 | ``` 90 | eig(A) % 计算A的特征值 91 | 92 | [V,D] = eig(A) % 计算矩阵A的特征向量及特征值,对角矩阵D是特征值做对角元素,相应的特征向量生成矩阵V 93 | 94 | poly(A) % 当A是一个方阵时,计算矩阵a的特征多项式,显示以方阵A的特征多项式的系数为分量做成的一个向量(次数由高到低) 95 | 96 | eigshow(A) % 显示2行2列矩阵A的特征值与特征向量 97 | ``` 98 | 99 | # 向量组的正交化 100 | ``` 101 | orth(a) % 当矩阵A的列向量组线性无关时,生成与A的列向量组等价的正交向量组; 102 | 当矩阵A的列向量组线性相关时,生成与A的列向量组的极大线性无关组等价的正交向量组 103 | ``` 104 | 105 | 106 | -------------------------------------------------------------------------------- /Programming/Matlab/More.md: -------------------------------------------------------------------------------- 1 | # collect() 合并同类项 2 | ``` 3 | syms a; 4 | f = a^2 + a^2; 5 | collect(f) 6 | ``` 7 | 8 | # factor() 因式分解 9 | ``` 10 | syms a; 11 | f = a^2 + a; 12 | factor(f) 13 | ``` 14 | 15 | # inline() 构造函数 16 | 构造函数x^2: 17 | ``` 18 | h = inline('x^2'); 19 | ``` 20 | 计算x=2时h的值: 21 | ``` 22 | h(2) 23 | ``` 24 | 25 | 26 | 27 | 28 | # polyval() 多项式的值计算 29 | ``` 30 | y = polyval(p,x) % 计算多项式p在x的每个点处的值。参数 p 是长度为 n+1 的向量,其元素是 n 次多项式的系数(降幂排序) 31 | ``` 32 | 33 | # polyvalm() 矩阵多项式的值计算 34 | ``` 35 | Y = polyvalm(p,X) % 以矩阵方式返回多项式 p 的计算值 36 | ``` 37 | 例如计算 38 | ![](https://latex.codecogs.com/gif.latex?p%28X%29%20%3D%20a_3X%5E3+%20a_2X%5E2%20+%20a_1X%20+%20a_0),则p = [a3, a2, a1, a0], X为矩阵。 39 | 40 | # roots() 求有理多项式方程的根 41 | ``` 42 | r = roots(d) 43 | % r为代数方程的根, d为代数方程的系数降幂排列行向量 44 | ``` 45 | 46 | # syms 定义符号变量 47 | ``` 48 | syms a b; 49 | 50 | syms a real; % 定义a是实数 51 | 52 | syms a positive; % 定义a是正数 53 | ``` -------------------------------------------------------------------------------- /Programming/Matlab/Probability Theory.md: -------------------------------------------------------------------------------- 1 | # 常见分布 2 | 3 | 字符 | 分布名称 4 | ----|-------- 5 | bino | 二项分布 6 | geo | 几何分布 7 | poiss | 泊松分布 8 | unif | 均匀分布 9 | exp | 指数分布 10 | norm | 正态分布 11 | chi2 | 卡方分布 12 | logn | 对数正态分布 13 | f | F分布 14 | t | T分布 15 | 16 | Matlab为每一种分布提供了5类命令函数: 17 | 18 | 命令|含义 19 | ---|--- 20 | pdf | 概率密度 21 | cdf | 概率分布函数(累计概率) 22 | inv | 逆概率分布函数 23 | rnd | 生成相应分布的随机数 24 | stat | 均值与方差 25 | 26 | 当需要一种分布的某一类命令函数时,只要将分布名称后缀命令函数字符并输入命令参数即可,例如: 27 | ``` 28 | binopdf(x,n,p) % 计算服从参数为n,p的二项分布的随机变量 29 | ``` 30 | 31 | # 随机数 32 | 分布名称字符+rnd,例如: 33 | ``` 34 | unifrnd(a,b) % 表示产生[a,b]上均匀分布的随机数 35 | ``` 36 | 0-1上的随机数: 37 | ``` 38 | rand(m,n) % m*n维 39 | ``` 40 | 41 | # 统计命令 42 | 命令|含义 43 | ---|--- 44 | mean(x) | 样本均值 45 | std(x) | 样本标准差 46 | var(x) | 样本方差 47 | conv(x,y) | 样本协方差 48 | corrcoef(x,y) | 样本相关系数 49 | hist(x) | 直方图 50 | min(x) | 最小值 51 | max(x) | 最大值 52 | median(x) | 中位数 53 | sort(x) | 升序排列 54 | sum(x) | 元素求和 55 | fix(x) | 取整部 56 | 57 | # 计算置信区间 58 | ``` 59 | [muhat, sigmahat, muci, sigmaci] = normfit(X, a) 60 | ``` 61 | 在显著性水平a下数据X的有关参数:muhat是X的均值的点估计值,sigmahat是均方差(标准差)的点估计值,muci是均值的区间估计,sigmaci是均方差的区间估计。 62 | -------------------------------------------------------------------------------- /Programming/Python/More.md: -------------------------------------------------------------------------------- 1 | # More 2 | 3 | ## copy 4 | a = b.copy() # 可以不用import copy 5 | 6 | ## enumerate() 同时返回数据下标和数据 7 | enumerate() 函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中。 8 | ``` 9 | for i, element in enumerate(seq): 10 | print(i, element) 11 | 12 | OUTPUT: 13 | 0, seq[0] 14 | 1, seq[1] 15 | ...... 16 | ``` 17 | 18 | ## iter() next() 迭代 19 | [python中的iter()函数与next()函数](https://blog.csdn.net/xun527/article/details/76652189) 20 | 21 | ## random 22 | 23 | ``` 24 | import random 25 | 26 | # 生成随机整数 27 | r = random.randint(a, b) # [a, b] 区间内的随机整数 28 | ``` 29 | 30 | ## 分离文件名和路径 31 | 32 | ``` 33 | import os 34 | 35 | # 分离路径和文件名 36 | file_full_path = '/home/mingrui/a.txt' 37 | (filepath, filename_ex) = os.path.split(file_full_path) 38 | # 分离文件名中的名字和后缀 39 | (filename, extension) = os.path.splitext(filename_ex) 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /Programming/Python/Picture_Plot/matplotlib_pyplot.md: -------------------------------------------------------------------------------- 1 | # import matplotlib.pyplot as plt 2 | 3 | ## 基础:显示图片 4 | ```python 5 | # 新建一个图片 6 | plt.figure() 7 | 8 | # 添加图片内容 9 | ...... 10 | 11 | # 显示图片 (图片窗口弹出后,不关闭窗口,程序不会继续运行) 12 | plt.show() 13 | ``` 14 | 15 | ## color表 16 | 17 | https://finthon.com/matplotlib-color-list/ 18 | 19 | ## 字体调节 20 | 21 | [参考](https://zhuanlan.zhihu.com/p/35983270) 22 | 23 | ``` 24 | from matplotlib import rcParams 25 | from matplotlib.font_manager import FontProperties 26 | 27 | # 推荐设置 28 | params={‘font.family':'serif', 29 | 'font.serif':'Times New Roman', 30 | 'font.style':'italic', 31 | 'font.weight':'normal', #or 'bold' 32 | 'font.size':'medium',#or large,small 33 | } 34 | rcParams.update(params) 35 | 36 | # 面向对象使用FrontProperties 37 | font0=FontProperties() 38 | font0.set_size('medium') 39 | font0.set_family('serif') 40 | font0.set_style('normal') 41 | font0.set_variant('normal') 42 | font0.set_stretch('normal') 43 | font0.set_weight('blod') 44 | ``` 45 | 46 | 47 | 48 | ## 折线图 & 设置曲线label 49 | 50 | ```python 51 | plt.plot(x_data, y_data, '--', label='LABELNAME') 52 | 53 | # 设置曲线的透明度 54 | plt.plot(x, y, 'r-', alpha=0.7) 55 | 56 | plt.legend(loc="upper right") # 显示曲线label, loc="upper right"表示label显示在右上角 57 | ``` 58 | 线型: 59 | ``` 60 | '--': 虚线 61 | ``` 62 | 63 | ## 散点图 64 | ``` 65 | plt.scatter(x_data, y_data) 66 | ``` 67 | 68 | ## 显示image 69 | ``` 70 | plt.grid(False) 71 | plt.xticks([]) 72 | plt.yticks([]) 73 | 74 | plt.imshow(img, cmap=plt.cm.binary) 75 | ``` 76 | 77 | 78 | 79 | ## 设置图片label:内容 & 颜色 80 | ``` 81 | plt.xlabel("{} {:2.0f}% ({})".format(class_names[predicted_label], 82 | 100*np.max(predictions_array), 83 | class_names[true_label]), 84 | color=color) 85 | ``` 86 | ## 设置坐标轴 87 | ```python 88 | # 设置是否显示刻度 89 | ax = plt.gca() 90 | ax.axes.xaxis.set_ticklabels([]) 91 | ax.axes.yaxis.set_ticklabels([]) 92 | ax.axes.xaxis.set_ticklabels([]) 93 | ax.axes.zaxis.set_ticklabels([]) 94 | # or 95 | plt.xticks([]) 96 | plt.yticks([]) 97 | 98 | 99 | 100 | # 设置范围 101 | plt.xlim([min, max]) 102 | plt.ylim([min, max]) 103 | ``` 104 | 105 | 106 | ## 同时显示多张图片(subplot) 107 | ``` 108 | plt.figure(figsize=(10,10)) 109 | for i in range(25): 110 | plt.subplot(5,5,i+1) 111 | plt.xticks([]) 112 | plt.yticks([]) 113 | plt.grid(False) 114 | plt.imshow(train_images[i], cmap=plt.cm.binary) 115 | plt.xlabel(class_names[train_labels[i]]) 116 | plt.show() 117 | ``` 118 | 119 | ## 画直方图 & 设置直方图颜色 120 | ``` 121 | plt.grid(False) 122 | plt.xticks(range(10)) 123 | plt.yticks([]) 124 | 125 | thisplot = plt.bar(range(10), predictions_array, color="#777777") 126 | plt.ylim([0, 1]) 127 | 128 | predicted_label = np.argmax(predictions_array) 129 | 130 | thisplot[predicted_label].set_color('red') 131 | thisplot[true_label].set_color('blue') 132 | ``` 133 | 134 | ## 频率统计图 135 | ``` 136 | plt.hist(data, bins=) 137 | ``` 138 | * bins为直方图的柱数 139 | 140 | ## 绘制 x y z 轴比例相同的 三维图 141 | 142 | ```python 143 | import matplotlib.pyplot as plt 144 | from mpl_toolkits.mplot3d import Axes3D 145 | 146 | def set_aspect_equal_3d(ax): 147 | """Fix equal aspect bug for 3D plots.""" 148 | 149 | xlim = ax.get_xlim3d() 150 | ylim = ax.get_ylim3d() 151 | zlim = ax.get_zlim3d() 152 | 153 | from numpy import mean 154 | xmean = mean(xlim) 155 | ymean = mean(ylim) 156 | zmean = mean(zlim) 157 | 158 | plot_radius = max([abs(lim - mean_) 159 | for lims, mean_ in ((xlim, xmean), 160 | (ylim, ymean), 161 | (zlim, zmean)) 162 | for lim in lims]) 163 | 164 | ax.set_xlim3d([xmean - plot_radius, xmean + plot_radius]) 165 | ax.set_ylim3d([ymean - plot_radius, ymean + plot_radius]) 166 | ax.set_zlim3d([zmean - plot_radius, zmean + plot_radius]) 167 | 168 | # 使用: 169 | fig = plt.figure() 170 | ax = fig.gca(projection='3d') 171 | ax.plot(x, y, z) 172 | set_aspect_equal_3d(ax) 173 | plt.show() 174 | ``` 175 | 176 | -------------------------------------------------------------------------------- /Programming/Python/Picture_Plot/seaborn.md: -------------------------------------------------------------------------------- 1 | # import seaborn as sns 2 | 3 | ## 快速绘制数据集中几对列的联合分布 4 | ``` 5 | sns.pairplot(dataset[["MPG", "Cylinders", "Displacement", "Weight"]], diag_kind="kde") 6 | # dataset格式为pandas 7 | ``` 8 | 9 | ## 绘制多次实验的平均值 10 | 11 | ![](https://pic4.zhimg.com/80/v2-52a9c2b8f9a652e08c851e4a327c9857_720w.jpg) 12 | 13 | [参考](https://zhuanlan.zhihu.com/p/75477750) 14 | 15 | ```python 16 | sns.tsplot(time=time, data=x1, color="r", condition="LABEL_NAME") 17 | # x1 (numpy) 每一行是一次实验的序列,多次试验的行堆叠起来行车x1矩阵 18 | ``` 19 | 20 | ## 对数据进行移动平均 21 | 22 | ```python 23 | # sm 是移动平均的窗大小、d是需要移动平均的数据 24 | y = np.ones(sm)*1.0/sm 25 | d = np.convolve(y, d, "same") 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /Programming/Python/numpy.md: -------------------------------------------------------------------------------- 1 | # import numpy as np 2 | 3 | ## 基础属性 4 | ``` 5 | Array = np.array([[1,2,3], [2,3,4]]) 6 | Array.ndim #维度 7 | Array.shape #行数和列数 8 | Array.size #元素个数 9 | 10 | a = np.array([2, 23, 4]) 11 | a = np.array([2, 23, 4], dtype = np.int) #int64 12 | dtype = np.int32 #int32 13 | dtype = np.float 14 | dtype = np.float32 15 | 16 | 17 | a = np.zeros((3,4)) 18 | a = np.ones((3,4), dtype = np.int) 19 | a = np.empty((3,4)) 20 | 21 | a = arange(10,20,2) 22 | a = arange(12).reshape(3,4) 23 | 24 | a = np.linspace(1,10,20) 25 | ``` 26 | 27 | ## 基础运算 28 | ``` 29 | c = a + b 30 | c = a - b 31 | 32 | c = a*b #对应元素相乘 33 | 34 | c = a**b #乘方 35 | 36 | c = np.sin(a) 37 | 38 | a = b<3 #判断,a为bool型 39 | 40 | 41 | # 矩阵乘法 42 | c = np.dot(a, b) 43 | c = a.dot(b) 44 | c = np.matmul(a, b) 45 | 46 | np.sum(a, axis=0) # 每个行向量取均值 47 | np.sum(a, axis=1) # 每个列向量取均值 48 | 最终的结果都为向量,如果要表达成矩阵形式,需要reshape或keepdim 49 | 50 | np.min 51 | np.max 52 | np.mean(A) 53 | np.average(A) 54 | A.mean() 55 | A.median() 56 | 57 | 58 | np.cumsum(A) #累加 59 | np.diff(A) #累差分:每一行中后一项与前一项之和 60 | np.nonzeros(A) #将所有非零元素的行坐标放在一个矩阵中,所有纵坐标放在一个矩阵中 61 | 62 | np.sort(A) #每个行向量中的元素从小到大排序 63 | 64 | A.T #矩阵转置 65 | 66 | np.clip(A, min, max) 将矩阵中的元素,小于设定最小值的令其等于最小值,大于设定最大值的令其等于最大值 67 | ``` 68 | 69 | ## 加载 txt 文件 70 | 71 | [参考](https://blog.csdn.net/ACID_lv_ing/article/details/87092714) 72 | 73 | ``` 74 | file = np.loadtxt('file_name', dtype=float) # 默认就是 float 75 | 76 | # txt 文件中的数据以 , 作为分隔 77 | file = np.loadtxt('file_name', delimiter=',') 78 | ``` 79 | 80 | ## 拼接、合并 81 | 82 | ``` 83 | # 水平合并 84 | C = np.concatenate((A, B), axis=1) 85 | C = np.hstack((A, B)) 86 | 87 | # 垂直合并 88 | C = np.concatenate((A, B), axis=0) 89 | C = np.vstack((A, B)) 90 | ``` 91 | 92 | -------------------------------------------------------------------------------- /Programming/Python/pandas.md: -------------------------------------------------------------------------------- 1 | # import pandas as pd 2 | 3 | ## 基础操作 4 | 取出数据集中的一列,并从数据集中删除此列: 5 | ``` 6 | column = dataset.pop('its_name') 7 | # 注意column的shape为(row_num,)。 8 | ``` 9 | 添加新列: 10 | ``` 11 | dataset['new_name'] = new_column 12 | ``` 13 | 14 | 15 | ## 导入csv数据集 16 | ``` 17 | raw_dataset = pd.read_csv(dataset_path, names=column_names, 18 | na_values = "?", comment='\t', 19 | sep=" ", skipinitialspace=True) 20 | ``` 21 | 22 | ## 剔除数据中的未知值 23 | 删除带有未知值(na)的行: 24 | ``` 25 | dataset.dropna() 26 | ``` 27 | ## 打印数据集的最后5行 28 | ``` 29 | print(dataset.tail()) 30 | ``` 31 | 32 | 打印数据集的前5行: 33 | ``` 34 | df.head() 35 | ``` 36 | 37 | ## 将数据集拆分成两部分:训练数据集和测试数据集 38 | ``` 39 | train_dataset = dataset.sample(frac=0.8,random_state=0) 40 | test_dataset = dataset.drop(train_dataset.index) 41 | ``` 42 | 43 | ## 查看数据集总体的数据统计 44 | ``` 45 | train_stats = train_dataset.describe() 46 | # train_stats的每一列是一个column的各项数据统计值 47 | ``` 48 | 49 | ## 数据规范化 50 | ``` 51 | def norm(x): 52 | return (x - train_stats['mean']) / train_stats['std'] # 利用之前计算的总体数据统计 53 | 54 | normed_train_data = norm(train_dataset) 55 | normed_test_data = norm(test_dataset) 56 | ``` 57 | 58 | ## 将object转换为离散数值 59 | eg: transfer ['good', 'ok', 'bad'] to [0, 1, 2] 60 | ``` 61 | df['col_name'] = pd.Categorical(df['col_name']) 62 | df['col_name'] = df.col_name.cat.codes 63 | ``` -------------------------------------------------------------------------------- /Programming/Python/sklearn.md: -------------------------------------------------------------------------------- 1 | # sklearn 2 | 3 | ## PCA 4 | 5 | ```python 6 | from sklearn.decomposition import PCA 7 | ``` 8 | 9 | [官方教程](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html#sklearn.decomposition.PCA.get_params) 10 | 11 | [参考文章](https://www.cnblogs.com/wj-1314/p/10144700.html) -------------------------------------------------------------------------------- /Programming/Python/tensorflow.md: -------------------------------------------------------------------------------- 1 | # import tensorflow as tf 2 | 3 | 推荐参考教程: 4 | 5 | [简单粗暴 TensorFlow 2.0 | A Concise Handbook of TensorFlow 2.0](https://tf.wiki/index.html#tensorflow-2-0-a-concise-handbook-of-tensorflow-2-0) 6 | 7 | [TensorFlow官方教程](https://tensorflow.google.cn/tutorials/) 8 | 9 | tf 2.0 API: 10 | 11 | [TensorFlow 2.0 API](https://tensorflow.google.cn/api_docs/python/tf) 12 | 13 | ## 构建模型总体流程: 14 | ``` 15 | model = tf.keras.Sequential() # keras建立一个网络 16 | model.add(hub_layer) # 添加一个预训练层 17 | model.add(tf.keras.layers.Dense(nodes_num, activation='')) # 添加层 18 | model.add(tf.keras.layers.Dense(nodes_num, activation='')) 19 | 20 | model.summary() # 输出模型概览 21 | 22 | model.compile(optimizer='', loss='', metrics=['']) # 模型优化器 23 | 24 | train_history = model.fit(train_data, train_label, epochs=epoch_num, validation_split= , verbose=0) # 喂数据,训练 25 | 26 | test_loss, test_acc = model.evaluate(test_data, test_label, verbose=2) # 用test set评估 27 | 28 | test_prediction = model.predict(test_data) # 用训练好的模型进行预测 29 | ``` 30 | 31 | ## 添加layer 32 | ``` 33 | model.add() 34 | ``` 35 | 36 | ### 不同类的layer 37 | 讲数据集展开成一个一个数据的层: 38 | ``` 39 | tf.keras.layers.Flatten(input_shape=(28, 28)) 40 | ``` 41 | 42 | 全连接层: 43 | ``` 44 | tf.keras.layers.Dense(nodes_num, activation='relu') 45 | ``` 46 | 47 | Dropout层: 48 | ``` 49 | tf.keras.layers.Dropout(0.2) 50 | ``` 51 | 52 | ### regularization 53 | ``` 54 | kernel_regularizer=keras.regularizers.l2(0.001) 55 | ``` 56 | 57 | ### activation function 58 | ``` 59 | activation = 'relu' 60 | activation = 'sigmoid' 61 | activation = 'softmax' 62 | ``` 63 | 64 | 65 | ## model.compile() 66 | ``` 67 | model.compile(optimizer='', loss='', metrics=['']) 68 | ``` 69 | ### optimizer 优化方法 70 | ``` 71 | optimizer = tf.keras.optimizers.RMSprop(0.001) 72 | optimizer='adam' 73 | ``` 74 | 75 | ### loss 76 | ``` 77 | loss = 'mse' 78 | loss = 'binary_crossentropy' 79 | ``` 80 | 81 | ### metrics 度量指标 82 | ``` 83 | metrics = ['mae', 'mse'] 84 | metrics = ['accuracy', 'binary_crossentropy'] 85 | ``` 86 | 87 | ## model.fit() 88 | ``` 89 | history = model.fit( 90 | train_data, train_labels, 91 | epochs=EPOCHS, validation_split = 0.2, verbose=0, 92 | callbacks=[]) 93 | ``` 94 | [绘制训练过程](https://tensorflow.google.cn/tutorials/keras/regression#%E8%AE%AD%E7%BB%83%E6%A8%A1%E5%9E%8B) 95 | 96 | ### verbose 97 | ``` 98 | verbose:日志显示 99 | verbose = 0 为不在标准输出流输出日志信息 100 | verbose = 1 为输出进度条记录 101 | verbose = 2 为每个epoch输出一行记录 102 | 注意: 默认为 1 103 | ``` 104 | 105 | ### validation_data 106 | 使用test set进行训练过程中的评估: 107 | ``` 108 | validation_data=(test_data, test_labels) 109 | ``` 110 | 111 | ### callbacks 112 | #### 可以在每个完成的时期执行一次自定义函数 113 | ``` 114 | callbacks=[PrintDot()] 115 | 116 | 其中: 117 | class PrintDot(keras.callbacks.Callback): 118 | def on_epoch_end(self, epoch, logs): 119 | if epoch % 100 == 0: print('') 120 | print('.', end='') 121 | ``` 122 | #### Early stopping 提前退出 123 | 如果经过一定数量的 epochs 后没有改进,则自动停止训练: 124 | ``` 125 | early_stop = keras.callbacks.EarlyStopping(monitor='val_loss', patience=10) 126 | 127 | callbacks = [early_stop] 128 | ``` 129 | 130 | ## model.evaluate() 131 | ``` 132 | test_loss, test_acc = model.evaluate(test_data, test_label, verbose=2) 133 | ``` 134 | 注意test_acc要和model.fit(metrics=[])对应起来 135 | 136 | ## model.predict() 137 | ``` 138 | test_prediction = model.predict(test_data) 139 | ``` 140 | 注意:test_prediction的格式为array 141 | 142 | 143 | 144 | *** 145 | ## ML basics with Keras 146 | ### MNIST手写数字网络搭建 147 | [初学者的 TensorFlow 2.0 教程](https://tensorflow.google.cn/tutorials/quickstart/beginner) 148 | 149 | * 构建一个简单的模型 150 | 151 | ### 搭建一个基础的分类网络:衣服分类 152 | [Basic classification: Classify images of clothing](https://tensorflow.google.cn/tutorials/keras/classification) 153 | 154 | ### 用 tf.data 加载 CSV 数据 155 | [用 tf.data 加载 CSV 数据](https://tensorflow.google.cn/tutorials/load_data/csv) 156 | 157 | ### 文本分类 158 | [使用 Keras 和 Tensorflow Hub 对电影评论进行文本分类](https://tensorflow.google.cn/tutorials/keras/text_classification_with_hub) 159 | 160 | * tensorflow_hub: 提供预训练模型 161 | * 文本嵌入 text embedding 162 | * model.summary() # 输出模型概览 163 | 164 | ### 回归 165 | [Basic regression: Predict fuel efficiency](https://tensorflow.google.cn/tutorials/keras/regression) 166 | 167 | * pandas 数据集处理 基础使用 168 | * csv 数据导入 169 | * 删除未知值所在的行 170 | * 拆分训练数据集和测试数据集 171 | * 查看总体的数据统计 172 | * 数据规范化 173 | * 快速查看训练集中几对列的联合分布 (using seaborn) 174 | * 通过为每个完成的时期打印一个点来显示训练进度 175 | * 在 history 对象中记录训练和验证的准确性 176 | * [可视化训练的训练进度](https://tensorflow.google.cn/tutorials/keras/regression#%E8%AE%AD%E7%BB%83%E6%A8%A1%E5%9E%8B) 177 | 178 | * Early stopping: 如果经过一定数量的 epochs 后没有改进,则自动停止训练 179 | 180 | ### Overfit & Underfit 181 | [Explore overfit and underfit](https://tensorflow.google.cn/tutorials/keras/overfit_and_underfit) 182 | * [multi-hot encoding](https://tensorflow.google.cn/tutorials/keras/overfit_and_underfit#download_the_imdb_dataset) 183 | * [loss='binary_crossentropy'](https://tensorflow.google.cn/tutorials/keras/overfit_and_underfit#demonstrate_overfitting) 184 | * [L1/L2 regularization](https://tensorflow.google.cn/tutorials/keras/overfit_and_underfit#add_weight_regularization) 185 | * [Dropout layer](https://tensorflow.google.cn/tutorials/keras/overfit_and_underfit#add_dropout) 186 | 187 | ### 保存和恢复模型 188 | [保存和恢复模型](https://tensorflow.google.cn/tutorials/keras/save_and_load) 189 | * [在训练期间保存模型权重 & 新模型加载权重](https://tensorflow.google.cn/tutorials/keras/save_and_load#%E5%9C%A8%E8%AE%AD%E7%BB%83%E6%9C%9F%E9%97%B4%E4%BF%9D%E5%AD%98%E6%A8%A1%E5%9E%8B%EF%BC%88%E4%BB%A5_checkpoints_%E5%BD%A2%E5%BC%8F%E4%BF%9D%E5%AD%98%EF%BC%89) 190 | * [手动保存权重](https://tensorflow.google.cn/tutorials/keras/save_and_load#%E6%89%8B%E5%8A%A8%E4%BF%9D%E5%AD%98%E6%9D%83%E9%87%8D) 191 | * [保存整个模型](https://tensorflow.google.cn/tutorials/keras/save_and_load#%E4%BF%9D%E5%AD%98%E6%95%B4%E4%B8%AA%E6%A8%A1%E5%9E%8B) 192 | 193 | ## Load and preprocess data 194 | 195 | ### CSV 196 | [用 tf.data 加载 CSV 数据](https://tensorflow.google.cn/tutorials/load_data/csv) 197 | 198 | ### Numpy 199 | [使用 tf.data 加载 NumPy 数据](https://tensorflow.google.cn/tutorials/load_data/numpy) 200 | * [打乱和批次化数据集](https://tensorflow.google.cn/tutorials/load_data/numpy#%E6%89%93%E4%B9%B1%E5%92%8C%E6%89%B9%E6%AC%A1%E5%8C%96%E6%95%B0%E6%8D%AE%E9%9B%86) & [tf.data.Dataset.shuffle(buffer_size)中buffer_size的理解](https://www.jianshu.com/p/1285036e314c) 201 | 202 | ### Pandas 203 | [使用 tf.data 加载 pandas dataframes 204 | ](https://tensorflow.google.cn/tutorials/load_data/pandas_dataframe) 205 | * [使用 pandas 读取csv数据 206 | ](https://tensorflow.google.cn/tutorials/load_data/pandas_dataframe#%E4%BD%BF%E7%94%A8_pandas_%E8%AF%BB%E5%8F%96%E6%95%B0%E6%8D%AE) 207 | * [将某列转换为离散数值](https://tensorflow.google.cn/tutorials/load_data/pandas_dataframe#%E4%BD%BF%E7%94%A8_pandas_%E8%AF%BB%E5%8F%96%E6%95%B0%E6%8D%AE) 208 | 209 | ### Images 210 | [用 tf.data 加载图片](https://tensorflow.google.cn/tutorials/load_data/images) 211 | 212 | ## Estimator 213 | [预创建的 Estimators](https://tensorflow.google.cn/tutorials/estimator/premade) 214 | 215 | ## Customization 定制化 216 | ### Tensors and operations 217 | [Customization basics: tensors and operations](https://tensorflow.google.cn/tutorials/customization/basics) 218 | * [Tensors的基础运算](https://tensorflow.google.cn/tutorials/customization/basics#tensors) 219 | * [Tensor和numpy之间的转换](https://tensorflow.google.cn/tutorials/customization/basics#numpy_compatibility) 220 | * [tf.data.Dataset API的各种使用](https://tensorflow.google.cn/tutorials/customization/basics#datasets) 221 | 222 | ### Custom layers 223 | [Custom layers:定制自己的special模型](https://tensorflow.google.cn/tutorials/customization/custom_layers) 224 | * [使用layer进行运算](https://tensorflow.google.cn/tutorials/customization/custom_layers#layers_common_sets_of_useful_operations) 225 | * [定制特殊的layers](https://tensorflow.google.cn/tutorials/customization/custom_layers#implementing_custom_layers) 226 | * [Resnet Block的建立方法](https://tensorflow.google.cn/tutorials/customization/custom_layers#models_composing_layers) 227 | * [简单网络堆叠:使用tf.keras.Sequential](https://tensorflow.google.cn/tutorials/customization/custom_layers#models_composing_layers) 228 | 229 | ### Automatic differentiation 230 | [Automatic differentiation and gradient tape](https://tensorflow.google.cn/tutorials/customization/autodiff) 231 | * [求导:Gradient tapes](https://tensorflow.google.cn/tutorials/customization/autodiff#gradient_tapes) 232 | * [高阶求导 higher-order gradients](https://tensorflow.google.cn/tutorials/customization/autodiff#higher-order_gradients) 233 | 234 | ### Custom training 235 | [定制化训练:基础](https://tensorflow.google.cn/tutorials/customization/custom_training) 236 | 237 | ### Custom training: walkthrough 演示 (重要) 238 | [自定义训练: 演示](https://tensorflow.google.cn/tutorials/customization/custom_training_walkthrough) 239 | * [tf.data.Dataset读取csv文件](https://tensorflow.google.cn/tutorials/customization/custom_training_walkthrough#%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA_tfdatadataset) 240 | * [tf.stack:以将特征字典重新打包为形状为 (batch_size, num_features) 的单个数组](https://tensorflow.google.cn/tutorials/customization/custom_training_walkthrough#%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA_tfdatadataset) 241 | * [不用model.fit,自定义训练过程](https://tensorflow.google.cn/tutorials/customization/custom_training_walkthrough#%E8%AE%AD%E7%BB%83%E6%A8%A1%E5%9E%8B) 242 | * [定义损失和梯度函数](https://tensorflow.google.cn/tutorials/customization/custom_training_walkthrough#%E5%AE%9A%E4%B9%89%E6%8D%9F%E5%A4%B1%E5%92%8C%E6%A2%AF%E5%BA%A6%E5%87%BD%E6%95%B0) 243 | * [创建优化器](https://tensorflow.google.cn/tutorials/customization/custom_training_walkthrough#%E5%88%9B%E5%BB%BA%E4%BC%98%E5%8C%96%E5%99%A8) 244 | * [训练循环](https://tensorflow.google.cn/tutorials/customization/custom_training_walkthrough#%E8%AE%AD%E7%BB%83%E5%BE%AA%E7%8E%AF) 245 | * [可视化损失函数随时间推移而变化的情况](https://tensorflow.google.cn/tutorials/customization/custom_training_walkthrough#%E5%8F%AF%E8%A7%86%E5%8C%96%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0%E9%9A%8F%E6%97%B6%E9%97%B4%E6%8E%A8%E7%A7%BB%E8%80%8C%E5%8F%98%E5%8C%96%E7%9A%84%E6%83%85%E5%86%B5) -------------------------------------------------------------------------------- /Programming/Python/数据结构.md: -------------------------------------------------------------------------------- 1 | # dictionary 字典 2 | 3 | ## 按 key 或 value 对字典排序 4 | 5 | [参考](https://www.runoob.com/python3/python-sort-dictionaries-by-key-or-value.html) 6 | 7 | 按 key 排序: 8 | 9 | ``` 10 | dict = {} 11 | sorted_dict = sorted(dict) 12 | ``` 13 | 14 | 按 value 排序: 15 | 16 | ``` 17 | dict = {} 18 | sorted_dict = sorted(key_value.items(), key = lambda kv:(kv[1], kv[0])) 19 | ``` 20 | 21 | 注意,排序得到的结果其实是一个 list,list 的元素为 tuple(key+value)。 22 | 23 | # list 24 | 25 | ``` 26 | # 排序 27 | a = [] 28 | a.sort() # 无返回值 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tutorials & Notes 各类教程&笔记 2 | 3 | 在这个 repo 中,我记录了一些笔记或者教程。这些内容都是我在过往的学习过程中,记录整理的,都是自己使用过的。有些内容是查了很多资料才好不容易总结出来的,为了方便之后查阅,所以建立了这个 repo。 4 | 5 | 建立这个库的初衷只是为了方便自己查看,所以内容都是我能看懂就行,如果别的网站已经整理得很好了,我就只记录下来了网址,一切都是为了方便。可能有些内容适用于我的使用条件,但不适用于其他人。 6 | 7 | 本来这个 repo 就是给自己看的,但最近居然有人 star 了这个 repo,所以在此特此说明。当然,如果这个 repo 中的内容能对大家有所帮助的话,那我是非常开心的。这里面有些内容确实不太容易整理到,会对大家有所帮助,只是记录的比较随意,可能带来理解上的困难。如果有任何问题,欢迎 issue,我会尽可能提供帮助。 -------------------------------------------------------------------------------- /Rapberry_Pi/Berryconda.md: -------------------------------------------------------------------------------- 1 | # Berryconda 2 | 3 | Berryconda是适用于树莓派的conda 4 | 5 | ## Berryconda 安装 6 | [Quick start](https://github.com/jjhelmus/berryconda#quick-start) 7 | 8 | ## conda 换国内源 9 | 直接在终端下运行修改命令即可: 10 | ``` 11 | conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free 12 | conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main 13 | conda config --set show_channel_urls yes 14 | ``` 15 | 16 | ## conda 虚拟环境 17 | ``` 18 | conda create --name my_env_name python=3.6 # 创建名为my_env_name的虚拟环境 19 | conda remove --name my_env_name --all # 删除名为my_env_name的虚拟环境 20 | ``` -------------------------------------------------------------------------------- /Rapberry_Pi/创建wifi热点&开启SSH&putty连接.md: -------------------------------------------------------------------------------- 1 | # Pi3 创建wifi热点 & 开启SSH & putty连接 2 | 3 | 4 | ## 创建wifi热点并设置开机自启动 5 | ``` 6 | # 创建WiFi热点使用的GitHub上一个开源项目: 7 | https://github.com/oblique/create_ap 8 | 9 | #将代码copy到本地,安装 10 | sudo git clone https://github.com/oblique/create_ap 11 | cd create_ap 12 | sudo make install 13 | 14 | #安装依赖的库 15 | sudo apt-get install util-linux procps hostapd iproute2 iw haveged dnsmasq 16 | 17 | # 此时你可以创建热点,通过以下命令: 18 | sudo create_ap wlan0 eth0 热点名 密码 19 | ``` 20 | 设置开机自启动: 21 | ``` 22 | sudo nano /etc/rc.local 23 | 24 | # 在exit 0 之前加入 25 | sudo create_ap wlan0 eth0 热点名 密码 26 | ``` 27 | 28 | 29 | ## 开启SSH服务 30 | 在Pi终端中,输入: 31 | ``` 32 | sudo raspi-config 33 | ``` 34 | 界面中选中Interfacing Optians, 然后再选SSH,Enable SSH。 35 | -------------------------------------------------------------------------------- /Rapberry_Pi/升级python版本.md: -------------------------------------------------------------------------------- 1 | # 树莓派 升级python版本 2 | 3 | ## python安装 4 | 更新树莓派系统: 5 | ``` 6 | sudo apt-get update 7 | sudo apt-get upgrade -y 8 | ``` 9 | 10 | 安装python依赖环境: 11 | ``` 12 | sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev 13 | ``` 14 | 15 | 下载python版本源码并解压: 16 | ``` 17 | wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz 18 | tar zxvf Python-3.6.1.tgz 19 | cd Python-3.6.1 20 | ``` 21 | 编译安装: 22 | ``` 23 | sudo ./configure --prefix=/usr/local/python3 24 | sudo make 25 | sudo make install 26 | ``` 27 | ## 建立软链接 28 | 创建: 29 | ``` 30 | # ln -s [目录地址] [软链接地址] 31 | ln -s /usr/local/python3/bin/python3 /usr/bin/python3 32 | ``` 33 | 删除: 34 | ``` 35 | # rm -rf [软链接地址] 36 | ``` 37 | 修改: 38 | ``` 39 | # ln -snf [新的目录地址][软链接地址] 40 | ``` 41 | 42 | 43 | *** 44 | 参考资料: 45 | 46 | [树莓派升级(安装)Python3.6|科技爱好者博客](http://blog.lxx1.com/3214) 47 | -------------------------------------------------------------------------------- /Rapberry_Pi/安装tensorflow.md: -------------------------------------------------------------------------------- 1 | 2 | ## Tensorflow 安装 3 | [Installing TensorFlow on Raspberry Pi 3](https://www.jianshu.com/p/7f031fa2739a) 4 | 5 | ## 使用Object Detection API 进行目标检测 6 | [Tutorial to set up TensorFlow Object Detection API on the Raspberry Pi | GitHub](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi#tutorial-to-set-up-tensorflow-object-detection-api-on-the-raspberry-pi) 7 | * [安装Tensorflow](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi#2-install-tensorflow) 8 | * [安装OpenCV](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi#3-install-opencv) 9 | * [Compile and Install Protobuf (used by ensorFlow object detection API)](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi#4-compile-and-install-protobuf) 10 | * [安装Object Detection API](https://github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi#5-set-up-tensorflow-directory-structure-and-pythonpath-variable) 11 | 12 | * [ssdlite模型下载:Tensorflow detection model zoo](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md) -------------------------------------------------------------------------------- /Rapberry_Pi/更换下载源.md: -------------------------------------------------------------------------------- 1 | # 切换到国内的apt-get下载源 2 | 防止下载速度过慢 3 | 4 | 换源: 5 | ``` 6 | sudo nano /etc/apt/sources.list 7 | ``` 8 | 在第一行开头加一个#,注释掉第一行 9 | 10 | 在最后一行之后加上: (strech是版本号,可能要改!!!!!!!) 11 | ``` 12 | deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi 13 | deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi 14 | ``` 15 | 先按键盘上的ctrl+o,再按回车保存,再按ctrl+x退出nano编辑器回到命令行界面。 16 | 17 | 然后再输入: 18 | ``` 19 | sudo nano /etc/apt/sources.list.d/raspi.list 20 | ``` 21 | 将原本源注释,加上中科大源: 22 | ``` 23 | deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ stretch main ui 24 | ``` 25 | Ctrl+o 回车保存,Ctrl+x 退出编辑器。然后更新: 26 | ``` 27 | sudo apt-get update && sudo apt-get upgrade 28 | ``` 29 | 30 | 31 | # 切换到国内的pip(pip3)下载源 32 | 33 | 注意:pip和pip3的操作方法一样。 34 | 35 | 创建目论~/.pip,然后创建文件pip.conf: 36 | ``` 37 | sudo mkdir ~/.pip 38 | 39 | sudo nano ~/.pip/pip.conf 40 | ``` 41 | 在打开的文件中输入以下内容: 42 | ``` 43 | [global] 44 | timeout = 6000 45 | index-url = https://pypi.tuna.tsinghua.edu.cn/simple 46 | trusted-host = pypi.tuna.tsinghua.edu.cn 47 | ``` 48 | 先按键盘上的ctrl+o,再按回车保存,再按ctrl+x退出nano编辑器回到命令行界面。 49 | 50 | *** 51 | *** 52 | *** 53 | 参考资料: 54 | 55 | https://www.lizenghai.com/archives/27483.html 56 | [树莓派换源-CSDN](https://blog.csdn.net/weixin_40973138/article/details/84141281) 57 | -------------------------------------------------------------------------------- /Rapberry_Pi/直流电机相关.md: -------------------------------------------------------------------------------- 1 | # 直流电机相关知识 2 | 3 | ## 直流电机工作原理 4 | 5 | 直流电动机:将直流电能转换为机械能的电动机。 6 | 7 |
8 |
直流电机工作原理图
9 | 10 | 11 | 直流电机里边固定有环状永磁体,电流通过转子上的线圈产生安培力,当转子上的线圈与磁场平行时,再继续转受到的磁场方向将改变,因此此时转子末端的电刷跟转换片交替接触,从而线圈上的电流方向也改变,产生的洛伦兹力方向不变,所以电机能保持一个方向转动。 12 | 13 | ## H桥 14 | 15 | H桥(H-Bridge),因外形与H相似故得名,常用于逆变器(DC-AC转换,即直流变交流)。通过开关的开合,将直流电(来自电池等)逆变为某个频率或可变频率的交流电,用于驱动交流电机(异步电机等)。 16 | 17 | ### H桥用于直流电机工作原理 18 | 19 | ![典型直流电机控制电路](http://file.elecfans.com/web1/M00/45/56/pIYBAFppK-CAD89vAADyGqvU95U756.png) 20 | 21 | 上图中所示为一个典型的直流电机控制电路。电路得名于“H桥驱动电路”是因为它的形状酷似字母H。4个三极管组成H的4条垂直腿,而电机就是H中的横杠(注意:图只是示意图,而不是完整的电路图,其中三极管的驱动电路没有画出来)。 22 | 23 | ![电机运转电流方向1](http://file.elecfans.com/web1/M00/45/56/pIYBAFppK-2AV4EXAAETvdNctiA890.png) 24 | 25 | 桥式电机驱动电路包括4个三极管和一个电机。要使电机运转,必须导通对角线上的一对三极管。根据不同三极管对的导通情况,电流可能会从左至右或从右至左流过电机,从而控制电机的转向。 26 | 27 | 要使电机运转,必须使对角线上的一对三极管导通。例如,如下图所示,当Q1管和Q4管导通时,电流就从电源正极经Q1从左至右穿过电机,然后再经Q4回到电源负极。按图中电流箭头所示,该流向的电流将驱动电机顺时针转动。当三极管Q1和Q4导通时,电流将从左至右流过电机,从而驱动电机按特定方向转动(电机周围的箭头指示为顺时针方向)。 28 | 29 | ![电机运转电流方向2](http://file.elecfans.com/web1/M00/45/53/o4YBAFppK_OAGNDgAADGhthvqaQ994.png) 30 | 31 | 上图所示为另一对三极管Q2和Q3导通的情况,电流将从右至左流过电机。当三极管Q2和Q3导通时,电流将从右至左流过电机,从而驱动电机沿另一方向转动(电机周围的箭头表示为逆时针方向)。 32 | 33 | ## 编写代码实现电机转速控制 & 小车转弯控制 & PWM电机转速变化 34 | 35 | [小车电机控制python代码](https://github.com/Mingrui-Yu/RaspberryCar/blob/master/PythonCode/move.py) 36 | 37 | ## PWM 38 | 39 | 脉冲宽度调制(Pulse width modulation),通过对一系列脉冲的宽度进行调制,来等效地获得所需要的波形(含形状和幅值), PWM控制技术在逆变电路中应用最广,应用的逆变电路绝大部分是PWM型,广泛应用在从测量、通信到功率控制与变换的许多领域中。 40 | 41 | ![PWM示意图](http://file.elecfans.com/web1/M00/85/A6/pIYBAFxtAg-ALgXSAAAgSMYQeE0019.jpg) 42 | 43 | ### 基本原理: 44 | 45 | 控制方式就是对逆变电路开关器件的通断进行控制,使输出端得到一系列幅值相等的脉冲,用这些脉冲来代替正弦波所需要的波形。也就是在输出波形的半个周期中产生多个脉冲,使各脉冲的等值电压为正弦波形,所获得的输出平滑且低次谐波少。按一定的规则对各脉冲的宽度进行调制,即可改变逆变电路输出电压的大小,也可改变输出频率。 46 | 47 | [PWM的作用:一个通俗的解释](https://zhidao.baidu.com/question/551407836.html) 48 | 49 | ### 正弦波PWM调制: 50 | 51 | 把正弦半波波形分成N等份,就可把正弦半波看成由N个彼此相连的脉冲所组成的波形。如果把上述脉冲序列用同样数量的等幅而不等宽的矩形脉冲序列代替,使矩形脉冲的中点和相应正弦等分的中点重合,且使矩形脉冲和相应正弦部分面积(即冲量)相等,就得到一组脉冲序列,这就是PWM波形。根据冲量相等效果相同的原理,PWM波形和正弦半波是等效的。 52 | 53 | ![正弦波PWM调制](http://www.elecfans.com/uploads/allimg/171006/1H40A439-1.jpg) 54 | 55 | ### PWM特点: 56 | 57 | * 从处理器到被控系统信号都是数字形式的,无需进行数模转换,让信号保持为数字形式可将噪声影响降到最小; 58 | * 对噪声抵抗能力增强,从模拟信号转向PWM可以极大地延长通信距离; 59 | 60 | ### 使用 RPI.GPIO 模块的脉宽调制(PWM)功能 61 | 62 | 创建一个 PWM 实例: 63 | ``` 64 | p=GPIO.PWM(channel, frequency) #(引脚, 频率) 65 | ``` 66 | 启用 PWM: 67 | ``` 68 | p.start(dc)# dc 代表占空比 #范围:0.0<=dc<= 100.0) 69 | ``` 70 | 更改频率: 71 | ``` 72 | p.ChangeFrequency(freq) #freq为设置的新频率,单位为 Hz 73 | ``` 74 | 更改占空比: 75 | ``` 76 | p.ChangeDutyCycle(dc) #范围:0.0<=dc<=100.0 77 | ``` 78 | 停止 PWM: 79 | ``` 80 | p.stop() 81 | ``` 82 | 83 | ********** 84 | 参考资料: 85 | 86 | [直流电动机](https://baike.baidu.com/item/%E7%9B%B4%E6%B5%81%E7%94%B5%E5%8A%A8%E6%9C%BA) 87 | 88 | [h桥电路图工作原理图文详解](http://www.elecfans.com/dianzichangshi/20180125622722.html) 89 | 90 | [一文读懂PWM原理及其在电源中的应用](http://m.elecfans.com/article/559335.html) 91 | 92 | [PWM是什么](http://www.elecfans.com/d/872960.html) 93 | 94 | [PWM信号是什么信号?它有什么作用? ](https://zhidao.baidu.com/question/551407836.html) 95 | 96 | -------------------------------------------------------------------------------- /Rapberry_Pi/相机&opencv_python.md: -------------------------------------------------------------------------------- 1 | # 在树莓派上安装基于python的opencv 2 | 3 | ## python2 + opencv 4 | ``` 5 | sudo pip install opencv-python 6 | ``` 7 | 8 | 9 | ## python3 + opencv 10 | 11 | ### 在树莓派设置中把根目录扩大到整个SD卡 12 | ``` 13 | sudo raspi-config 14 | ``` 15 | Advanced Options -- Expand Filesystem 16 | 17 | ### 不成功:直接使用pip3安装 18 | (最新版树莓派系统2019.10已经可以通过此方式直接安装) 19 | 20 | 若使用: 21 | ``` 22 | sudo pip3 install opencv-python 23 | 24 | # 安装依赖库 25 | sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev 26 | sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev 27 | sudo apt-get install libxvidcore-dev libx264-dev 28 | sudo apt-get install qt4-dev-tools libatlas-base-dev 29 | ``` 30 | 不成功 31 | 32 | ### 成功:离线安装 33 | 首先在浏览器中输入下载地址: 34 | (https://www.piwheels.org/simple/opencv-python/opencv_python-3.4.3.18-cp34-cp34m-linux_armv7l.whl) 35 | 注意网址对应版本:opencv3.4.3 + python3.4 36 | 37 | 下载好后,将该whl文件导入树莓派中; 38 | 39 | 在树莓派上离线安装: 40 | ``` 41 | sudo pip3 install opencv_python-3.4.3.18-cp34-cp34m-linux_armv7l.whl 42 | ``` 43 | 44 | 成功后,安装依赖库: 45 | ``` 46 | sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev 47 | sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev 48 | sudo apt-get install libxvidcore-dev libx264-dev 49 | sudo apt-get install qt4-dev-tools libatlas-base-dev 50 | ``` 51 | (可能还有其他依赖库) 52 | 53 | 测试,在Terminal中输入: 54 | ``` 55 | python3 56 | import cv2 57 | ``` 58 | 59 | # python脚本调用摄像头 60 | 可以直接使用opencv调用摄像头 61 | 62 | 在 ```sudo raspi-config``` 中启用Camera,然后重启。 63 | 64 | 之后参考 [树莓派(Raspberry Pi)中PiCamera+OpenCV的使用](https://blog.csdn.net/u012005313/article/details/70244747#C0) 65 | 66 | *** 67 | *** 68 | *** 69 | 参考资料: 70 | 71 | [树莓派python3使用pip3安装opencv3.4](https://blog.csdn.net/weixin_42834671/article/details/100620865) -------------------------------------------------------------------------------- /Rapberry_Pi/网球追踪技术原理.md: -------------------------------------------------------------------------------- 1 | # 网球追踪技术原理 2 | 3 | ## 霍夫圆检测 4 | 5 | 在笛卡尔坐标系中圆的参数方程为: 6 | (其中(a,b)为圆心,r为半径) 7 | 8 | ![20191031190710.png](https://i.loli.net/2019/10/31/dQzZrIRiOahsg9Y.png) 9 | 10 | 变型为: 11 | 12 | ![20191031190741.png](https://i.loli.net/2019/10/31/FSnZfsWcUmb47IR.png) 13 | 14 | 即笛卡尔xy坐标系中经过某一点的所有圆映射到abr坐标系中就是一条三维的曲线。 15 | 16 | 通过判断abr坐标系中每一点的相交(累积)数量,大于一定阈值的点就认为是圆。 17 | 18 | (上述为标准霍夫圆变换,效率低,opencv实际使用的是基于霍夫梯度法的霍夫圆变换) 19 | 20 | 21 | ## HSV变换 22 | 23 | HSV是一种比较直观的图像模型,常用于图像处理 24 | * H:色调 25 | * 取值范围0~360°,红色为0°,绿色为120°,蓝色为240° 26 | * OpenCV中取值范围为0~180° 27 | * S: 饱和度 28 | * 表示颜色接近光谱色的程度,取值范围0~100% 29 | * OpenCV中取值范围为0~255 30 | * V:明度 31 | * 表示颜色明亮的程度,取值范围0~100% 32 | * OpenCV中取值范围为0~255 33 | 34 | ![HSV域示意图](https://i.loli.net/2019/10/31/P3XmMVFt4NblYoS.png) 35 | 36 | -------------------------------------------------------------------------------- /Rapberry_Pi/超声波传感器.md: -------------------------------------------------------------------------------- 1 | # 超声波传感器相关 2 | 3 | ## 超声波传感器基本知识 4 | 5 | 性能: 6 | * 探测距离: 2cm-400cm 7 | * 没有温度修正功能 8 | * 感应角度:不大于15度 9 | * 高精度:可达0.3cm 10 | 11 | 接口定义: 12 | * Vcc, Trig(控制端), Echo(接收端), Gnd 13 | 14 | ## 超声波测距基本原理 15 | 控制口发一个10us以上的高电平,就可以在接收口等待高电平输出。一有输出就可以开定时器计时,当此口变为低电平时就可以读定时器的值,此时就为此次测距的时间,方可根据声速算出距离。 16 | 17 | 1. 采用IO口TRIG触发测距,给至少10us的高电平信号; 18 | 2. 模块自动发送8个40khz的方波,自动检测是否有信号返回; 19 | 3. 有信号返回,通过IO口ECHO输出一个高电平,高电平持续的时间就是超声波从发射到返回的时间。测试距离=高电平时间*声速/2; 20 | 21 | 超声波时序图: 22 | 23 | ![超声波时序图](http://file.elecfans.com/web1/M00/50/E3/o4YBAFr83PSAR0P4AAA4pwUYEmA631.jpg) 24 | 25 | ## 超声波测距程序实现 26 | [超声波测距程序实现](https://github.com/Mingrui-Yu/RaspberryCar/blob/master/PythonCode/ultrasound.py) 27 | 28 | [超声波+红外避障程序实现](https://github.com/Mingrui-Yu/RaspberryCar/blob/master/PythonCode/main_obstacle_avoidance.py) 29 | 30 | ## 提升测距准确性的方法 31 | 32 | ### 对测距值进行移动平均 33 | ``` 34 | dist_current = self.DistMeasure() 35 | dist_mov_ave = (0.2 * dist_current) + (0.8 * dist_mov_ave) 36 | ``` 37 | 38 | ### 防止sensor错过回波而停止运行 39 | ``` 40 | # 不加修正的ECHO上升沿检测 41 | while GPIO.input(self.GPIO_ECHO) == 0: 42 | pass 43 | start_time = time.time() 44 | ``` 45 | 在上述程序中,如果sensor错过了回波,那么ECHO永远也不会变为高电平,程序就会一直陷在while循环里,无法继续运行。所以我们对ECHO上升沿检测程序进行了修正: 46 | ``` 47 | # 修正后的ECHO上升沿检测 48 | ii = 0 49 | while GPIO.input(self.GPIO_ECHO) == 0: 50 | ii = ii + 1 51 | if ii > 10000: 52 | print('Ultrasound error: the sensor missed the echo') 53 | return 0 54 | pass 55 | start_time = time.time() 56 | ``` 57 | 经实验,在正常测距的情况下,ii不可能需要累加到10000。所以当ii>10000时,可以认为sensor已经错过了回波,则break,本次测距无效。同时,如果本次测距无效,则dist_mov_ave与上一时刻的dist_mov_ave保持一致。 58 | -------------------------------------------------------------------------------- /StudyNotes/LoopClosing.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # DBoW 4 | 5 | Bag of Words (BoW),词袋模型。应该是说目前主流 SLAM 系统中应用最广泛且效果一流的回环检测方法。考虑到在完整的回环闭合模块中,回环检测之后还要进行回环校正,BoW 方法可以是目前最适合 SLAM 系统回环检测的方法了。 6 | 7 | BoW 方法的原理可以概括为:系统会预先加载一个很大的字典,图像的每一个特征点的描述子可以转换为字典中的一个单词 (word)。图像的每个特征点对应一个 word,我们以一幅图像中是否出现过某个 word 以及出现次数,来对该图像统计一个词袋向量 (bag-of-words vector),作为整幅图像的描述向量。两张图像的 bag-of-words vector 之间的距离就描述了两张图像的差异,从而可以计算出图像之间的相似度,进而进行图像匹配,找到可能的回环关键帧 (Candiate Loop KF)。 8 | 9 | 目前,基于 BoW 回环检测的主流 SLAM 系统包括: 10 | * ORB-SLAM 11 | * VINS-Mono 12 | * LDSO (DSO with Loop closing) 13 | 14 | 提出将 BoW 方法应用于 SLAM 系统回环检测的论文很多,最经典论文应该是12年发表在 TRO 上的 [Bags of Binary Words for Fast Place Recognition in Image Sequences](https://ieeexplore.ieee.org/abstract/document/6202705),论文的作者 Dorian 也是 [DBoW](https://github.com/dorian3d/DBow) 和 [DBoW2](https://github.com/dorian3d/DBoW2) GitHub 开源库的作者。 15 | 16 | ## BoW 原理 17 | 18 | 我们以 [Bags of Binary Words for Fast Place Recognition in Image Sequences](https://ieeexplore.ieee.org/abstract/document/6202705) 论文为参考,来分模块地介绍基于 BoW 的 SLAM 回环检测是如何实现的。 19 | 20 | ### 特征点描述 21 | 22 | 理论上,BoW 方法对图像的特征点类型和描述子类型并没有要求,只要描述子之间能进行距离描述就可以。 23 | 24 | 论文中,作者以 FAST 特征点 + BRIEF 描述子的搭配来进行特征点的提取和描述,这样形成的描述子是一个二进制的向量(这是 BRIEF 描述子带来的)。现在最常用的大概是 ORB 特征及 ORB 描述子(当然 ORB 是基于 FAST + BRIEF 改造而来)。 25 | 26 | 采用 BRIEF 描述子最大好处在于:因为其是二进制的向量,所以两个描述子之间计算距离非常迅速。二进制向量间的距离采用 Hamming 距离(两个向量某位不同的位数)描述,该距离可以直接通过异或运算求得。 27 | 28 | ### 构建图像数据集 & 词典 29 | 30 |
31 | 32 | 上图展示了图像数据集和词典的示意图,其采用了几种方法(结构)来提高计算速度。 33 | 34 | #### vocabulary tree 35 | 36 | 词典由一个 vocabulary tree 构成,该树的每个叶节点代表一个 word,其构建构成如下: 37 | 1. 从一个离线的很大的图像数据集中,提取很多很多很多特征点和相应的描述子 38 | 2. 对这些描述子聚类成 $k_w$ 个类(使用 k-means++ 聚类法),这 $k_w$ 个类就是 vocabulary tree 的根节点下一层的 $k_w$ 个节点。 39 | 3. 每一个类,再进行同样的聚类。每个类再细分出 $k_w$ 个子类 40 | 4. 以此类推,共进行 $L_w$ 次 41 | 5. 得到最终的 vocabulary tree,每个叶节点代表一个 word 42 | 43 | 44 | 这样最终,就形成了如图所示的一个树,该树有 $k_w + 1$ 层,共有 $k_w^{L_w}$ 个叶节点,也就是总共存储了 $k_w^{L_w}$ 个 words。采用树的结构的原因是:因为 word 会特别特别多,在寻找某特征对应的 word 时,如果是线性查询,则时间复杂度为 $O(n)$。若用这种树结构,则只需 $O(\log_{k_m}n)$。 45 | 46 | 另外,为了更好地计算图像相似度,所以给每个 word 赋予一个不同的权重。例如如果一个 word 特别经常出现,在每个图像中都出现,那么它对于计算相似度的贡献就很小,应该给一个很小的权重。权重的具体计算方法为 TF-IDF (Term Frequency-Inverse Document Frequency) ([参考文献](https://ieeexplore.ieee.org/abstract/document/1238663)): 47 | 48 | 其中 IDF 部分(某word 在字典中出现的频率越低,则分类图像时区分度越高): 49 | 50 | $$\mathrm{IDF}_{i}=\log \frac{n}{n_{i}}$$ 51 | 52 | 其中 $n$ 为数据集的总特征数量,$n_i$ 为 word $w_i$ 对应的特征的数量。 53 | 54 | TF 部分(某 word 在一个图像中经常出现,它的区分度就高): 55 | 56 | $$\mathrm{TF}_{i}=\frac{n_{i}}{n}$$ 57 | 58 | 其中 $n_i$ 为该图像中 word $w_i$ 出现的次数, $n$ 为该图像一共出现的 word 次数(等于特征点数) 59 | 60 | 而一个 word $w_i$ 在某图片中的权重 $\eta_{i}$ 即为: 61 | 62 | $$\eta_{i}=\mathrm{TF}_{i} \times \mathrm{IDF}_{i}$$ 63 | 64 | 所以一张图像 $I_t$ 的 bag-of-words vector $v_t$ 为: 65 | 66 | $$\boldsymbol{v}_t = \left\{\eta_{1}, \eta_{2}, ... , \eta_{N}\right\}$$ 67 | 68 | 其中 $N$ 为词典中的所有 word 类数。 69 | 70 | 计算两张图像的 bag-of-words vector 的距离的方法可以使用 $L_1$ 范数形式: 71 | 72 | $$ s\left(\mathbf{v}_{1}, \mathbf{v}_{2}\right)=1-\frac{1}{2}\left|\frac{\mathbf{v}_{1}}{\left|\mathbf{v}_{1}\right|}-\frac{\mathbf{v}_{2}}{\left|\mathbf{v}_{2}\right|}\right| $$ 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /StudyNotes/ORB-SLAM2.md: -------------------------------------------------------------------------------- 1 | # ORB-SLAM2 in ROS 2 | 3 | ## 编译 4 | 5 | 参考:[raulmur/ORB_SLAM2](https://github.com/raulmur/ORB_SLAM2#7-ros-examples) 6 | 7 | 在 ~/.bashrc 中添加 ORB-SLAM2 path 至 ROS_PACKAGE_PATH 8 | ``` 9 | sudo gedit ~/.bashrc 10 | 11 | # 添加 12 | export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/mingrui/Mingrui/SLAMProject/ORB_SLAM2/Examples/ROS 13 | ``` 14 | **NOTICE:** 15 | * ${ROS_PACKAGE_PATH}:和/home之间不能有空格。 16 | * 添加的位置要在之前添加的其它的 source 命令之后。 17 | 18 | 19 | 编译: 20 | ``` 21 | cd /home/mingrui/Mingrui/SLAMProject/ORB_SLAM2 22 | chmod +x build_ros.sh 23 | 24 | ./build_ros.sh 25 | ``` 26 | 会报错:```DSO missing from command line``` 27 | 28 | 解决:[ERROR while running ./build_ros.sh #535](https://github.com/raulmur/ORB_SLAM2/issues/535) 29 | 30 | 31 | ## 使用电脑自带摄像头跑 ORB-SLAM2 32 | 参考:[ubuntu16.04下用笔记本摄像头和ROS编译运行ORB_SLAM2的单目AR例程](https://www.cnblogs.com/feifanrensheng/p/8995836.html) 33 | 34 | ## Android 手机摄像头 与 PC 实现 ROS 通信 35 | 参考:[ ROS实时采集Android的图像和IMU数据 36 | ](https://www.cnblogs.com/hitcm/p/5616364.html) 37 | 38 | **NOTICE:** 39 | * ```sudo apt-get install ros-melodic-imu-tools``` 修改 ROS 版本 40 | * PC 的 ip 地址 通过 终端输入 ifconfig 查看 41 | * 必须要 roslauch,否则没有 /camera/image_raw 这个 ROS topic 42 | 43 | 关于 rvis 界面: 44 | * 如果要实时显示 image,需要 Add - By topic - 添加/camera/image_raw/image 45 | * 如果要显示 imu,则需要 Add - By topic - 添加 imu,且在 Fix Frame 中 将 map 改为 imu 46 | 47 | ### 保存图片 48 | 49 | 目前没有找到直接保存的方法,选择写一个 ROS node 来接受图像,再通过 OpenCV 进行显示和保存。与上一部分 Android 配合使用。 50 | 51 | cmake 的那堆东西还不太懂,所以选择修改 ORB-SLAM2 的 ros_mono.cc 实现。在 ros_mono.cc 同一目录下写了个 ros_camera_capture.cc。 52 | 53 | 使用方法: 54 | 55 | Terminal 1: 56 | ``` 57 | roscore 58 | ``` 59 | 手机进入 apk 运行 60 | 61 | Terminal 2: 在 Android_Camera-IMU 目录 62 | ``` 63 | roslaunch android_cam-imu.launch 64 | ``` 65 | (可以关掉 rvis) 66 | 67 | Terminal 3: 68 | ``` 69 | rosrun ORB_SLAM2 CameraCapture 70 | ``` 71 | 按下 q 保存图像(注意保存的目录 SLAMProject/calibrationImages) 72 | 73 | (实验发现家里的网真不好,手机和电脑之间的传输很不稳定,切换成 手机热点就好了) 74 | 75 | ## 手机摄像头标定 76 | 参考: [相机标定](相机标定.md) 77 | 使用 OpenCV sample. 78 | 79 | 新建了一个文件夹 SLAMProject/camera_calibration_opencv,作为标定的工作文件夹。 80 | 81 | 在 VID5.xml 中添加标定图片的路径。 82 | 83 | ORB-SLAM2 中需要的参数有 fx, fy, cx, cy, k1, k2, k3, p1, p2,也就是有径向畸变和切向畸变参数,所以要在 in_VID5.xml 中将 改为0。 84 | 85 | 编译: 86 | ``` 87 | cd camera_calibration_opencv 88 | mkdir build 89 | cd build 90 | cmake .. 91 | make 92 | ``` 93 | 运行: 94 | ``` 95 | ./build/Camera_Calibration in_VID5.xml 96 | ``` 97 | 98 | 参数输出在 out_camera_data.xml 中: 99 | * 是相机内参矩阵,顺序为 fx, 0, cx; 0, fy, cy; 0, 0, 1; 100 | * 就是畸变参数,其顺序为 k1, k2, p1, p2, k3。 101 | 102 | 之后将标定参数填入 ORB-SLAM2 的自己的 ORB_SLAM2/Examples/Monocular/MI9SE.yaml 中 103 | 104 | ## 使用手机摄像头跑 ORB-SLAM2 105 | 参考:[采集Android手机摄像头运行ORB_SLAM2(ubuntu16.04+ROS kinetic)](https://blog.csdn.net/qq_36122936/article/details/88556428?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task) 106 | 107 | Terminal 1: 108 | ``` 109 | roscore 110 | ``` 111 | 手机进入 apk 运行 112 | 113 | Terminal 2: 在 Android_Camera-IMU 目录 114 | ``` 115 | roslaunch android_cam-imu.launch 116 | ``` 117 | (可以关掉 rvis) 118 | 119 | Terminal 3: 120 | ``` 121 | rosrun ORB_SLAM2 Mono ~/Mingrui/SLAMProject/ORB_SLAM2/Vocabulary/ORBvoc.txt ~/Mingrui/SLAMProject/ORB_SLAM2/Examples/Monocular/MI9SE.yaml 122 | ``` -------------------------------------------------------------------------------- /StudyNotes/PCA.md: -------------------------------------------------------------------------------- 1 | [主成分分析法原理简介](http://astrowww.bnu.edu.cn/sites/Computational_Astronomy/html/6shijian/chengguo/2008%E5%AD%A6%E7%94%9F/pca-%E5%A7%9C%E6%99%A8.pdf) -------------------------------------------------------------------------------- /StudyNotes/ROS.md: -------------------------------------------------------------------------------- 1 | # ROS 基础用法 2 | 3 | [ROS-Tutorials](http://wiki.ros.org/ROS/Tutorials) 4 | 5 | ## ROS Enivronment 配置 6 | 7 | 在 ~/.bashrc 中添加 ROS environment setup,该方法会永久有效(个人推荐,否则太麻烦了) 8 | ``` 9 | echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc 10 | source ~/.bashrc 11 | ``` 12 | 如果只想对于当前 Terminal 有效,则: 13 | ``` 14 | source /opt/ros/melodic/setup.bash 15 | ``` 16 | 17 | ## 建立 ROS Workspace 18 | example: ~/catkin_ws 为 Workspace 目录 19 | ``` 20 | mkdir -p ~/catkin_ws/src 21 | cd ~/catkin_ws/ 22 | catkin_make # 首次会创建 CMakeLists.txt,之后类似于 cmake 23 | ``` 24 | 注:-p 的意义为:可以创建目录及其子目录,否则只能创建到一级目录 catkin_ws 25 | 26 | 如果想使用该 Workspace,需要在 Workspace 目录的终端中: 27 | ``` 28 | source devel/setup.bash # 只对当前终端有效 29 | ``` 30 | 31 | ## ROS 文件操作方法 32 | ``` 33 | rospack find [package_name] 34 | 35 | roscd [locationname[/subdir]] 36 | 37 | rosls [locationname[/subdir]] 38 | ``` 39 | 40 | ## Package 41 | ### 创建: 42 | ``` 43 | cd ~/catkin_ws/src 44 | 45 | # 创建 beginner_tutorials 文件夹其中包括 package.xml & CMakeLists.txt 46 | # catkin_create_pkg [depend1] [depend2] [depend3] 47 | catkin_create_pkg beginner_tutorials std_msgs rospy roscpp 48 | ``` 49 | ### Build: 50 | ``` 51 | cd ~/catkin_ws 52 | catkin_make 53 | ``` 54 | 55 | 56 | ## Run ROS 57 | 首先,必须,总领全局: 58 | ``` 59 | roscore 60 | ``` 61 | 新的终端: 62 | ``` 63 | # optional 64 | rosnode list # 查看当前的 nodes 列表 65 | rosnode info [nodename] # 查看 nodename 的具体信息 66 | ``` 67 | ### rosrun 68 | 新的终端: 69 | ``` 70 | # rosrun [package_name] [node_name] 71 | rosrun turtlesim turtlesim_node # 小乌龟 72 | ``` 73 | 74 | 新的终端: 75 | ``` 76 | rosrun turtlesim turtle_teleop_key # 键盘方向键输入 77 | ``` 78 | 79 | ### Watch the Node/Topic/Message Graph: 80 | 81 | 新的终端: 82 | ``` 83 | rosrun rqt_graph rqt_graph 84 | ``` 85 | 86 | ### rostopic 87 | ``` 88 | rostopic echo [topic] # will show topic's message 89 | rosmsg show [message]] # show message's detals 90 | ``` 91 | 92 | ### roslaunch 93 | 同时启动多个 nodes 94 | 95 | ## 使用例子 96 | [Creating a ROS msg and srv](http://wiki.ros.org/ROS/Tutorials/CreatingMsgAndSrv) 97 | 98 | [Writing a Simple Publisher and Subscriber (C++)](http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29) 99 | 100 | [Writing a Simple Service and Client (C++)](http://wiki.ros.org/ROS/Tutorials/WritingServiceClient%28c%2B%2B%29) -------------------------------------------------------------------------------- /StudyNotes/SVD.md: -------------------------------------------------------------------------------- 1 | # SVD: Sigular Value Decompostion 2 | 3 | Reference: 4 | 5 | * [漫谈奇异值分解](http://charleshm.github.io/2016/03/Singularly-Valuable-Decomposition/):引出奇异值分解比较通俗易懂,适合第一次推导,推荐先看这个。但不够准确(局限在实数域),最后的例子没看懂。 6 | * [We Recommend a Singular Value Decomposition](http://www.ams.org/publicoutreach/feature-column/fcarc-svd):推荐看。 7 | * 生动形象介绍了SVD的几何解释 8 | * 用例子介绍了SVD的应用 9 | * [维基百科](https://zh.wikipedia.org/wiki/%E5%A5%87%E5%BC%82%E5%80%BC%E5%88%86%E8%A7%A3):基础概念和性质,讲得不太清楚,也不太准确,建议别看了。 -------------------------------------------------------------------------------- /StudyNotes/Simscape.md: -------------------------------------------------------------------------------- 1 | # Simscape 相关 2 | 3 | 4 | 5 | simscape Multibody 提供了很多examples: 6 | https://ww2.mathworks.cn/help/physmod/sm/examples.html?s_tid=CRUX_gn_example 7 | 8 | 9 | model workspaces的相关介绍: https://ww2.mathworks.cn/help/simulink/ug/using-model-workspaces.html?lang=en 10 | 下面related topics中有更详细的介绍 11 | 12 | 如何更改model workspaces中存储的data:https://ww2.mathworks.cn/help/simulink/ug/change-model-workspace-data.html?lang=en 13 | 14 | 关于solver的选择:https://ww2.mathworks.cn/help/simulink/gui/solver.html 15 | 实验发现ode23t 配合较大的时间步长较好 -------------------------------------------------------------------------------- /StudyNotes/caffe.md: -------------------------------------------------------------------------------- 1 | ## 根据 prototxt 绘制网络结构示意图 2 | 3 | ![](https://pic3.zhimg.com/80/v2-ca03df14a573bfedb17a5f89c165613a_720w.png) 4 | 5 | ## 添加 triplet loss layer 6 | 7 | 参考 [GitHub](https://github.com/jmfacil/single-view-place-recognition) 中的 models/fine_tuned/triplet_vgg16_pool4_fc_128_fine_train.prototxt 中的实现方法(使用 caffe 自带的简单层叠加实现) 8 | 9 | ## 添加 L2 normalization layer 10 | 11 | [参考](https://groups.google.com/d/msg/caffe-users/rSuLJ_cSqUg/st875SgVAwAJ),(使用 caffe 自带的简单层叠加实现) 12 | 13 | ## 对预训练的模型进行 net surgery 14 | 15 | [参考](https://nbviewer.jupyter.org/github/BVLC/caffe/blob/master/examples/net_surgery.ipynb) 16 | 17 | ## 不同 layers 之间参数共享 18 | 19 | [参考](http://caffe.berkeleyvision.org/gathered/examples/siamese.html) 20 | 21 | ## lr_mult / decay_mult 22 | 23 | [参考]() 24 | 25 | [How to reuse same network twice within a new network in CAFFE](https://stackoverflow.com/questions/33983627/how-to-reuse-same-network-twice-within-a-new-network-in-caffe) 26 | 27 | ## pycaffe 常用 API 28 | 29 | [参考-Caffe-Python接口常用API](http://wentaoma.com/2016/08/10/caffe-python-common-api-reference/) -------------------------------------------------------------------------------- /StudyNotes/calc.md: -------------------------------------------------------------------------------- 1 | # calc 2 | 3 | 记录一下 calc 编译过程中遇到的一些问题 4 | 5 | ## TrainAndTest 6 | 7 | 其他需要 pip 的依赖: 8 | 9 | ``` 10 | pip install lmdb 11 | pip install psutil 12 | pip install click 13 | ``` 14 | 15 | ### 编译 TrainAndTest 中的 DBoW2 16 | 17 | 报错: 18 | 19 | ``` 20 | calc/TrainAndTest_origin_backup/ThirdParty/DBoW2/build/dependencies/src/DLib/src/DUtilsCV/Drawing.cpp 21 | error: no matching function for call to ‘_IplImage::_IplImage(cv::Mat&)’ 22 | IplImage ipl_im = IplImage(im); 23 | ``` 24 | 25 | 解决:在源代码中将 IplImage(im) 改为 cvIplImage(im) [参考](https://github.com/davisking/dlib/commit/54a9a5bbf3267386dd39a82fb792bab1bb60796c) 26 | 27 | 报错: 28 | 29 | ``` 30 | error: ‘boost::python::numeric’ has not been declared 31 | boost::python::numeric::array::set_module_and_type("numpy", "ndarray"); 32 | ``` 33 | 34 | 解决: 35 | 36 | boost::python::numeric 在 boost >= 1.65 中已经没有了。[参考](https://github.com/AcademySoftwareFoundation/openvdb/issues/170) 37 | 38 | 似乎将``` boost::python::numeric::array::set_module_and_type("numpy", "ndarray");```在源代码中注释掉就可以了。 39 | 40 | -------------------------------------------------------------------------------- /StudyNotes/flann.md: -------------------------------------------------------------------------------- 1 | # FLANN 2 | 3 | [GitHub](https://github.com/mariusmuja/flann) 4 | 5 | [教程 PDF](https://www.cs.ubc.ca/research/flann/uploads/FLANN/flann_manual-1.8.4.pdf) 6 | 7 | ## pyflann 8 | 9 | [安装](https://pypi.org/project/flann/) 10 | 11 | ## 使用 12 | 13 | Eigen matrix 转换为 flann::Matirx: [参考](https://stackoverflow.com/questions/13465890/eigenmatrixxd-to-flannmatrixdouble-conversion) 14 | 15 | [报错 ... has no member named serialize](https://github.com/mariusmuja/flann/issues/214) : 解决:在OpenCV之前include flann 16 | 17 | [undefined reference to LZ4 for flann 1.8.5 or later](https://github.com/mariusmuja/flann/issues/384#issuecomment-432637533) : 解决:手动在CMakeLists.txt中链接该库 -------------------------------------------------------------------------------- /StudyNotes/相机标定.md: -------------------------------------------------------------------------------- 1 | # 张正友标定法 & OpenCV相机标定实现 2 | 3 | ## 张正友标定法 原理 4 | 5 | Paper: [A Flexible New Technique 6 | for Camera Calibration](https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=888718&tag=1) & Nutstore/Papers 笔记。 7 | 8 | 原理解释参考: 9 | 10 | [SLAM入门之视觉里程计(6):相机标定 张正友经典标定法详解 11 | ](https://www.cnblogs.com/wangguchangqing/p/8335131.html) 12 | 13 | ## OpenCV相机标定实现 14 | 15 | ### Method1: 使用OpenCV sample 16 | [官方源码 | Github](https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp) 17 | 18 | 我的实现:[GitHub](https://github.com/Mingrui-Yu/slambook2/tree/master/MingruiSLAM/ch5/camera_calibration) 19 | 20 | 资料参考: [OpenCV 相机参数标定(Camera Calibration)](https://www.jianshu.com/p/967a35dbb56a) 参考该篇文章中提到的该sample的调用方法 21 | 22 | NOTICE: 23 | * 在OpenCV安装目录中 samples/data 中有拍摄好的标定板图片,可以直接用(不推荐,因为它长宽的格数都一样,可使用上面参考博文中的 9*6 的 chessboard)。 24 | * 实验发现,标定板周围要是白色的才行,黑色的提取不出角点来。 25 | * in_VID5.xml 是输入的一些控制参数,可以根据实际情况进行修改。 26 | * VID5.xml 中输入图片所在目录。 27 | 28 | ### Method2: 自己写主函数,其中调用OpenCV库函数 29 | 我的实现:[GitHub](https://github.com/Mingrui-Yu/slambook2/tree/master/MingruiSLAM/ch5/cameraCalibration) 不完整,只写到标定,没写标定结果评估 30 | 31 | 资料参考: 32 | * [张正友相机标定Opencv实现以及标定流程&&标定结果评价&&图像矫正流程解析(附标定程序和棋盘图)](https://blog.csdn.net/dcrmg/article/details/52939318) 主要参考该篇文章最后的完整代码 (其中定义内参矩阵和畸变系数的Mat格式需要修改) 33 | * [Camera calibration using C++ and OpenCV](https://sourishghosh.com/2016/camera-calibration-cpp-opencv/) 参考其中提到FLAG的设置 34 | 35 | NOTICE: 36 | * flag的设置对标定结果有较大影响。 37 | * 拍摄的标定板图片,标定板要小一点,否则提取不出角点。 38 | * 定义内参矩阵的数据格式为Mat::eye(3, 3, CV_64F), 如果定义为参考文章中的那样,标定后内参矩阵出现-nan。 -------------------------------------------------------------------------------- /TX2/基本使用.md: -------------------------------------------------------------------------------- 1 | # TX2 基本使用 2 | 3 | [TX2-start 6 CPU kernel-开启高功耗模式](https://www.cnblogs.com/happyamyhope/p/9110899.html) -------------------------------------------------------------------------------- /Ubuntu/Anaconda & vscode & TensorFlow.md: -------------------------------------------------------------------------------- 1 | # Ubuntu:Anaconda & vscode & TensorFlow 2 | 3 | ## 安装Anaconda 4 | 1. 下载: 5 | ``` 6 | wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.0.0-Linux-x86_64.sh 7 | ``` 8 | 其他版本可以到https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/自行查找。 9 | 10 | 2. 安装: 11 | ``` 12 | sudo bash Anaconda3-5.0.0-Linux-x86_64.sh 13 | ``` 14 | 按照提示安装即可,默认将安装在~目录下,如需更改,可以自行指定。 15 | 16 | 17 | 最后允许将Anaconda路径添加到bashrc中。 18 | 19 | (似乎可以没有这一步) 20 | 21 | ``` 22 | source ~/anaconda3/etc/profile.d/conda.sh 23 | ``` 24 | 25 | 3. 激活安装: 26 | ``` 27 | source ~/.bashrc 28 | ``` 29 | 30 | 4. 检查是否安装成功 31 | ``` 32 | conda --version 33 | ``` 34 | 35 | ### 换国内源 36 | 添加清华源: 37 | ``` 38 | conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ 39 | conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 40 | #设置搜索时显示通道地址 41 | conda config --set show_channel_urls yes 42 | 43 | ``` 44 | 45 | ### 升级 46 | ``` 47 | conda update -n base -c defaults conda # 似乎可以没有 48 | conda upgrade --all 49 | ``` 50 | 51 | * 如果出现error:```PermissionError: [Errno 13] Permission denied: '/home/ymr/anaconda3/.condatmp'```,则(设置管理员权限): 52 | ``` 53 | sudo chown -R ymr:ymr /home/ymr/anaconda3 54 | ``` 55 | 56 | * Anaconda中的pip换国内源的方式与ubuntu的pip的一样,不用重复操作。 57 | 58 | ### conda虚拟环境 59 | [TensorFlow 安装与环境配置/Conda虚拟环境](https://tf.wiki/zh/basic/installation.html#tensorflow) 60 | 61 | 查看当前虚拟环境使用的python path [参考](https://docs.anaconda.com/anaconda/user-guide/tasks/integration/python-path/) 62 | 63 | ``` 64 | which python 65 | ``` 66 | 67 | 68 | 69 | *** 70 | 71 | ## 安装TensorFlow 72 | [TensorFlow 安装与环境配置](https://tf.wiki/zh/basic/installation.html#tensorflow) 73 | 74 | ## vscode 75 | ### 切换不同python版本 76 | IDE左下角显示python版本,点击即可切换。从中找到Anaconda中需要的虚拟环境中的python版本即可。 77 | -------------------------------------------------------------------------------- /Ubuntu/GRUB2.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 16.04 引导修复(boot repair) 2 | 3 | 注意u盘启动项在bios里的设置 4 | 5 | https://blog.csdn.net/laocaibcc229/article/details/79274412 6 | 7 | # 修改unbuntu windows默认启动顺序 8 | [ubuntu windows双系统默认启动项轻松切换](https://jingyan.baidu.com/article/c1a3101e608595de656deb0e.html) 9 | -------------------------------------------------------------------------------- /Ubuntu/Github.md: -------------------------------------------------------------------------------- 1 | # Ubuntu Github 2 | 3 | https://blog.csdn.net/m0_37592397/article/details/78664757 4 | 5 | https://www.cnblogs.com/haoxr/p/7693927.html 6 | 7 | https://www.runoob.com/w3cnote/git-guide.html 8 | 9 | [ubuntu下github的使用](https://blog.csdn.net/u012411498/article/details/80675608) 10 | 11 | 12 | 13 | 14 | 15 | ## 前期配置。。。 16 | 17 | 1 在github网站上新建一个仓库 18 | 19 | 2 本地文件夹中打开终端,执行:git init 20 | 21 | 3 配置git 22 | 23 | git add./ :添加托管文件,将目录下的所有文件添加 24 | 25 | git commit -m "#description#" :commit推送,“”内是commit的描述 26 | 27 | 上传文件到远程库:需要该仓库额SSH KEY,从网页上点击Clone or download,复制 28 | 29 | git remote add origin #SSH KEY# 添加远程仓库 30 | 31 | git remote set-url #SSH KEY# 添加文件到远程库 32 | 33 | git push origin master 第一次进行push 34 | 35 | *** 36 | 37 | git add 38 | 39 | git commmit 40 | 41 | git pull 从远程拿到最新代码版本 42 | 43 | git push 更新远程 44 | 45 | 46 | 47 | ## 从网站上clone一个已有项目 48 | 49 | ``` 50 | git clone https://github.com//username//test_project.git 51 | ``` 52 | 修改项目后: 53 | ``` 54 | git add . // .代表添加所有文件 55 | git commit -m "对文件操作的简易描述" 56 | git push 57 | ``` 58 | 59 | 60 | 61 | ## git中submodule子模块的使用 62 | 63 | ### 在自己的项目中添加 submodule 64 | 65 | [参考1](https://git-scm.com/book/en/v2/Git-Tools-Submodules) [参考2](https://www.activestate.com/blog/getting-git-submodule-track-branch/) 66 | 67 | 具体,如果在一个父项目中需要添加一个子项目,则在需要添加的位置: 68 | 69 | ``` 70 | git submodule add SUBMODULE_URL 71 | 72 | # 如果需要指定 branch 则 73 | git submodule add -b BRANCH_NAME https://github.com/XXX/XXXX 74 | ``` 75 | 76 | 这会在父项目根目录创建.gitmodules,但还没有真正把submodule clone 下来。之后更新: 77 | 78 | ``` 79 | git submodule update --init 80 | git submodule update --remote 81 | ``` 82 | 83 | ### clone 别人的项目并 clone下来其中的 submodule 84 | 85 | 参考[git中submodule子模块的添加、使用和删除 | CSDN](https://blog.csdn.net/guotianqing/article/details/82391665) 86 | 87 | 88 | 89 | ## 使用socks5代理,加速git clone 90 | [git 设置和取消代理](https://gist.github.com/laispace/666dd7b27e9116faece6) 91 | ``` 92 | git config --global http.proxy socks5h://127.0.0.1:1080 93 | 94 | ``` 95 | 若要取消: 96 | ``` 97 | git config --global --unset http.proxy 98 | ``` 99 | 100 | 101 | 102 | ## 使用 .gitignore 上传时忽略指定文件 103 | 104 | https://www.liaoxuefeng.com/wiki/896043488029600 105 | 106 | 注意:在编写 .gitignore 之前就已经上传了的文件无法被之后添加的 .gitignore 管理,需要先在云端删除: 107 | 108 | ``` 109 | git rm -r --cached FILE_NAME 110 | git commit -m "delete xxx" 111 | git push 112 | ``` 113 | 114 | 115 | 116 | ## 重命名 repo 117 | 118 | https://help.github.com/cn/github/administering-a-repository/renaming-a-repository -------------------------------------------------------------------------------- /Ubuntu/NVIDIA driver.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 18.04 NVIDIA driver installation (Failure in Thinkpad S5) 2 | 3 | 4 | 查看系统当前内核: 5 | ``` 6 | uname -r 7 | ``` 8 | 9 | 上nvidia官网查看显卡对应的最新驱动版本号 10 | 11 | 卸载旧版本的nvidia驱动: 12 | ``` 13 | sudo apt-get autoremove --purge nvidia* 14 | ``` 15 | 16 | 使用如下命令添加Graphic Drivers PPA: 17 | ``` 18 | sudo add-apt-repository ppa:graphics-drivers/ppa 19 | sudo apt-get update 20 | ``` 21 | 22 | 禁用nouveau驱动: 23 | Ubuntu系统集成的显卡驱动程序是nouveau,我们需要先将nouveau从Linux内核卸载掉才能安装NVIDIA官方驱动。 24 | 将nouveau添加到黑名单blacklist.conf中,linux启动时,就不会加载nouveau. 25 | 26 | 由于blacklist.conf文件的属性不允许修改。所以需要先修改文件属性。 27 | ``` 28 | sudo chmod 666 /etc/modprobe.d/blacklist.conf 29 | ``` 30 | ``` 31 | sudo vi /etc/modprobe.d/blacklist.conf 32 | ``` 33 | 在文件末尾添加如下几行: 34 | ``` 35 | blacklist nouveau 36 | options nouveau modeset=0 37 | ``` 38 | 修改并保存文件后,记得把文件属性复原: 39 | ``` 40 | sudo chmod 644 /etc/modprobe.d/blacklist.conf 41 | ``` 42 | 再更新一下内核: 43 | ``` 44 | sudo update-initramfs -u 45 | ``` 46 | 修改后需要重启系统。 47 | 48 | 重启系统确认nouveau是已经被屏蔽掉,使用lsmod命令查看:无输出则为成功禁用。 49 | ``` 50 | lsmod | grep nouveau 51 | ``` 52 | 53 | 54 | If your nvidia-smi failed to communicate but you've installed the driver so many times, check prime-select. 55 | Run prime-select query to get all possible options. You should see at least nvidia | intel. 56 | Choose prime-select nvidia. 57 | If it says nvidia is already selected, select a different one, e.g. prime-select intel, then switch back to nvidia prime-select nvidia 58 | Reboot and check nvidia-smi. 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | *** 68 | 69 | [1050Ti Ubuntu18.04](https://blog.cnblogs.com/devilmaycry812839668/p/10351400.html) 70 | 71 | [Ubuntu18.04](https://blog.csdn.net/chentianting/article/details/85089403) 72 | 73 | 74 | ## 禁用nouveau驱动 75 | Ubuntu系统集成的显卡驱动程序是nouveau,我们需要先将nouveau从Linux内核卸载掉才能安装NVIDIA官方驱动。 76 | 将nouveau添加到黑名单blacklist.conf中,linux启动时,就不会加载nouveau. 77 | 78 | 由于blacklist.conf文件的属性不允许修改。所以需要先修改文件属性。 79 | ``` 80 | sudo chmod 666 /etc/modprobe.d/blacklist.conf 81 | ``` 82 | ``` 83 | sudo vi /etc/modprobe.d/blacklist.conf 84 | ``` 85 | 在文件末尾添加如下几行: 86 | ``` 87 | blacklist vga16fb 88 | blacklist nouveau 89 | blacklist rivafb 90 | blacklist rivatv 91 | blacklist nvidiafb 92 | ``` 93 | 修改并保存文件后,记得把文件属性复原: 94 | ``` 95 | sudo chmod 644 /etc/modprobe.d/blacklist.conf 96 | ``` 97 | 98 | 再更新一下内核: 99 | ``` 100 | sudo update-initramfs -u 101 | ``` 102 | 修改后需要重启系统。 103 | 104 | 重启系统确认nouveau是已经被屏蔽掉,使用lsmod命令查看: 105 | ``` 106 | lsmod | grep nouveau 107 | ``` 108 | --- 109 | 安装驱动之前另一个重要的事情就是确认系统里面没有旧版本的驱动,以免发生冲突,因此需要卸载旧版本的驱动。 110 | ``` 111 | sudo apt-get autoremove --purge nvidia* 112 | ``` 113 | ## PPA方式安装显卡驱动: 114 | 115 | 在Linux系统里面安装显卡驱动使用PPA的方式成功率一般比较高,但是安装的版本有限: 116 | 117 | 使用如下命令添加Graphic Drivers PPA: 118 | ``` 119 | sudo add-apt-repository ppa:graphics-drivers/ppa 120 | sudo apt-get update 121 | ``` 122 | 寻找合适的驱动版本 123 | ``` 124 | ubuntu-drivers devices 125 | ``` 126 | 安装NVIDIA driver ,如上图显示recommand的驱动, 按ctrl+alt+F1进入tty文本模式[tty注意事项](https://github.com/Mingrui-Yu/Tutorials/blob/master/Ubuntu/tty.md) , 关闭(图形)桌面显示管理器LightDM 127 | ``` 128 | sudo service lightdm stop 129 | ``` 130 | 如果提示unit lightdm.service not loaded, 则先安装LightDm: 131 | ``` 132 | sudo apt install lightdm 133 | ``` 134 | 安装完毕后跳出一个界面,选择lightdm,再 135 | ``` 136 | sudo service lightdm stop 137 | ``` 138 | 139 | ``` 140 | sudo apt-get install nvidia-390 141 | sudo reboot 142 | ``` 143 | 安装完成后重启。 144 | 145 | 重启系统后,执行下面的命令查看驱动的安装状态显示安装成功 146 | ``` 147 | sudo nvidia-smi 148 | sudo nvidia-setting 149 | ``` 150 | 151 | 重启X-window 服务 152 | ``` 153 | sudo service lightdm start 154 | ``` 155 | -------------------------------------------------------------------------------- /Ubuntu/OpenAI-baselines.md: -------------------------------------------------------------------------------- 1 | [OpenAI baselines](https://github.com/openai/baselines) 2 | 3 | 4 | You'll also need system packages CMake, OpenMPI and zlib. Those can be installed as follows 5 | 6 | ``` 7 | sudo apt-get update && sudo apt-get install cmake libopenmpi-dev python3-dev zlib1g-dev 8 | ``` 9 | 10 | ``` 11 | git clone https://github.com/openai/baselines.git 12 | cd baselines 13 | pip3 install -e . 14 | ``` 15 | 16 | ## Testing the installation 17 | 18 | All unit tests in baselines can be run using pytest runner: 19 | 20 | ``` 21 | pytest-3 22 | ``` 23 | 24 | ## 使用例子 25 | 初始训练: 26 | ``` 27 | python3 -m baselines.run --alg=ppo2 --env=HalfCheetah-v2 --num_timesteps=5e4 --save_path=~/models --log_path=~/lo 28 | ``` 29 | 接着之前训练的模型继续训练: 30 | ``` 31 | python3 -m baselines.run --alg=ppo2 --env=HalfCheetah-v2 --num_timesteps=1e6 --load_path=~/models --save_path=~/models --log_path=~/lo --play 32 | ``` 33 | 训练好了,测试,展示: 34 | ``` 35 | python3 -m baselines.run --alg=ppo2 --env=HalfCheetah-v2 --num_timesteps=0 --load_path=~/models --play 36 | ``` 37 | 38 | -------------------------------------------------------------------------------- /Ubuntu/Python&软链接&pip.md: -------------------------------------------------------------------------------- 1 | # Python安装升级 & 软链接 & pip 2 | 3 | ## python 安装 4 | ubuntu18.04自带python3.6.8 5 | 6 | ## 建立软链接 7 | 用于使python指令指向某一特定版本: 8 | 9 | 10 | eg:python3指向python3.5: 11 | 12 | 查询python3软链接地址: 13 | ``` 14 | which python3 15 | ``` 16 | 查询python3.5的目录地址: 17 | ``` 18 | which python3.5 19 | ``` 20 | 21 | 创建软链接: 22 | ``` 23 | ln -s [目录地址] [软链接地址] 24 | ``` 25 | 删除: 26 | ``` 27 | rm -rf [软链接地址] 28 | ``` 29 | 修改: 30 | ``` 31 | ln -snf [新的目录地址][软链接地址] 32 | ``` 33 | NOTICE: 34 | 35 | * 如果软链接指向失败,可以通过ls查看链接文件的颜色,如果颜色为浅蓝色,说明软链接有效;如果颜色为红色,说明软链接无效;可以删除软链接,重新建立软链接试试。 36 | * 通过在软链接python3的目录里运行指令 ```ls -al python3``` 可以查看python软链接指向哪里。 37 | 38 | ## pip3 39 | ``` 40 | sudo apt-get install python3-pip 41 | ``` 42 | -------------------------------------------------------------------------------- /Ubuntu/ROS.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 18.04 ROS melodic 2 | 3 | ## 安装 4 | [官方安装教程](http://wiki.ros.org/melodic/Installation/Ubuntu),其中第一步使用国内镜像: 5 | ``` 6 | sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list' 7 | ``` 8 | 参考资料:[在Ubuntu 18.04 LTS安装ROS Melodic](https://blog.csdn.net/ZhangRelay/article/details/80241758) 9 | 10 | ### sudo rosdep init 出错 11 | sudo rosdep init 报错: 12 | ``` 13 | ERROR: cannot download default sources list from: 14 | https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list 15 | Website may be down. 16 | ``` 17 | 首先试一试在浏览器中能不能打开,如果打不开的话,说明该网站需要翻墙。 18 | 19 | 因为在终端中安装,所以光浏览器能翻不够,还得配置终端翻墙,配置方法可见 shadowsocks.md 相关教程。 20 | 21 | 成功配置终端翻墙后,如果还报这个错,则需要: 22 | ``` 23 | sudo c_rehash /etc/ssl/certs 24 | sudo -E rosdep init 25 | ``` 26 | 之后再 rosdep update 就可以了。 27 | 28 | 参考资料: 29 | * [sudo rosdep init出错的解决方案](https://zhuanlan.zhihu.com/p/43345574) 30 | * [sudo rosdep init 错误 ](https://wenda.ncnynl.com/question/116401) 31 | 32 | ## 学习教程 33 | [ROS-Tutorials](http://wiki.ros.org/ROS/Tutorials) -------------------------------------------------------------------------------- /Ubuntu/SLAM相关.md: -------------------------------------------------------------------------------- 1 | # SLAM需要的配置 (in 视觉SLAM十四讲) 2 | 3 | ## Eigen 4 | ``` 5 | sudo apt-get install libeigen3-dev 6 | ``` 7 | 之后创建链接: 8 | ``` 9 | sudo ln -sf eigen3/Eigen Eigen 10 | sudo ln -sf eigen3/unsupported unsupported 11 | ``` 12 | 13 | ## OpenCV 14 | 安装依赖项:(其中有些需要新版本) 15 | ``` 16 | sudo apt-get install build-essential libgtk2.0-dev libvtk5-dev libjpeg-dev libtiff4-dev libjasper-dev 17 | libopenexr-dev libtbb-dev 18 | ``` 19 | 在OpenCV官网下载OpenCV for linux (Source),解压后进入目标文件夹cmake: 20 | ``` 21 | mkdir build 22 | cd build 23 | cmake .. 24 | make 25 | sudo make install 26 | ``` 27 | 28 | ### 可能出现程序错误及解决方法 29 | 30 | 一、错误:error while loading shared libraries: libopencv_core.so.3.x: cannot open shared object file: No such file or directory 31 | 32 | 33 | 解决方法: 34 | 35 | 如果共享库文件已经安装到了/lib或/usr/lib目录下,需要再执行一下ldconfig命令: 36 | ``` 37 | sudo ldconfig 38 | ``` 39 | 如果共享库文件安装到了/usr/local/lib(很多开源的共享库都会安装到该目录下)或其它"非/lib或/usr/lib"目录下, 那么在执行ldconfig命令前, 还要把新共享库目录加入到共享库配置文件/etc/ld.so.conf中, 参考[error while loading shared libraries: xxx.so.x" 错误的原因和解决办法](https://www.cnblogs.com/Anker/p/3209876.html) 40 | 41 | 二、错误:Failed to load module "canberra-gtk-module" 42 | 43 | 解决办法: 44 | ``` 45 | sudo apt-get install libcanberra-gtk-module 46 | ``` 47 | 48 | ## PCL 安装 49 | ``` 50 | sudo apt-get install libpcl-dev pcl-tools 51 | ``` 52 | 可能会报错: 53 | 54 | 有一些软件包无法被安装。如果您用的是 unstable 发行版,这也许是 55 | 因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件 56 | 包尚未被创建或是它们已被从新到(Incoming)目录移出。 57 | 下列信息可能会对解决问题有所帮助: 58 | 下列软件包有未满足的依赖关系: 59 | 此时可以这样解决:安装aptitude,aptitude可以比apt-get更加智能地解决依赖问题。 60 | ``` 61 | sudo apt-get install aptitude 62 | sudo aptitude install libpcl-dev 63 | sudo apt-get install pcl-tools 64 | ``` 65 | 66 | ### 查看pcd点云文件 67 | In ternimal: 68 | ``` 69 | pcl_viewer filename.pcd 70 | ``` 71 | 72 | ## Octovis安装 73 | Octovis是八叉树地图及可视化工具。 74 | 75 | 安装: 76 | ``` 77 | sudo apt-get install liboctomap_dev octovis 78 | ``` 79 | 查看bt地图文件:In terminal: 80 | ``` 81 | octovis filename.bt 82 | ``` 83 | 84 | 85 | ## Google GTest 86 | ``` 87 | sudo apt-get install libgtest-dev 88 | 89 | cd /usr/src/gtest 90 | 91 | sudo mkdir build 92 | cd build 93 | sudo cmake .. 94 | sudo make 95 | 96 | # 将生成的libgtest.a 和 libgtest_main.a 拷贝到系统的lib路径下 97 | sudo cp libgtest*.a /usr/local/lib 98 | ``` 99 | 100 | 101 | 102 | ## OpenGL/Glut 103 | 参考:[Installing OpenGL/Glut libraries in Ubuntu](http://kiwwito.com/installing-opengl-glut-libraries-in-ubuntu/) 104 | 105 | The first step is to install the development libraries of OpenGL/Glut in Ubuntu: 106 | ``` 107 | sudo apt-get install freeglut3 freeglut3-dev 108 | ``` 109 | For newer versions of Ubuntu (>= 11.10) you have to install another package because the linker does't link anymore. 110 | ``` 111 | sudo apt-get install binutils-gold 112 | ``` 113 | 114 | -------------------------------------------------------------------------------- /Ubuntu/Terminal常用命令.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 终端常用命令 2 | 3 | ``` 4 | # 列出当前目录下所有文件 5 | ls 6 | 7 | # 删除文件夹 8 | sudo rm- r FOLDER_NAME 9 | 10 | # 删除文件 11 | sudo rm -f FILE_NAME 12 | 13 | 14 | ``` 15 | 16 | ## 压缩/解压文件 17 | 18 | ``` 19 | # 解压 tar.xz 20 | # 分两步: 21 | xz -d FILE_NAME.tar.xz 22 | tar -xvf FILE_NAME.tar 23 | 24 | # 压缩 25 | tar -cvf FILE_NAME 26 | xz -z FILE_NAME 27 | ``` 28 | 29 | ## 下载文件 30 | 31 | 多种用法 [参考](https://www.cnblogs.com/wuheng1991/p/5332764.html) 32 | 33 | ``` 34 | wget URL 35 | ``` 36 | 37 | ## 杀死进程 38 | 39 | ``` 40 | ps -aux # 查看进程 41 | 42 | kill ID # 根据进程编号杀死进程 43 | ``` 44 | 45 | ## 查看磁盘空间 46 | 47 | ``` 48 | df -hl # 查看磁盘剩余空间 49 | df -sh NAME # 查看目录的大小 50 | ``` 51 | 52 | -------------------------------------------------------------------------------- /Ubuntu/VScode.md: -------------------------------------------------------------------------------- 1 | # Ubuntu VScode 相关 2 | 3 | ## ubuntu vscode上使用cmake、编译、调试 4 | 安装VScode插件: 5 | * c++ 6 | * cmake 7 | * cmake-tool 8 | 9 | 编写代码 10 | 11 | 编写CMakeFileLists.txt 12 | 13 | ![2019-11-03 09-21-13 的屏幕截图.png](https://i.loli.net/2019/11/03/P4DIYXcMxoHNuA6.png) 14 | 15 | 上图下方蓝条:点击build 16 | 17 | 选择GCC6.5.0 18 | 19 | 然后编写launch.json文件:  20 | 21 | 按F5,选择default,生成lauch.json文件后将其中的"program"的内容改为:"${workspaceFolder}/build/待执行文件的名字" 22 | 23 | 都搞定之后按F5,就可以直接执行程序了。 24 | 25 | 如果想添加task文件自动cmake,可参考[vscode + cmake + cpp 多文件编译、断点调试](https://blog.csdn.net/zhulinmanbu114/article/details/90754803) 26 | 27 | ### VScode中的图床插件:PicGo 28 | 29 | [PicGo](https://marketplace.visualstudio.com/items?itemName=Spades.vs-picgo),用vscode编辑markdown时,可以安装这个插件,从而很方便地上传并插入图像。 30 | 31 | 操作|快捷键 32 | ---|--- 33 | Uploading an image from clipboard | Ctrl + Alt + U 34 | Uploading images from explorer | Ctrl + Alt + E 35 | Uploading an image from input box | Ctrl + Alt + O 36 | -------------------------------------------------------------------------------- /Ubuntu/apt-get & pip换国内源.md: -------------------------------------------------------------------------------- 1 | # 换国内源 2 | 3 | ## apt-get 换国内源 4 | 5 | 备份源文件: 6 | ``` 7 | cd /etc/apt/ 8 | sudo cp sources.list sources.list.bk 9 | ``` 10 | 之后编辑源文件: 11 | ``` 12 | sudo gedit sources.list 13 | ``` 14 | 将内容改为:[Ubuntu 镜像使用帮助 | 清华大学开源软件镜像站](https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/) 15 | 16 | 之后更新: 17 | ``` 18 | sudo apt-get update # 更新源 19 | sudo apt-get upgrade # 更新软件 20 | ``` 21 | 22 | ## pip 换国内源 23 | 注意:pip和pip3的操作方式一样。 24 | 25 | 首先在当前用户目录下建立文件夹.pip,然后在文件夹中创建pip.conf文件,再将源地址加进去即可。 26 | ``` 27 | sudo mkdir ~/.pip 28 | sudo nano ~/.pip/pip.conf 29 | ``` 30 | 31 | 然后将下面这两行复制进去就好了 32 | ``` 33 | [global] 34 | timeout = 6000 35 | index-url = https://pypi.tuna.tsinghua.edu.cn/simple 36 | trusted-host = pypi.tuna.tsinghua.edu.cn 37 | ``` 38 | 39 | *** 40 | 参考资料: 41 | 42 | [pip/pip3更换国内镜像源|CSDN](https://blog.csdn.net/zwliang98/article/details/83546788) 43 | 44 | [pip或pip3更换源为国内源|Linux公社](https://www.linuxidc.com/Linux/2019-04/158178.htm) 45 | -------------------------------------------------------------------------------- /Ubuntu/caffe.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 18.04 caffe 2 | 3 | # caffe-cpu 4 | 5 | ## 安装 6 | [官网教程](http://caffe.berkeleyvision.org/install_apt.html),其中提到 18.04 可以通过 apt-get 直接安装,但实测好像只装了 python 版本,没有找到 cpp 等源码在哪里。所以还是得通过源码编译安装。 7 | 8 | ### 安装依赖 9 | ``` 10 | sudo apt install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler 11 | sudo apt install -y --no-install-recommends libboost-all-dev 12 | sudo apt install -y libatlas-base-dev 13 | sudo apt install -y libgflags-dev libgoogle-glog-dev liblmdb-dev 14 | ``` 15 | [参考资料](https://github.com/BVLC/caffe/issues/2704) 16 | 17 | ### 下载源码 18 | ``` 19 | git clone https://github.com/BVLC/caffe.git 20 | cd caffe 21 | ``` 22 | 23 | ### 修改 CMakeLists.txt 24 | 可以使用 makefile,也可以使用 cmake,这里使用 cmake。 25 | 26 | 为了安装 caffe-cpu,CMakeList.txt 需要做修改: 27 | ``` 28 | caffe_option(CPU_ONLY "Build Caffe without CUDA support" ON) # 从 OFF 改为 ON 29 | 30 | set(python_version "3" CACHE STRING "Specify which Python version to use") # 从 "2" 改成 "3" 31 | ``` 32 | [参考资料](https://github.com/BVLC/caffe/pull/1667) 33 | 34 | ### 编译 35 | ``` 36 | mkdir build 37 | cd build 38 | cmake .. 39 | make all 40 | make install 41 | make runtest 42 | ``` 43 | [参考资料](http://caffe.berkeleyvision.org/installation.html#compilation) 44 | 45 | ## 使用 caffe-cpu 的其他项目,在编译时报错 cublas_v2.h can't find 46 | 47 | 这是因为没有安装 cuda,自然也没有 cublas_v2.h。但 caffe-cpu 不需要 cuda。在 caffe 编译的过程中,通过设置 48 | ``` 49 | caffe_option(CPU_ONLY "Build Caffe without CUDA support" ON) # 从 OFF 改为 ON 50 | ``` 51 | 避免了这个问题,但这个问题在其他使用 caffe-cpu 的项目编译时再次出现。 52 | 53 | 解决办法,在项目的 CMakeLists.txt 中添加: 54 | ``` 55 | add_definitions( -DCPU_ONLY=1 ) 56 | ``` 57 | [参考资料](https://github.com/BVLC/caffe/issues/2704) 58 | 59 | # caffe-cuda + anaconda3 + python2.7 60 | 61 | [官网教程](http://caffe.berkeleyvision.org/install_apt.html) 62 | 63 | #### 首先安装相关依赖 64 | 65 | ``` 66 | sudo apt build-dep caffe-cuda # dependencies for CUDA version 67 | 68 | # 似乎不全,上文cpu教程中的那些依赖也装了吧 69 | ``` 70 | 71 | #### 下载源码 72 | 73 | eg. 下载在 ~/ 74 | 75 | ``` 76 | git clone https://github.com/BVLC/caffe.git 77 | cd caffe 78 | ``` 79 | 80 | #### 建立anaconda虚拟环境 81 | 82 | ``` 83 | conda create --name ENV_NAME python=2.7 # ENV_NAME 可以命名为caffe_py27 84 | 85 | source activate ENV_NAME 86 | 87 | # 在该环境内安装caffe相关依赖 88 | cd ~/caffe/python 89 | for req in $(cat requirements.txt); do pip install $req; done 90 | ``` 91 | 92 | #### 修改caffe/Makefile.config 93 | 94 | ``` 95 | cp Makefile.config.example Makefile.config 96 | # 在Makefile.config中进行修改 97 | ``` 98 | 99 | 去掉注释: USE_CUDNN := 1 100 | 101 | 去掉注释: OPENCV_VERSION := 3 102 | 103 | 去掉注释:CUDA_DIR := /usr/local/cuda (检查cuda的path对不对) 104 | 105 | CUDA_ARCH中按提示注释掉该注释的 106 | 107 | 注释:PYTHON_INCLUDE 108 | 109 | 去掉注释:ANACONDA_HOME 及后面几行,注意修改为 anaconda 虚拟环境中 python 的 path。eg: ANACONDA_HOME := $(HOME)/anaconda3/envs/ENV_NAME 110 | 111 | 注释:PYTHON_LIB := /usr/lib 112 | 113 | 去掉注释:PYTHON_LIB := $(ANACONDA_HOME)/lib 114 | 115 | 去掉注释:WITH_PYTHON_LAYER := 1 116 | 117 | 在相应位置进行如下修改:否则运行时报错 没有"hdf5.h" [参考](https://github.com/BVLC/caffe/issues/2690) 118 | 119 | ``` 120 | # Whatever else you find you need goes here. 121 | INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/ 122 | LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/ 123 | ``` 124 | 125 | #### 编译 126 | 127 | 使用 make 不使用 cmake 128 | 129 | ``` 130 | make all -j4 131 | make test 132 | make runtest 133 | make pycaffe 134 | make distribute 135 | ``` 136 | 137 | #### 其他操作 138 | 139 | 运行时报错:fatal error: caffe/proto/caffe.pb.h: No such file or directory 140 | 141 | 解决:[参考](https://github.com/muupan/dqn-in-the-caffe/issues/3) 142 | 143 | ``` 144 | # In the directory you installed Caffe to 145 | protoc src/caffe/proto/caffe.proto --cpp_out=. 146 | mkdir include/caffe/proto 147 | mv src/caffe/proto/caffe.pb.h include/caffe/proto 148 | ``` 149 | 150 | 另外,若使用 make 安装的 头文件目录在 ~/caffe/include,而如果使用 cmake 安装的头文件目录在 ~/caffe/build/install/include。在使用caffe的项目中,需要注意caffe的路径 151 | 152 | 为了使用pycaffe,需要进行如下操作才能正常 import caffe: [参考](https://yangcha.github.io/Caffe-Conda/) 153 | 154 | ``` 155 | sudo gedit ~/.bashrc 156 | 157 | # 在末尾添加 158 | export PYTHONPATH=~/caffe/python:${PYTHONPATH:+:${PYTHONPATH}} 159 | 160 | # 更新 161 | source ~/.bashrc 162 | ``` 163 | 164 | 重启终端。 165 | 166 | # 在服务器安装时出现的问题 167 | 168 | 1. 重装一下 cudnn -------------------------------------------------------------------------------- /Ubuntu/firefox.md: -------------------------------------------------------------------------------- 1 | # Ubuntu18.04 安装最新版firefox浏览器(国内版) 2 | 3 | firefox浏览器分:国际版和国内版。 4 | 5 | 二者之间账户不互通(我可以用同一个邮箱分别在国际版和国内版上注册) 6 | 7 | 所以,如果想同步书签啥的的化,需要统一使用国内版。 8 | 9 | windows上官网下载的就是国内版。 10 | 11 | ubuntu默认安装(apt-get)的firefox是国际版,所以需要自己去官网下载最新的国内版 12 | 13 | ## 安装 14 | 15 | 先卸载国际版: 16 | ``` 17 | sudo apt-get remove firefox 18 | ``` 19 | 20 | [Firefox官网](http://www.firefox.com.cn/), 下载下来的是一个tar.bz2文件。(解压后其中/foxfire/foxfire可以直接绿色运行(可能需要邮件属性更改为可执行)) 21 | 22 | 之后: 23 | 24 | ``` 25 | # 解压该文件 26 | tar -xvf Firefox-latest-x86_64.tar.bz2 27 | 28 | # 将解压的中文版 Firefox 移动到应该的位置 29 | sudo mv firefox /opt 30 | 31 | cd /usr/share/applications 32 | 33 | # 创建firefox.desktop文件 34 | sudo touch firefox.desktop 35 | 36 | sudo gedit firefox.desktop 37 | ``` 38 | 编辑内容为: 39 | ``` 40 | [Desktop Entry] 41 | Name=firefox 42 | Name[zh_CN]=火狐浏览器 43 | Comment=火狐浏览器 44 | Exec=/opt/firefox/firefox 45 | Icon=/opt/firefox/browser/chrome/icons/default128.png #可能在其他位置 46 | Terminal=false 47 | Type=Application 48 | Categories=Application 49 | Encoding=UTF-8 50 | StartupNotify=true 51 | ``` 52 | 保存后退出,重启后应该可以了。 53 | ``` 54 | sudo reboot 55 | ``` 56 | 在DASH下搜索firefox即可找到我们安装的中文版火狐浏览器了,拖到Dock中固定即可。 57 | 58 | **但是,火狐的图标未能正确显示,可以点开,但图标缺失(透明)** 59 | 60 | ## 使用shadowsocks科学上网 61 | 62 | 在shadowsocks已经配置好的情况下,chrome已经可以科学上网,但firefox不行。 63 | 64 | 需要再配置:Firefox-首选项-常规-网络设置: 65 | * 手动配置代理: SOCKS主机:127.0.0.1 端口:1080 66 | * 下方勾选“使用SOCKS v5时代理DNS查询”。 -------------------------------------------------------------------------------- /Ubuntu/gym.md: -------------------------------------------------------------------------------- 1 | [gym官方网站](http://gym.openai.com/docs/#getting-started-with-gym) 2 | 3 | ## Installation 4 | ``` 5 | pip3 install gym 6 | ``` 7 | 8 | ## gym-gazebo 9 | [gym-gazebo官网](https://github.com/erlerobot/gym-gazebo/) 10 | 11 | 然后跟着教程链接一点一点做就行了 12 | 13 | NOTICE:最后gzclient打开的方法,要在gym-gazebo的安装目录下打开terminal,另外教程中的第一步(source ...)可以不做。 14 | 15 | ## Mujoco 16 | [Mujoco-py Installation](https://github.com/openai/mujoco-py#obtaining-the-binaries-and-license-key) 17 | 18 | [mujoco-py Documentation](https://openai.github.io/mujoco-py/build/html/index.html#mujoco-py-documentation) 19 | 20 | 仿真GUI操作方法:[MjViewer: 3D rendering](https://openai.github.io/mujoco-py/build/html/reference.html#mjviewer-3d-rendering) 21 | -------------------------------------------------------------------------------- /Ubuntu/matebook修改boot启动顺序.md: -------------------------------------------------------------------------------- 1 | # matebook14 修改boot启动顺序 2 | 在终端中输入: 3 | ``` 4 | sudo efibootmgr 5 | ``` 6 | 可以看到当前的启动项和启动顺序 7 | 8 | 修改启动顺序: 9 | ``` 10 | efibootmgr -o X,Y # 指定标号为X的启动项顺序在Y之前,注意要包括所有启动项 11 | ``` 12 | -------------------------------------------------------------------------------- /Ubuntu/nvidiadriver_cuda_cudnn.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 18.04 安装 NVIDIA Driver + cuda + cudnn 2 | 3 | ## 安装 NVIDIA driver 4 | 5 | 在 软件和更新 中选择 附加驱动,选择合适的驱动,点击应用更改。 6 | 7 | 之后重启电脑。 8 | 9 | 终端输入 ```nvidia-smi``` 查看是否成功安装. 10 | 11 | 注意:430是长期支持,435是短期支持。 12 | 13 | ## 安装 cuda 14 | 15 | 注意:cuda 有两个API,一个是和driver装在一起的,另一个是需要在这里单独安装的。两者的版本不用相同。[参考](https://stackoverflow.com/questions/53422407/different-cuda-versions-shown-by-nvcc-and-nvidia-smi) 16 | 17 | 参考 [Ubuntu18.04安装CUDA10、CUDNN](https://blog.csdn.net/qq_32408773/article/details/84112166) 18 | 19 | https://developer.nvidia.com/cuda-toolkit-archive 找到合适的版本下载 20 | 21 | 所有配置选项选好之后,选择runfile(local),下载 22 | 23 | 之后,在下载目录中: 24 | 25 | ``` 26 | sudo sh cuda_10.0.130_410.48_linux.run 27 | ``` 28 | 29 | 之后会出一个声明,不断按Enter看下一行,直到最后。 30 | 31 | 之后, 32 | 33 | ![](https://pic1.zhimg.com/80/v2-d0cbc3346c466bb90d7566ae6a904cb4_720w.jpg) 34 | 35 | 注意:Install NVIDIA Accelerated Graphics Driver for ... 选择no 36 | 37 | 如果想同时安装多版本的cuda,参考[知乎-Ubuntu安装 cuda10 + cudnn7.5 + Tensorflow2.0](https://zhuanlan.zhihu.com/p/65557545) 38 | 39 | 配置到环境变量: 40 | 41 | ``` 42 | sudo gedit ~/.bashrc 43 | 44 | # 打开文件后,在文件末尾添加路径 45 | export PATH=/usr/local/cuda-10.0/bin:$PATH 46 | export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH  47 | 48 | # 之后更新 49 | source ~/.bashrc 50 | ``` 51 | 52 | !!!特别重要: 53 | 54 | ``` 55 | sudo apt install xserver-xorg-input-all 56 | 57 | # 如果没进行这步,重启电脑后进入ubuntu桌面后,鼠标键盘均无法操作 58 | ``` 59 | 60 | 重启。如果重启后出现鼠标键盘无法操作状况:[参考](https://blog.csdn.net/qq_38145502/article/details/104898072)。之后cuda安装完毕。 61 | 62 | 测试是否安装成功: 63 | 64 | ``` 65 | cd /usr/local/cuda/samples/1_Utilities/deviceQuery 66 | sudo make 67 | ./deviceQuery 68 | ``` 69 | 70 | 出 Result = PASS 则安装成功. 71 | 72 | ## 安装 cudnn 73 | 74 | 在[官网](https://developer.nvidia.com/cudnn)下载安装包,需要注册登录才能下载。选择适合自己的版本(要与cuda的版本对应) 75 | 76 | [官网安装教程](https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html),使用Tar File 进行安装。验证工作不用做。 77 | 78 | 查看安装的 cuda cudnn 版本:[参考](https://medium.com/@changrongko/nv-how-to-check-cuda-and-cudnn-version-e05aa21daf6c) 79 | 80 | ``` 81 | # 查看cuda 82 | cat /usr/local/cuda/version.txt 83 | 84 | # 查看cudnn 85 | cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2 86 | ``` 87 | 88 | ### CUDNN_STATUS_INTERNAL_ERROR 89 | 90 | [参考](https://github.com/tensorflow/tensorflow/issues/24496) 91 | 92 | 大概原因是显存不足,没有找到合适的解决办法。如果有的时候能运行有的时候运行不了,说明运行不了的时候是因为其他进程占用显存过多。重启再运行能解决。 -------------------------------------------------------------------------------- /Ubuntu/opencv.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 18.04 安装 opencv 2 | 3 | ## Python 4 | 5 | 使用 SIFT: (版本不能高于3.4.2,高版本中 SIFT 因为专利原因无法直接使用) [参考](https://github.com/skvark/opencv-python/issues/126#issuecomment-577818046) 6 | 7 | ``` 8 | pip install opencv-contrib-python==3.4.2.17 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /Ubuntu/peek-ubuntu录屏软件.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 录屏软件 peek 2 | 3 | 安装及使用教程可见:(https://www.jianshu.com/p/9069991bbce6) 4 | 5 | -------------------------------------------------------------------------------- /Ubuntu/pppoe拨号上网.md: -------------------------------------------------------------------------------- 1 | # Ubuntu18.04 pppoe 拨号上网 2 | 3 | ## 据测试不太好用 4 | 首先,关闭有线连接,同时,有线连接设置中的“自动连接”不能勾选。 5 | 6 | 之后: 7 | ``` 8 | sudo pppoeconf 9 | ``` 10 | 之后输入用户名(删除username)和密码。 11 | 12 | 一路yes即可。 13 | 14 | ``` 15 | # 启动 16 | sudo pon dsl-provider 17 | 18 | # 关闭 19 | sudo poff dsl-provider 20 | ``` 21 | 22 | ## 好用的 23 | In Terminal: 24 | ``` 25 | nmcli con edit type pppoe con-name "networkname" # networkname 随便起 26 | 27 | set pppoe.username wrangler # wrangler是我的校园网账户名 28 | save 29 | quit 30 | ``` 31 | 之后打开右上角网络设置,可以看到自己添加的networkname的网络。 32 | 33 | 点它,点设置图标,不填写,会弹出一个黑色的框框,里面填入 服务:networkname,密码:账号密码。之后点确定,框框不会消失,再点取消就可以了。(不出现框框的话就把这个网络删除,重新创建一个。删除方法如下文) 34 | 35 | 设置-常规里面选中自动连接。 36 | 37 | 有线网络1的设置-常规里面不选中自动连接。 38 | 39 | 这样基本就好了,以后连接该网络就可以直接点这个了。但是重启后会显示有线网络未托管。解决方法: 40 | ``` 41 | sudo gedit /etc/NetworkManager/NetworkManager.conf # 打开后,找到 [ifupdown] managed=false 修改成: [ifupdown] managed=true 42 | 43 | sudo service network-manager restart # 其他地方可以也会用到 44 | ``` 45 | 之后再重启就不会有这个问题了。 46 | 47 | 接入XJTU校园网需要在10.6.8.2上登录。 48 | 49 | ### 查看曾经创建的网络(创建、删除) 50 | ``` 51 | # sudo打开文件管理器 52 | sudo nautilus 53 | ``` 54 | 之后找到/usr/share/applications/Network connections,里面可以看到创建的网络,也可以创建网络和删除网络。 -------------------------------------------------------------------------------- /Ubuntu/pytorch.md: -------------------------------------------------------------------------------- 1 | # Ubuntu18.04 pytorch 2 | 3 | ## 安装 4 | [pytorch安装](https://pytorch.org/get-started/locally/)官网指南,选择对应的版本进行安装。 5 | 6 | ## pytorch使用教程 7 | [pytorch-tutorial](https://pytorch.org/tutorials/beginner/blitz/tensor_tutorial.html#sphx-glr-beginner-blitz-tensor-tutorial-py) -------------------------------------------------------------------------------- /Ubuntu/shadowsocks.md: -------------------------------------------------------------------------------- 1 | # ubuntu 中配置shadowsocks 2 | 3 | 4 | ### 安装及初始配置 5 | 安装shadowsocks3.0: 6 | ``` 7 | sudo pip3 install https://github.com/shadowsocks/shadowsocks/archive/master.zip -U 8 | ``` 9 | 10 | 配置: 11 | ``` 12 | sudo nano /etc/shadowsocks.json 13 | ``` 14 | 内填入: 15 | 16 | ``` 17 | { 18 | "server":"服务器的ip", 19 | "server_port":xxxxx, 20 | "local_address":"127.0.0.1", 21 | "local_port":1080, 22 | "password":"密码", 23 | "timeout":300, 24 | "method":"aes-256-gcm" 25 | } 26 | ``` 27 | 28 | ### 每次开机 29 | 30 | 运行: 31 | ``` 32 | sslocal -c /etc/shadowsocks.json 33 | ``` 34 | 之后配置网络代理:ubuntu设置-网络-网络代理-手动:在Socks中填入127.0.0.1和1080。 35 | 36 | 若不运行,需要讲网络代理再改回来 37 | 38 | 39 | ## 终端翻墙 40 | 41 | ### 安装及初始配置 42 | **安装 Polipo:** Shadowsocks 默认是用 Socks5 协议的,对于 Terminal 的 get,wget 等走 Http 协议的地方是无能为力的,所以需要转换成 Http 代理,加强通用性。 43 | ``` 44 | sudo apt-get install polipo 45 | ``` 46 | 修改配置文件: 47 | ``` 48 | sudo gedit /etc/polipo/config 49 | ``` 50 | 将下面的内容整个替换到文件中并保存: 51 | ``` 52 | # This file only needs to list configuration variables that deviate 53 | # from the default values. See /usr/share/doc/polipo/examples/config.sample 54 | # and "polipo -v" for variables you can tweak and further information. 55 | logSyslog = false 56 | logFile = "/var/log/polipo/polipo.log" 57 | 58 | socksParentProxy = "127.0.0.1:1080" 59 | socksProxyType = socks5 60 | 61 | chunkHighMark = 50331648 62 | objectHighMark = 16384 63 | 64 | serverMaxSlots = 64 65 | serverSlots = 16 66 | serverSlots1 = 32 67 | 68 | proxyAddress = "0.0.0.0" 69 | proxyPort = 8123 70 | ``` 71 | 重启 Polipo: 72 | ``` 73 | /etc/init.d/polipo restart 74 | ``` 75 | 76 | ### 需要终端翻墙时: 77 | 启动 Polipo: 78 | ``` 79 | /etc/init.d/polipo start 80 | ``` 81 | 82 | 在需要翻墙的终端中配置代理(以下配置只对当前终端有效),在终端输入: 83 | ``` 84 | export http_proxy="http://127.0.0.1:8123/" 85 | export https_proxy="https://127.0.0.1:8123/" 86 | ``` 87 | (Optional)输入查看代理的设置情况: 88 | ``` 89 | env | grep proxy 90 | ``` 91 | 如果想撤销当前会话的http_proxy代理,使用: 92 | ``` 93 | unset http_proxy 94 | unset https_proxy 95 | ``` 96 | 97 | 参考资料: 98 | * [Ubuntu配置Shadowsocks实现终端代理](https://www.meirenji.info/2017/12/09/Ubuntu%E9%85%8D%E7%BD%AEShadowsocks%E5%AE%9E%E7%8E%B0%E7%BB%88%E7%AB%AF%E4%BB%A3%E7%90%86/) 99 | * [为终端设置Shadowsocks代理](https://droidyue.com/blog/2016/04/04/set-shadowsocks-proxy-for-terminal/) -------------------------------------------------------------------------------- /Ubuntu/tty.md: -------------------------------------------------------------------------------- 1 | # tty 文本模式 2 | ctrl + alt + F1~F6 分别为6个tty; +F7为返回图形界面 (lightdm模式下) 3 | 4 | ## login 5 | 用户名:ymr(terminal中@之前的名字是用户名) 6 | password:密码 7 | 8 | 出现sudo 框框框框:输入密码 9 | -------------------------------------------------------------------------------- /Ubuntu/个人主页jekyll+GitHub Pages.md: -------------------------------------------------------------------------------- 1 | # 基于 jekyll 和 GitHub Pages 搭建个人主页 2 | 3 | ## 使用GitHub Pages搭建个人主页 4 | 在github上建立一个repo,名为"username.github.io" (eg: Mingrui-Yu.github.io) 5 | 6 | 将此repo clone到本地。 7 | 8 | ## 使用jekyll-theme-next主题搭建个人主页 9 | clone the repo [jekyll-theme-next on GitHub](https://github.com/Simpleyyt/jekyll-theme-next) 10 | 11 | 将里面的内容全部复制到刚才自己建立"username.github.io" repo中。 12 | 13 | 此时git push一下,就可以在https://mingrui-yu.github.io看到自己的个人主页了。 14 | 15 | 这里可以用jekyll进行本地编辑 [参考文档](http://theme-next.simpleyyt.com/getting-started.html),但我没试成功,以后有空再试,现在先不断push,凑合着用。 16 | 17 | ## 编辑主页的内容 18 | 19 | Next主题具有详细的[说明文档](http://theme-next.simpleyyt.com/),其中常用的内容包括: 20 | * 更改Scheme,我使用Pisces 21 | * 更改菜单栏的内容,若要添加一项菜单,总共需要修改: 22 | * config中menu下属目录。 23 | * _data/languages/{language}.yml中对应的菜单项显示文本。 24 | * _data/languages/{language}.yml中对应的菜单项显示图标。 25 | * 在repo根目录下添加相应文件夹,其中写index.md文件,layout选用pages。 26 | * 侧栏的设置 27 | * 社交链接 28 | * 个人照片:需要将个人照片放在/assets/images/目录下。同时,讲config中Sidebar Avatar下面的in directory和avatar后面都加上图片的位置(eg: /assets/images/mingrui.jpg) 29 | * 新的文章放在_post文件夹中 30 | * 命名需要用'2019-11-30-name'的格式来命名,否则报错。 31 | * 添加categories 32 | * 添加tags 33 | * 设置背景动画(取消动画) -------------------------------------------------------------------------------- /Ubuntu/常用文件夹固定到File左侧.md: -------------------------------------------------------------------------------- 1 | # Ubuntu下 将常用文件夹固定到File左侧 2 | 3 | 将盖文件夹拖动到File左侧栏,此时File左侧栏会显示新建书签,此时拖动到“新建书签”位置即可。 -------------------------------------------------------------------------------- /Ubuntu/微信.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 18.04 下基于 deepin-wine 安装微信 2 | 3 | GitHub 项目地址:( https://github.com/wszqkzqk/deepin-wine-ubuntu ),参照其中说明文档即可。 4 | 5 | 其中容器的安装,也可参考 https://zhuanlan.zhihu.com/p/73033900 6 | 7 | ## 安装后的问题 8 | 9 | ### 中文字体显示为方块 10 | 11 | 参考 https://github.com/wszqkzqk/deepin-wine-ubuntu/issues/136#issuecomment-513047538 以及 https://github.com/wszqkzqk/deepin-wine-ubuntu/issues/136#issuecomment-514585722 两个步骤。 12 | 13 | ### 屏幕中央显示黑色方框 14 | 15 | 参考https://github.com/wszqkzqk/deepin-wine-ubuntu/issues/72#issuecomment-555400352 ,把微信语言换成引文即可。 16 | 17 | -------------------------------------------------------------------------------- /Ubuntu/思维导图软件.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 思维导图软件 MindMaster 2 | 3 | 下载:https://www.edrawsoft.cn/download/mindmaster/all/ -------------------------------------------------------------------------------- /Ubuntu/搜狗输入法.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 下搜狗输入法相关 2 | 3 | ## 安装 4 | [Ubuntu18.04下安装搜狗输入法](https://blog.csdn.net/lupengCSDN/article/details/80279177) 5 | 6 | 注意,其中似乎不需要讲搜狗输入法的位置调到第一个。 7 | 8 | [Ubuntu18.04搜狗输入法选词面板乱码](https://blog.csdn.net/qq_40965177/article/details/82049254) 9 | 10 | ## 利用中文输入法打出的英文变宽 11 | 在设置里更改半角/全角即可。 12 | -------------------------------------------------------------------------------- /Ubuntu/服务器上的配置.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ``` 4 | # 安装 nano 5 | apt-get install nano 6 | 7 | # 安装 locate 8 | apt-get install mlocate 9 | sudo updatedb 10 | ``` 11 | 12 | cuda 添加到bash 13 | 14 | 将 cudnn 复制到 /usr/local/cuda 中: 15 | 16 | ``` 17 | cp /usr/include/cudnn.h /usr/local/cuda/include 18 | cp /usr/lib/x86 (具体是啥不记得了) /libcudnn* /usr/local/cuda/lib64 19 | chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* 20 | ``` 21 | 22 | 安装 anaconda 23 | 24 | apt-get 加入 deb-src 25 | 26 | ``` 27 | cd /etc/apt/ 28 | nano sources.list 29 | 30 | # 每一行都复制一下添加一行,前缀改为 deb-src 31 | 32 | # 之后 33 | apt-get update 34 | apt-get upgrade 35 | ``` 36 | 37 | 38 | 39 | 安装 caffe 相关依赖,之后 nvidia-smi 会显示 driver/library mismatch,解决办法: [参考]() 40 | 41 | ``` 42 | apt-get purge nvidia* 43 | # 之后按提示删除不用的依赖项 44 | ``` 45 | 46 | 之后正常操作,安装 caffe。 47 | 48 | 一切配置好后 import caffe 出错(这些错误本地配置的时候没有出现): 49 | 50 | ERROR: /usr/lib/libgdal.so.20: undefined symbol: sqlite3_column_table_name [参考](https://blog.csdn.net/likejoey/article/details/83751786) 51 | 52 | ``` 53 | # 解决:在虚拟环境中 54 | conda update sqlite 55 | ``` 56 | 57 | 另外,在虚拟环境中 ```for req in $(cat requirements.txt); do pip install $req; done ```的时候有些东西可能因为版本问题没有装上,需要手动安装,见红字标识。其中 scikit-image 的安装 [参考](https://blog.csdn.net/xumi13/article/details/104605881/) 58 | 59 | 注意 pip 还是不要升级的好。[pip版本降级](https://blog.csdn.net/TZJD89/article/details/87971232) 60 | 61 | 62 | 63 | ## calc 64 | 65 | ./main.py 时 Permission Denied 66 | 67 | ``` 68 | chmod +x main.py 69 | ``` 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /Ubuntu/用不用sudo的区别.md: -------------------------------------------------------------------------------- 1 | # 用不用sudo的区别 2 | 3 | ## python 和 sudo python 4 | 5 | 直接运行```python```,执行的是/usr/local/bin/python; 6 | 7 | 运行```sudo python```,执行的是/usr/bin/python; -------------------------------------------------------------------------------- /Ubuntu/翻译软件GoldenDict.md: -------------------------------------------------------------------------------- 1 | # ubuntu18.04 翻译软件GoldenDict安装配置 2 | 3 | [Ubuntu 18.04 LTS版本 GoldenDict安装与配置](https://www.cnblogs.com/creasing/p/11333728.html) 4 | 5 | ## 屏幕取词 6 | 选中单词后,按下快捷键 Ctrl+C+C 7 | -------------------------------------------------------------------------------- /Ubuntu/解决ubuntu安装软件has install-snap change in progress错误.md: -------------------------------------------------------------------------------- 1 | https://blog.csdn.net/dyxcome/article/details/86105724 2 | 3 | -------------------------------------------------------------------------------- /Ubuntu/解决ubuntu改变win系统时间.md: -------------------------------------------------------------------------------- 1 | # 安装Ubuntu导致Windows时间错误解决方案 2 | 3 | Ubuntu 默认硬件时间为UTC(Coordinated Universal Time)即协调世界时,中国时间为UTC+8;而Windows则认定硬件时间为系统时间。这就造成了当先开启Ubuntu系统时,系统从网络得到本地时间例如为8点钟,然后其修改硬件时间为0点,再次启用Windows时,Windows读取硬件时间为本地时间,这就造成了系统显示时间比实际时间慢8小时的问题 4 | 5 | 目前通用的解决方法有两种:一种是修改Ubuntu系统时间的读取方式,另一种是修改Windows系统时间的读取方式。在此推荐修改Ubuntu系统,因为修改方式极其简单。 6 | 7 | 在终端输入: 8 | ``` 9 | #安装时间校准服务 10 | sudo apt-get install ntpdate 11 | 12 | #从time.windows.com获取本地时间 13 | sudo ntpdate time.windows.com 14 | 15 | #同步时间到硬件 16 | sudo hwclock --localtime --systohc 17 | ``` -------------------------------------------------------------------------------- /Ubuntu/解决ubuntu触控板右键失灵.md: -------------------------------------------------------------------------------- 1 | # 解决unbuntu18.04触控板右键失灵 2 | 3 | [最新的ubuntu 18.04触控板右键失灵的解决方法](https://blog.csdn.net/qq_36317016/article/details/80143557) 4 | -------------------------------------------------------------------------------- /Ubuntu/运行可执行文件.md: -------------------------------------------------------------------------------- 1 | # Ubuntu 执行exe文件 2 | 3 | ubuntu18.04 LTS下执行属性为executable (application/x-executable)的文件的方法: 4 | 5 | 1. chmod +x filename 6 | 7 | 2. ./filename 就可以执行了 8 | 9 | 注:把filename替换为你要安装的文件名。 10 | -------------------------------------------------------------------------------- /WIN/EndNote.md: -------------------------------------------------------------------------------- 1 | # win10 安装使用 Endnote x9 2 | 3 | ## 安装 4 | 5 | [参考](https://zhuanlan.zhihu.com/p/61958997) 6 | 7 | ## 使用 8 | 9 | [Endnote 插入文献导致word崩溃!!解决方法](https://blog.csdn.net/u012236241/article/details/87910304) 10 | 11 | [解决误识别中括号、自动搜索中括号](https://jingyan.baidu.com/article/fc07f98956c52e12fee5196a.html) 12 | 13 | [在endnote中制作GB/T7714《文后参考文献著录规则》的输出格式](http://blog.sciencenet.cn/blog-485-448980.html) 14 | 15 | [GB/T 7714-2015格式文件](https://cnzhx.net/blog/endnote-output-style-cnzhx/) (endnote 官网提供的不准确) 16 | 17 | [修改Endnote插入Word参考文献中位置](https://blog.csdn.net/qq_21095607/article/details/60868392) 18 | 19 | ## 配置使用GB/T 7714-2015 20 | 21 | 具体的规则可见该标准的[pdf](http://www.ggzzchina.com/Upload/2016-02/20160223155134487.pdf) 22 | 23 | Style 文件下载:[GB/T 7714-2015格式文件](https://cnzhx.net/blog/endnote-output-style-cnzhx/) 24 | 25 | word中无法正常导入该Sytle:上述网址中也有响应的解决方案 26 | 27 | ### 参考文献的缩进不正确 28 | 29 | 具体表现为:第一行缩进了,第二行却没缩进。应该第一行不缩进,第二行与第一行的文字部分对齐。 30 | 31 | 第一步: 32 | 33 | Word工具栏 - 开始 - 样式 - 第三个向下的箭头 - 应用样式 - 修改 34 | 35 | “样式基准”改为无样式 36 | 37 | 第二步: 38 | 39 | Endnote中 编辑 - 输出样式 - 编辑XXX样式 - 参考文献 - 布局 40 | 41 | 右上角 - 插入字段:制表符 (如果没有这一步,word中参考文献序号是1位数和2位数时对不齐) 42 | 43 | 右下角 - 悬挂式缩进:选择全部段落 44 | 45 | Ctrl + s 保存 46 | 47 | 第三步: 48 | 49 | Word工具栏 - EndNote - Bibliography - 右下角箭头 - Layout - 左下方Hanging indent:调整为合适的值(多试试,大概0.8cm)- 确定 50 | 51 | 第四步: 52 | 53 | Word工具栏 - 开始 - 样式 - 第三个向下的箭头 - 应用样式 - 修改 54 | 55 | 左下角-格式:根据需要调整字体、行距等等 56 | 57 | ### 修改会议的参考文献格式 58 | 59 | 需要将 [C].XXXXComference 改为 [C]// XXXXConference -------------------------------------------------------------------------------- /WIN/Latex相关.md: -------------------------------------------------------------------------------- 1 | # Latex相关 2 | 3 | CTex下载:https://mirrors.tuna.tsinghua.edu.cn/ctex/legacy/2.9/ 4 | full版本 5 | 6 | CTex安装:https://blog.csdn.net/sinat_41805381/article/details/80185144 7 | 8 | Texstudio下载:https://sourceforge.net/projects/texstudio/ 9 | 安装:https://www.cnblogs.com/dingruihfut/p/9690073.html 10 | 11 | MikTex下载:https://miktex.org/download 12 | 安装在CTex的文件夹中,覆盖原来的MikTex文件夹 13 | 14 | ## 自动化学报latex模板(这就是个傻逼) 15 | 16 | 居然图片和引用的下标都是手打,我服。 17 | 18 | [官方模板下载](http://www.aas.net.cn/UserFiles/File/aas_template.zip) 19 | 20 | [编译中缺少picins:下载picins宏包](http://mirrors.ctan.org/macros/latex209/contrib/picins.zip),将picins.sty文件拷贝至for chinese paper文件夹里。 21 | 22 | ## 计算机学报latex模板 23 | [官方模板下载](http://cjc.ict.ac.cn/wltg/new/submit/LatexTemplet.zip) 24 | 25 | ### TexStudio界面中中文乱码: 26 | 选项-设置TexStudio-编辑器-默认字体编码: 选GBK。 27 | 28 | ### 使用PDFLatex进行构建 29 | 构建的构成中会出现``` 30 | Sorry, but miktex-makemf did not succeed. The log file hopefully contains ...```的错误 31 | 32 | 经试验发现,是在引用\begin{CJK*}{GBK}{xxx}的时候就会出现这个错误。 33 | 34 | 实验发现,不用管他,等着,让他一直运行,跑完整个文档后就好了。 -------------------------------------------------------------------------------- /WIN/Onedrive.md: -------------------------------------------------------------------------------- 1 | 如何更改OneDrive文件夹的存储位置(路径)https://www.windows10.pro/onedrive-folder-change-location/ 2 | -------------------------------------------------------------------------------- /WIN/PPT.md: -------------------------------------------------------------------------------- 1 | # win10 PowerPoint 使用技巧 2 | 3 | ## 画线时,取消自动选点 4 | 5 | 在拖动线的时候按住 Alt 键。 -------------------------------------------------------------------------------- /WIN/PS.md: -------------------------------------------------------------------------------- 1 | 教程:https://mp.weixin.qq.com/s/KrjKI5RPVQPb2WkY9kOg1g 2 | -------------------------------------------------------------------------------- /WIN/Python.md: -------------------------------------------------------------------------------- 1 | python下载:https://www.python.org/downloads/ 2 | 安装:https://www.cnblogs.com/tiandlsd001/p/7764044.html 3 | 4 | vscode python: 5 | 在vscode中安装python库:https://jingyan.baidu.com/article/acf728fd6f0dbdf8e510a3a5.html 6 | 更换库源镜像:https://blog.csdn.net/qq_39022311/article/details/83241701 7 | 8 | Tensorflow cpu:pip3 install tensorflow 9 | -------------------------------------------------------------------------------- /WIN/SSR+AmyTelecom.md: -------------------------------------------------------------------------------- 1 | # Win10 配置SSR + AmyTelecom 2 | 3 | 一序列机场相关文章: 4 | 5 | * [DuyaoSS-机场测速和简介 [SS/SSR/V2Ray] 【联通】更新中 ](https://github.com/DuyaoSS/SSR/issues/1) 6 | * [SS/SSR 简介和客户端软件下载](https://congcong0806.github.io/2018/04/20/SS/) 7 | 8 | ## 购买AmyTelecom服务 9 | 10 | https://api.nxtlnodes.com/Subscription/ShadowRocketImportService?sid=7500&token=SMMY3pkUROW 11 | 12 | 选择 MyService,点击 Get Subscriptions,点击 win/SSR Subscription,即可复制订阅信息。 13 | 14 | ## 安装SSR 15 | 16 | ssr下载地址:https://github.com/HMBSbige/ShadowsocksR-Windows/releases 选择shadowsocksR-Portable-Win64-xxx.zip 17 | 18 | 之后的配置方式可参考:https://docs.nameless13.com/winssr,内附安卓ssr客户端教程 19 | 20 | 另外发现,选择新加坡的服务器的话无法访问Google Scholar, 提示“We're sorry...... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.” 换用香港的或美国的都可以。 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /WIN/SolidConverter.md: -------------------------------------------------------------------------------- 1 | https://mp.weixin.qq.com/s/z09Brz1wL27lgYJYR1XPlw 2 | -------------------------------------------------------------------------------- /WIN/Word.md: -------------------------------------------------------------------------------- 1 | # WIIN10 Word 使用技巧 2 | 3 | ## 表格 4 | 5 | ### 如何快速制作斜线表头 6 | 7 | 绘制表格-直接画就行了 [参考](https://zhuanlan.zhihu.com/p/49177644) 8 | 9 | ## 页眉页脚 10 | 11 | [页眉插入章节标题](https://www.jianshu.com/p/7a1841e7c9a5) 12 | 13 | ## 分页之后的首行的段前距调整 14 | 15 | 不选择“分页”,而是选择插入“下一页-分节符” 16 | 17 | [怎么在word中插入分节符](https://jingyan.baidu.com/article/72ee561aa5a027e16038df72.html) -------------------------------------------------------------------------------- /WIN/XJTU-VPN.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mingrui-Yu/Tutorials/f8dd8d160665c6b6d0a48c08fcf46fcb98c4f7e3/WIN/XJTU-VPN.pdf -------------------------------------------------------------------------------- /WIN/Zotero: -------------------------------------------------------------------------------- 1 | # WIN10 配置使用 Zotero 2 | 3 | ## 下载安装 4 | 5 | https://www.zotero.org/ 6 | 7 | Zotero - 编辑 - 首选项 - 高级 - 文件和文件夹: 更改数据存储位置(不放在C盘) 8 | 9 | ## 使用 WebDAV 连接坚果云 10 | 11 | Zotero - 编辑 - 首选项 - 同步: 12 | 13 | * 使用 WebDAV 14 | * 在坚果云官网上申请第三方应用接入,将相应信息填入此处,点击OK 15 | 16 | 之后会发现在坚果云目录下会出现“zotero”文件夹(与我的坚果云并列) 17 | 18 | ## 在 ipad 上用 PDF expert 查看编辑 zotero 中的 pdf 文件 19 | 20 | PDF expert 与坚果云完成连接 21 | 22 | 下载 zotero 的插件:zotfile http://zotfile.com/ 23 | 24 | 按照 [参考](https://www.ravenxrz.ink/archives/1b8fe85b.html) 中进行相应配置,将同步目录设定为坚果云同步文件夹中的一个目录 25 | 26 | 之后在 zotero 中利用 zotfile 将 pdf 导出至同步文件夹,在 ipad 上用 PDF expert 查看同步文件夹内的pdf文件。PC端再将编辑后的 pdf 文件从同步文件夹导入至 zotero。 27 | 28 | ## 导入知网的文献 29 | 30 | 目前无法将知网下载的文献拖入Zotero实现自动抓取,导入知网文献的步骤如下: 31 | 32 | 1. 在知网上对应文献导出参考文献,选择Endnote格式,复制到剪贴板 33 | 2. 在Zotero中选择 “文件-从剪贴板中导入”,导入条目 34 | 3. 从知网下载pdf文件,拖入Zotero,再拖至上述条目内 35 | 36 | ## Zotero + Word 进行参考文献管理 37 | 38 | 在word中显示Zotero加载项:[下载安装了zotero,为什么word没显示zotero的加载项 | CSDN](https://blog.csdn.net/quinn1994/article/details/104460556?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight) 39 | 40 | GBT7714-2015参考文献格式的csl文件:[几个 GB/T7714相关的csl文件 | 知乎](https://zhuanlan.zhihu.com/p/62396113) ,选择第三个。 41 | 42 | 在Word中插入参考文献的其他步骤:[[Zotero]如何在Word中插入参考文献 | 知乎](https://zhuanlan.zhihu.com/p/62931860) 43 | 44 | -------------------------------------------------------------------------------- /WIN/cmd.md: -------------------------------------------------------------------------------- 1 | 进入文件夹xx 2 | ``` 3 | cd xx 4 | ``` 5 | 6 | 返回上一级文件夹 7 | ``` 8 | cd.. 9 | ``` 10 | 11 | 删除w文件xx.txt 12 | ``` 13 | del xx.txt 14 | ``` 15 | 16 | 显示文件夹内容所有内容 17 | ``` 18 | dir 19 | ``` 20 | 21 | 启用administer账户: 先以管理员身份运行cmd 22 | ``` 23 | net user administrator /active:yes 24 | ``` 25 | 禁用administer账户 26 | ``` 27 | net user administrator /active:no 28 | ``` 29 | -------------------------------------------------------------------------------- /WIN/mathpix.md: -------------------------------------------------------------------------------- 1 | # 公式截图 转latex公式/word公式 2 | 3 | ## 公式截图转latex公式 4 | 下载:[mathpix官网](https://mathpix.com/),需要科学上网 5 | 6 | 安装windows版本,打开后,按下ctrl+alt+m,即可截图公式。 7 | 8 | ## latex公式转word公式 9 | [用LaTeX写公式转换到Word的方法](https://www.douban.com/note/648629593/) -------------------------------------------------------------------------------- /WIN/ssh.md: -------------------------------------------------------------------------------- 1 | # Windows 上 ssh 连接服务器 2 | 3 | XJTU IAIR 服务器 AI MAX 4 | 5 | WIN + X 点击 Windows PowerShell 出终端 6 | 7 | 终端内输入 ssh -p POST USERNAME@HOST -------------------------------------------------------------------------------- /WIN/win10电脑半夜自动开机.md: -------------------------------------------------------------------------------- 1 | # 解决win10电脑半夜从睡眠状态自动开机 2 | 3 | https://www.v2ex.com/t/577040 4 | 5 | 电源高级选项-睡眠-禁止计时器唤醒 -------------------------------------------------------------------------------- /WIN/删除文件.md: -------------------------------------------------------------------------------- 1 | WIN10删除或更改需要SYSTEM或ADMINISTRATORS权限的文件夹 2 | https://blog.csdn.net/qq_36896735/article/details/81150074 3 | -------------------------------------------------------------------------------- /WIN/邮件客户端.md: -------------------------------------------------------------------------------- 1 | # win10邮件(outlook)客户端 2 | 3 | ## 添加qq/foxmail邮箱 4 | [win10自带邮箱无法同步QQ邮箱问题如何解决](https://jingyan.baidu.com/article/cb5d6105a91441005c2fe0d9.html) 5 | 6 | ## 添加stu.xjtu.edu.cn邮箱 7 | 选择IMAP方式,输入邮箱的密码即可。 8 | --------------------------------------------------------------------------------