一些小bug和学习

swap扩容

【Linux 问题记录】(2)内存不足_dd: failed to open_Hzhihua的博客-CSDN博客


查看系统中的所有环境

用户安装的不同Python环境会放在~/anaconda/envs目录下。查看当前系统中已经安装了哪些环境,使用conda info -e。

user@user-XPS-8920:~$ conda info -e


ffmpeg 将图片制作为视频
ffmpeg -r 2 -start_number 000001 -i 'matches_000000_%6d.png' -b:v 3000k temp.mp4


tmux 创建窗口
tmux  ls 查看窗口
tmux a -t 0 恢复0窗口


后台运行程序
nohup  {} >data.txt &

linux 指定卡跑程序
CUDA_VISIBLE_DEVICES=0 python3 train.py

linux指定对多卡跑
import os  
os.environ["CUDA_VISIBLE_DEVICES"] = "0,1,2"

pytorch跑程序
model=model.cuda()
model=torch.nnDataParallel(modle,device_ids=[0,1,2].cuda)

其他

训练后保存的模型参数,再次导入模型时,出现报错:

Missing key(s) in state_dict: ...

解决办法:
在导入参数前加上
import torch.nn as nn
from torch.backends import cudnn

model = torch.nn.DataParallel(model)
cudnn.benchmark = True


链接服务器
ssh 102in
服务器链接网
proxyon
压缩文件
tar-zcvf py.tar.gz py38/
复制服务器环境
scp 101in:/home/zenglongjian/.conda/envs/py38.tar.gz ./
解压文件
tar -zxvf py38.tar.gz py38

conda安装python环境
https://zhuanlan.zhihu.com/p/44398592
光线    勒克斯值Lux
 全日光线    100000
 日光有云     70000
 日光浓云     20000
 室内光线     100-1000
 日出/日落光线     500
 黎明光线     1-0
 满月夜光     4
 半月夜光     0.2
 月夜密云夜光     0.02
 无月夜光     0.001
 平均星光     0.0007
 无月密云夜光     0.00005
 
 
PSNR(峰值信噪比):
https://blog.csdn.net/qq_43557445/article/details/109737753?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522167851205616782427419173%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=167851205616782427419173&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-109737753-null-null.142^v73^control_1,201^v4^add_ask,239^v2^insert_chatgpt&utm_term=PSNR%2FSSIM&spm=1018.2226.3001.4187
用得最多,但是其值不能很好地反映人眼主观感受。一般取值范围:20-40.值越大,视频质量越好。
SSIM(结构相似性):

计算稍复杂,其值可以较好地反映人眼主观感受。一般取值范围:0-1.值越大,视频质量越好


将文件夹中的文件批量命名为1.jpg,2.jpg,3.jpg,4.jpg,5.jpg,6.jpg
 i=1; for x in *; do mv $x $i.jpg; let i=i+1; done
删除文件夹中所有的.png   
rm *.png

相机标定 https://blog.csdn.net/a083614/article/details/78579163
当源证书过老(更换国内源产生的问题)sudo apt install ca-certificates --reinstall更
换源 add-apt-repository [options  -y -r ] repository
截图软件flameshot gui
tmux -new -s zen
tmux+b+shift+ "
tmux+b+%+shift

#include <iomanip> // setfill, setw   setw() 用于控制输出之间的间隔
 git 远程 https://blog.csdn.net/bluefish89/article/details/113698228
检测图像是否为8 位无符号整数,通道数是 1、3 或 4下
if(img.empty())
  {
      std::cout << "Failed to read image "  << std::endl;
      return -1;
  }
    int img_type = img.type();
    int img_channels = img.channels();
    if (img_type != CV_8UC1 && img_type != CV_8UC3 && img_type != CV_8UC4) {
        std::cerr << "Image type is not supported." << std::endl;
        return -1;
    }
    if (img_channels != 1 && img_channels != 3 && img_channels != 4) {
        std::cerr << "Image channels are not supported." << std::endl;
        return -1;
    }


//博主微信/QQ 2487872782
//有问题可以联系博主交流
//有图像处理需求也可联系博主
//图像处理技术交流QQ群 271891601
//https://blog.csdn.net/chenxjhit/article/details/80549194?ops_request_misc=&request_id=&biz_id=102&utm_term=cv::imwrite%E5%87%BD%E6%95%B0%E4%BF%9D%E5%AD%98%E5%A4%9A%E5%BC%A0%E5%9B%BE%E7%89%87&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~sobaiduweb~default-4-80549194.nonecase&spm=1018.2226.3001.4450
//https://blog.csdn.net/wenhao_ir/article/details/51698089
//参考的链接
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include<opencv2/imgcodecs/imgcodecs.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <boost/format.hpp>  // for formating strings
#include <iostream>
#include <time.h>  
#include <fstream>
using namespace cv;
using namespace std;
 
int main()
{
    //源图像  
    //Mat img_input = imread("/home/zeng/SLAM_ORB2/codes/data/depth/0.png");
   // vector<cv::Mat>  depthImgs;
    //cv::String img_outputpath = ".data/depth/depth_noise/";
    for (int i = 0; i < 182; i++) {
    boost::format fmt("./data/%s/%d.%s"); //图像文件格式
    boost::format fmt_out("./data/%s/%s/%d.%s"); //
    //depthImgs.push_back(cv::imread((fmt % "depth" % (0) % "png").str(), -1)); // 使用-1读取原始图像
    cv::String img_outputpath = (fmt_out % "depth" %"depth_noise_c" % (i) % "png").str();//存储文件路径
    Mat img_input = cv::imread((fmt % "depth" % (i) % "png").str());
    //g_srcImage = imread("test.png");
    printf("第%02d个\n",i);
    Mat img_output(img_input.size(), img_input.type());
    Mat noise(img_input.size(), img_input.type());  
    //std::cout << img_input << std::endl;
    RNG rng(time(NULL));
    rng.fill(noise, RNG::NORMAL, 0,  1);  /*产生高斯分布矩阵*///0均值,1标准差
    cv::add(img_input, noise, img_output);//将高斯噪声加入到深度图中
    cv::imwrite(img_outputpath, img_output);
    //imshow("原图像", img_input);
    //imshow("噪声图像", noise);
    //imshow("加上高斯噪声后的图像", img_output);
}
 
    waitKey(0);
    return EXIT_SUCCESS;
}


superglue hloc 带训练和复现的代码
https://github.com/cvg/Hierarchical-Localization
!git clone --quiet --recursive https://github.com/cvg/Hierarchical-Localization/
%cd /content/Hierarchical-Localization
!pip install -e .
!pip install --upgrade --quiet plotly

import tqdm, tqdm.notebook
tqdm.tqdm = tqdm.notebook.tqdm  # notebook-friendly progress bars
from pathlib import Path

from hloc import extract_features, match_features, reconstruction, visualization, pairs_from_exhaustive
from hloc.visualization import plot_images, read_image
from hloc.utils import viz_3d
images = Path('datasets/sacre_coeur')
outputs = Path('outputs/demo/')
!rm -rf $outputs
sfm_pairs = outputs / 'pairs-sfm.txt'
loc_pairs = outputs / 'pairs-loc.txt'
sfm_dir = outputs / 'sfm'
features = outputs / 'features.h5'
matches = outputs / 'matches.h5'

feature_conf = extract_features.confs['superpoint_aachen']
matcher_conf = match_features.confs['superglue']

references = [str(p.relative_to(images)) for p in (images / 'mapping/').iterdir()]
print(len(references), "mapping images")
plot_images([read_image(images / r) for r in references], dpi=25)

extract_features.main(feature_conf, images, image_list=references, feature_path=features)
pairs_from_exhaustive.main(sfm_pairs, image_list=references)
match_features.main(matcher_conf, sfm_pairs, features=features, matches=matches);


model = reconstruction.main(sfm_dir, images, sfm_pairs, features, matches, image_list=references)
fig = viz_3d.init_figure()
viz_3d.plot_reconstruction(fig, model, color='rgba(255,0,0,0.5)', name="mapping")
fig.show()

visualization.visualize_sfm_2d(model, images, color_by='visibility', n=2)

url = "https://upload.wikimedia.org/wikipedia/commons/5/53/Paris_-_Basilique_du_Sacr%C3%A9_Coeur%2C_Montmartre_-_panoramio.jpg"
# try other queries by uncommenting their url
# url = "https://upload.wikimedia.org/wikipedia/commons/5/59/Basilique_du_Sacr%C3%A9-C%C5%93ur_%285430392880%29.jpg"
# url = "https://upload.wikimedia.org/wikipedia/commons/8/8e/Sacr%C3%A9_C%C5%93ur_at_night%21_%285865355326%29.jpg"
query = 'query/night.jpg'
!mkdir -p $images/query && wget $url -O $images/$query -q
plot_images([read_image(images / query)], dpi=75)

references_registered = [model.images[i].name for i in model.reg_image_ids()]
extract_features.main(feature_conf, images, image_list=[query], feature_path=features, overwrite=True)
pairs_from_exhaustive.main(loc_pairs, image_list=[query], ref_list=references_registered)
match_features.main(matcher_conf, loc_pairs, features=features, matches=matches, overwrite=True);

import pycolmap
from hloc.localize_sfm import QueryLocalizer, pose_from_cluster

camera = pycolmap.infer_camera_from_image(images / query)
ref_ids = [model.find_image_with_name(n).image_id for n in references_registered]
conf = {
    'estimation': {'ransac': {'max_error': 12}},
    'refinement': {'refine_focal_length': True, 'refine_extra_params': True},
}
localizer = QueryLocalizer(model, conf)
ret, log = pose_from_cluster(localizer, query, camera, ref_ids, features, matches)

print(f'found {ret["num_inliers"]}/{len(ret["inliers"])} inlier correspondences.')
visualization.visualize_loc_from_log(images, query, log, model)

pose = pycolmap.Image(tvec=ret['tvec'], qvec=ret['qvec'])
viz_3d.plot_camera_colmap(fig, pose, camera, color='rgba(0,255,0,0.5)', name=query)
fig.show()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值