OpenCV 学习随记

Installation pip install opencv-python Reading and Saving Images 函数 cv2.imwrite()用于将图像保存到指定的文件 retval = cv2.imwrite(filename, img [, paras]) cv2.imwrite() 将 OpenCV 图像保存到指定的文件。 cv2.imwrite() 基于保存文件的扩展名选择保存图像的格式。 cv2.imwrite() 只能保存 BGR 3通道图像,或 8 位单通道图像、或 PNG/JPEG/TIFF 16位无符号单通道图像。 Arguments filename:要保存的文件的路径和名称,包括文件扩展名 img:要保存的 OpenCV 图像,nparray 多维数组 paras:不同编码格式的参数,可选项 cv2.CV_IMWRITE_JPEG_QUALITY:设置 .jpeg/.jpg 格式的图片质量,取值为 0-100(默认值 95),数值越大则图片质量越高; cv2.CV_IMWRITE_WEBP_QUALITY:设置 .webp 格式的图片质量,取值为 0-100; cv2.CV_IMWRITE_PNG_COMPRESSION:设置 .png 格式图片的压缩比,取值为 0-9(默认值 3),数值越大则压缩比越大。 retval:返回值,保存成功返回 True,否则返回 False。 Notice cv2.imwrite() 保存的是 OpenCV 图像(多维数组),不是 cv2.imread() 读取的图像文件,所保存的文件格式是由 filename 的扩展名决定的,与读取的图像文件的格式无关。 对 4 通道 BGRA 图像,可以使用 Alpha 通道保存为 PNG 图像。 cv2....

December 7, 2021 · 1 min · Andyliu

Anaconda使用随记

基本命令 创建虚拟环境:conda create -n <env_name> python=X.X 查看环境信息:conda info --envs 激活虚拟环境:conda activate <env_name> 删除环境:conda remove -n <env_name> --all 查找包:conda search --full-name <pkg_name> 添加软件源 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r conda config --set show_channel_urls yes Minutiae unable auto activate base: conda config --set auto_activate_base false

November 30, 2021 · 1 min · Andyliu

Nginx 服务器配置子域名

添加域名解析 到腾讯云服务器控制台,添加需要解析的子域名,如下图。图中第一个参数“主机记录”即为子域名名称。 配置Nginx server { # 端口设置 listen 80; # 二级域名设置 server_name ling.comfluter.life; # 301重定向设置 return 301 http://47.102.150.182/; } 增加一项二级域名设置即可。

November 28, 2021 · 1 min · Andyliu

树莓派配置NAS

挂载NTFS格式磁盘 貌似树莓派OS能够自动挂载NTFS磁盘到/media/pi下。不用额外操作。 使用SAMBA协议提供校园网内文件服务 安装SAMBA 安装SAMBA:sudo apt-get update && sudo apt-get install -y samba 查看SAMBA版本: root@raspberrypi:/media/pi/4T存储# samba --version Version 4.13.13-Debian

November 28, 2021 · 1 min · Andyliu

Including Verilog Code Block in Latex

include packages for code block and coloring \usepackage{listings} \usepackage{xcolor} insert following codes for defining verilog code coloring tactic. It should be inserted at the head field of the latex file (before \begin{document}). % for verilog code coloring \definecolor{vgreen}{RGB}{104,180,104} \definecolor{vblue}{RGB}{49,49,255} \definecolor{vorange}{RGB}{255,143,102} \lstdefinestyle{verilog-style} { language=Verilog, basicstyle=\small\ttfamily, keywordstyle=\color{vblue}, identifierstyle=\color{black}, commentstyle=\color{vgreen}, numbers=left, numberstyle=\tiny\color{black}, numbersep=10pt, tabsize=8, moredelim=*[s][\colorIndex]{[}{]}, literate=*{:}{:}1 } \makeatletter \newcommand*\@lbracket{[} \newcommand*\@rbracket{]} \newcommand*\@colon{:} \newcommand*\colorIndex{% \edef\@temp{\the\lst@token}% \ifx\@temp\@lbracket \color{black}% \else\ifx\@temp\@rbracket \color{black}% \else\ifx\@temp\@colon \color{black}% \else \color{vorange}% \fi\fi\fi } \makeatother \usepackage{trace} Insert your verilog code block using following codes:...

November 26, 2021 · 1 min · Andyliu

Linux 学习随记

开启root账户并配置SSH登录 修改root密码 sudo passwd root 修改SSH配置 sudo vi /etc/ssh/sshd_config 找到选项PermitRootLogin,将其前面的#去掉,即可使用SSH登录。若将后面的prohibit-password改为yes则可使用密码登录。 如果不选择密码登录,还需要通过其他账户登录,将authorized_keys复制到root账户的.ssh文件夹/root/.ssh下 Minutiae 使用taskset命令限定Linux下CPU逻辑核的使用对象及个数 linux下如何查看多核负载情况 LINUX下查看CPU使用率的命令

November 25, 2021 · 1 min · Andyliu

博客评论功能搭建

在王凯师兄的推荐下,使用gitalk搭建博客评论功能。 Github上申请OAuth application 登录github 在Settings页面选择Developer settings选项。 在Developer settings选择OAuth Apps,然后会在页面右边有一个New OAuth App按钮,点击这个按钮就进入到新建OAuth application页面 填写新建OAuth application相关信息: Application name:新建应用的名称 Homepage URL:The full URL to your application homepage. eg.https://comfluter.life/ Application description:对新建应用的描述 Authorization callback URL:回调链接,与Homepage URL保持一致即可。 注:这些参数可以在以后修改 点击注册应用,就可以看到Client ID,可以新建一个Client Secret Hugo 配置 使用stack主题,在配置文件config.yaml中已经预留了相关字段。 复制填写刚生成的Client ID,Client Secret。 repo: 类型:字符串,必填,github上的仓库名字,用于存放Gitalk评论 owner: 类型:字符串,必填,github仓库的所有者的名字 admin: 类型:数组(元素是字符串),必填,github仓库的所有者和合作者 (对这个 repository 有写权限的用户)。如果仓库有多个人可以操作,那么在这里以数组形式写出:['someone'] Debugging Error: Not Found. 尝试了修改Homepage URL为github pages页面,发现并没有用。 解决:存放评论的repo不能为private属性. 应该是一个public的代码库才可以使用Gitalk! References Gitalk评论插件使用教程

November 25, 2021 · 1 min · Andyliu

Verilog with vscode

linting using vscode extension Verilog-HDL/SystemVerilog/Bluespec SystemVerilog. using iverilog go to extension settings and set verilog > linting : linter = iverilog then the linting function should work for verilog files. Notice: the dir to verilog file should not contain chinese characters and spaces. if you imported module from other file without include command, iverilog willl report an error. As it is always the case when using vivado, add -i to extention setting Verilog › Linting › Iverilog: Arguments to ignore this error....

November 24, 2021 · 1 min · Andyliu

Git large file versioning

Download git-lfs on https://git-lfs.github.com/, and run the installation package for windows. Once downloaded and installed, set up Git LFS for your user account by running:git lfs install. You only need to run this once per user account. In each Git repository where you want to use Git LFS, select the file types you’d like Git LFS to manage (or directly edit your .gitattributes). You can configure additional file extensions at anytime....

November 22, 2021 · 1 min · Andyliu

Numpy 学习随记

数组切片 import numpy as np a = np.array([[11, 12, 13], [21, 22, 23]], [31, 32, 33]) 注意Numpy中元素编号从0开始,左侧包含右侧不包含 取单个元素x = a[1, 2],对应第0维的第1个元素4 切片x = a[0:2, 1:3],对应第0维的第0~1个元素,第1维的第1~2个元素[[12 13], [22 23]] 切片x = a[:2, 2:],对应对应第0维的最开始到第2(2-1)个元素,第1维的第2个及以后的所有元素[[13], [23]] 判断一个数组是否存在于另一个大数组内 直接使用==会逐数字判断元素是否存在: import numpy as np a = np.array([[1, 2, 3], [2, 3, 4]]) print(a == np.array([1, 2, 3])) 可以改为(a == np.array([1, 2, 3])).all(1).any()。y == z会将y的每一行与z的每个元素进行比较。 使用all(axis=1)可以获取所有元素匹配的行,并使用any()找出是否匹配。 import numpy as np a = np.array([[1, 2, 3], [2, 3, 4]]) print(a == np....

November 22, 2021 · 1 min · Andyliu