当前位置: 首页 > 编程日记 > 正文

bash脚本【一】——批量处理文件

Bash脚本2.0

#!/bin/bashoutput_root_dir="0723weixin"
data_root_dir="D:/data/"$output_root_dir
config_dir="config"# speckle_name="SPEACKLEIMAGE.bmp"
# ir_name="IRIMAGE.bmp"
# rgb_name="RGBIMAGE.jpg"
# config_name="config"speckle_name="speckle.bmp"
ir_name="ir.bmp"
rgb_name="rgb.jpg"
config_name="config"dir=$(ls -l $data_root_dir  |awk '/^d/ {print $NF}')
for subdir in $dir
doif [ "$subdir" != "$config_dir" ];then#echo $subdirdir1=$(ls -l $data_root_dir/$subdir |awk '/^d/ {print $NF}')for subdir1 in $dir1do#echo $data_root_dir/$subdir/$subdir1for((index=1;index<=10 ;index++))dofile_ir=$(ls -l $data_root_dir/$subdir/$subdir1/raw  |awk '/^-/ {print $NF}' |awk '/ir/ {print $NF}' | awk '/_'$index'.bmp/ {print $1}')file_speckle=$(ls -l $data_root_dir/$subdir/$subdir1/raw  |awk '/^-/ {print $NF}' |awk '/speckle/ {print $NF}' | awk '/_'$index'.bmp/ {print $1}')file_rgb=$(ls -l $data_root_dir/$subdir/$subdir1/data/rgb  |awk '/^-/ {print $NF}' |awk '/rgb/ {print $NF}' | awk '/_'$index'.jpg/ {print $1}')echo $data_root_dir/$subdir/$subdir1/raw/$file_irecho $data_root_dir/$subdir/$subdir1/raw/$file_speckleecho $data_root_dir/$subdir/$subdir1/data/rgb/$file_rgbmkdir -vp ./data/$subdir/$subdir1/$index/#mkdir -vp ./data/$output_root_dir/$subdir/$subdir1/raw/$index/./bin/RelWithDebInfo/depth_magic_runner.exe \$data_root_dir/$subdir/$subdir1/raw/$file_speckle \--ir $data_root_dir/$subdir/$subdir1/raw/$file_ir \--rgb $data_root_dir/$subdir/$subdir1/data/rgb/$file_rgb \--config $data_root_dir/$config_dir/$config_name \# --set_depth_hdr_mode=true# --rotate_ir_img=truemv -f ./debug_output/* ./data/$subdir/$subdir1/$index/#mv -f ./debug_output/* ./data/$output_root_dir/$subdir/$subdir1/raw/$index/donedone   fi
done   

Bash脚本1.0

#!/bin/bashdir=(
"100cm三角/"                
"80cm三角/"                   
)for((i=0;i<=30 ;i++))doecho "The dir is: ${dir[$i]}"mkdir -vp ./data/${dir[$i]}/depth_image/./bin/depth_magic_runner /home/sun/company/优图测试0616/${dir[$i]}\1SPEACKLEIMAGE.bmp \--ir /home/sun/company/优图测试0616/${dir[$i]}\1IRIMAGE.bmp  \--rgb /home/sun/company/优图测试0616/${dir[$i]}\1RGBIMAGE.jpg \--config /home/sun/company/004/ --deptrum_prefix ./data/${dir[$i]}/depth_image/done# do
#   for((i=1;i<=1 ;i++))
#   do
#     for((index=1;index<=1;index++))
#     do
#     echo "The dir is:${dir[$i]}/$index"
#     mkdir -vp ./data/${dir[$i]}/depth_image\[$index\]/
#     ./bin/depth_magic_runner /home/sun/company/优图测试0616/${dir[$i]}\[$index\]SPEACKLEIMAGE.bmp \
#     --ir /home/sun/company/优图测试0616/${dir[$i]}\[$index\]IRIMAGE.bmp  \
#     --rgb /home/sun/company/优图测试0616/${dir[$i]}\[$index\]1RGBIMAGE.jpg \
#     --config /home/sun/company/004/ --deptrum_prefix ./data/${dir[$i]}/depth_image\[$index\]/
#     done
#   done
# donesun@sun:~/company/deptrum/depth-magic$ 

  for((i=1;i<=31 ;i++))doecho "The dir is: ${dir[$i]}"mkdir -vp ./data/${dir[$i]}/depth_image/./bin/depth_magic_runner /home/sun/company/优图测试0616/${dir[$i]}\1SPEACKLEIMAGE.bmp \--ir /home/sun/company/优图测试0616/${dir[$i]}\1IRIMAGE.bmp  \--rgb /home/sun/company/优图测试0616/${dir[$i]}\1RGBIMAGE.jpg \--config /home/sun/company/004/ --deptrum_prefix ./data/${dir[$i]}/depth_image/done
#!/bin/bash# index=1
# while(( $index<=10 ))
# do
#     mkdir -vp ./data1/speckle_raw\[$index\]/
#     echo $index
#     ./depth_magic_runner ~/data/fill_hole/50/LaserOn/IR_RAW/speckle_raw\[$index\].raw --ir ~/data/fill_hole/50/LaserOff/IR_RAW/speckle_raw\[$index\].raw  --rgb ~/data/fill_hole/50/LaserOn/RGB/rgb\[$index\].bmp --config ~/data/fill_hole/001/ --deptrum_prefix ./data1/speckle_raw\[$index\]/
#     let "index++"
# done# int=1
# while(( $int<=5 ))
# do
#     echo $int
#     let "int++"
# donedir=(
"Dis_30_Cur_1.8_Exp_2.1_Gain_1_2020-06-01-14-06-15-680/"              
"Dis_30_Cur_1.8_Exp_2.2_Gain_1_2020-06-01-14-06-18-623/"              
)dir1=(
"Dis\ \(30\)\ Cur\ \(1.8\)\ Exp\ \(2.1\)\ Gain\ \(1\)_2020-06-01-14-06-15-680/"                        
"Dis\ \(30\)\ Cur\ \(1.8\)\ Exp\ \(2.2\)\ Gain\ \(1\)_2020-06-01-14-06-18-623/"                        
)# for distance in 30 50 80 100
for distance in 100
dofor((i=1;i<=1 ;i++))dofor((index=1;index<=10;index++))doecho "The dir is: $distance/${dir[$i]}/$index"mkdir -vp ./data2/$distance/${dir[$i]}/speckle_raw\[$index\]/./depth_magic_runner ~/data/fill_hole/Fatman-mini-001_NBF_人脸#0601/$distance/$i/LaserOn/IR_RAW/speckle_raw\[$index\].raw \--ir ~/data/fill_hole/Fatman-mini-001_NBF_人脸#0601/$distance/$i/LaserOff/IR_RAW/speckle_raw\[$index\].raw  \--rgb ~/data/fill_hole/Fatman-mini-001_NBF_人脸#0601/$distance/$i/LaserOn/RGB/rgb\[$index\].bmp \--config ~/data/fill_hole/Fatman-mini-001_NBF_1.8A#0512/ --deptrum_prefix ./data2/$distance/${dir[$i]}/speckle_raw\[$index\]/donedone
done

批量读文件批量命名

#include <gflags/gflags.h>int aa = 0;
DEFINE_string(deptrum_edge, "./debug_output/", "Prefix to be added to the debug output filename");std::string edge_image_name = FLAGS_deptrum_edge + std::to_string(aa++)+"rgb_roi_on_color.bmp";
cv::imwrite(edge_image_name, trace_edge_color);

之前帮师弟写个一个批量读取图片并且批量修改图片名的功能的小程序,mark一下便于以后复用。

#include <iostream>    
#include <sstream> 
#include <string>    
#include <io.h> 
#include <string.h>
using namespace std;
const int N = 4;
const string fileType = ".jpg";
string int2string(int n, int i);
/*created by sunshine on 2018/5/2*/
int main()
{_finddata_t file;  string fileDirectory = "C:\\Users\\Administrator\\Desktop\\owner\\一餐厅"; //文件夹目录,自己修改  string buffer = fileDirectory + "\\*" + fileType;intptr_t hFile;hFile = _findfirst(buffer.c_str(), &file); if (hFile == -1L)cout << "没有指定格式的图片" << endl;//没有指定格式的图片  else{/**   序号控制  你只需要改正i就OK了,然后配合上面的string fileDirectory指向你的绝对路径  ,后期要是大批量处理的话  可以在进一步扩展一下这个程序*/int i = 530;string newFullFilePath;string oldFullFilePath;string strName;do{oldFullFilePath.clear();newFullFilePath.clear();strName.clear();oldFullFilePath = fileDirectory + "\\" + file.name;++i;strName = int2string(N, i); //类型转换  //char p[20] = "mi-note3-0102-"//第二个字符串  //strName =strcpy(strName, p);//将第一个字符串p拷贝到q中 newFullFilePath = fileDirectory + "\\" +"mi-note3-0102-"+ strName + fileType;int c = rename(oldFullFilePath.c_str(), newFullFilePath.c_str());//重命名  if (c == 0)cout << "重命名成功" << strName << fileType << endl;elsecout << "重命名失败" << strName << fileType << endl;} while (_findnext(hFile, &file) == 0);_findclose(hFile);}system("pause");return 0;
}string int2string(int n, int i)
{char s[BUFSIZ];sprintf_s(s, "%d", i);int len = strlen(s);if (len > n){cout << "输入的N太小!";}else{stringstream Num;for (int i = 0; i < n - len; i++)Num << "0";Num << i;return Num.str();}
}
  std::string filename1 = "./debug_output/points1.txt";FILE* fp = fopen(filename1.c_str(), "at+");cv::Mat norm_obj_points, norm_ref_points;for (std::vector<cv::Point2d>::iterator points1it = points1.begin(); points1it != points1.end(); points1it++) {//std::cout << (*vit).x<<"     " << (*vit).y << std::endl;fprintf(fp,"%10.4f%10.4f\n",(*points1it).x,(*points1it).y);}fclose(fp);std::string filename2 = "./debug_output/points2.txt";FILE* fp2 = fopen(filename2.c_str(), "at+");for (std::vector<cv::Point2d>::iterator points2it = points2.begin(); points2it != points2.end(); points2it++) {//std::cout << (*vit).x<<"     " << (*vit).y << std::endl;fprintf(fp2,"%10.4f%10.4f\n",(*points2it).x,(*points2it).y);}fclose(fp2);

std::string filename = "./debug_output/theta.txt";
    FILE* fp = fopen(filename.c_str(), "at+");        
                    fprintf(fp,
                            "%10.4f %10.3f %10.3f %10.3f %10.2f\n",
                            self_calib_theta_,
                            self_calib_theta_x,
                            self_calib_theta_y,
                            self_calib_theta_z,
                            mean_move_y);

fclose(fp);

相关文章:

【PAT (Basic Level) 】1030 完美数列 (25 分)

给定一个正整数数列&#xff0c;和正整数 p&#xff0c;设这个数列中的最大值是 M&#xff0c;最小值是 m&#xff0c;如果 M≤mp&#xff0c;则称这个数列是完美数列。 现在给定参数 p 和一些正整数&#xff0c;请你从中选择尽可能多的数构成一个完美数列。 【输入格式】&…

运营商劫持处理

测试URL&#xff1a;因近期发现长宽资源经常出现被劫持和转发错误的现象。解决办法如下&#xff1a;1、把转发列表写到named.conf文件里&#xff0c;更新我们的转发ip2、然后编写策略针对我们要去的域名从BGP出口出去&#xff0c;防止NAT。x.x.x.x.com&#xff0c;&#xff08;…

oracle维护数据的完整性

转自&#xff1a;https://www.cnblogs.com/roger112/p/7722376.html 介绍&#xff1a; 数据的完整性用于确保数据库数据遵从一定的商业的逻辑规则。在oracle中&#xff0c;数据完整性可以使用约束、触发器、应用程序(过程、函数)三种方法来实现&#xff0c;在这三种方法中&…

MATLAB【五】———— matlab 调用C++生成exe文件,高斯核函数

两种方式调用C生成的exe文件&#xff0c; 语法&#xff1a; status system(command) [status,cmdout] system(command) [status,cmdout] system(command,-echo) 说明 status system(command) 调用操作系统执行指定的命令。操作会等待命令执行完毕&#xff0c;然后再将命令…

REACT day 1

https://facebook.github.io/react/ A JAVASCRIPT LIBRARY FOR BUILDING USER INTERFACES Declarative views make your code more predictable and easier to debug. React是Facebook在2013年发布的一个前端框架&#xff0c;而如今的React俨然已经演变成一个前端生态&#xff…

win10+Chrome浏览器截长图方法

本方法亲测可行&#xff0c;操作系统为win10&#xff0c;其他操作系统没有试过。 部分内容基于https://blog.csdn.net/ianly123/article/details/80565614并进行修正。 打开 Chrome 浏览器&#xff0c;进入需要截图的网站页面。打开开发者工具&#xff1a;在页面任何地方点击…

如何打造一流的视觉AI技术

本次分享主要分以下几个部分&#xff1a;首先简要介绍一下计算机视觉技术的相关背景&#xff0c;然后结合格灵深瞳的实践&#xff0c;从算法研发、训练平台、智能数据处理、异构计算等几个方面着重介绍如何打造一流的视觉AI技术&#xff0c;最后介绍格灵深瞳在相关技术落地方面…

MATLAB【六】 ———— matlab 随机散斑模拟

%% %input for image size(NX,NY) <散斑图大小&#xff08;像素&#xff09;> NX 1280; NY 800; %input for numble of speckles(S)<散斑数量> S 9226; %输入的散斑大小 a 4; %input for peak intensity of each speckle(I0)<散斑峰值强度> I0 1; %input …

【Python】zip函数

zip()函数用于将可迭代对象作为参数&#xff0c;将对象中对应的元素打包成一个个元组&#xff0c;然后返回这些由元组组成的列表。 如果各个迭代器的元素不一致&#xff0c;则返回列表长度与最短的对象相同。 利用*号操作符&#xff0c;可将元组解压为列表。 >>> a …

CentOS 7.0,启用iptables防火墙

CentOS 7.0默认使用的是firewall作为防火墙&#xff0c;这里改为iptables防火墙。1、关闭firewall&#xff1a;systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动2、安装iptables防火墙yum install iptables-services…

手撸 webpack4.x 配置(一)

现在的前端开发框架 &#xff0c;都绕不开 webpack 打包 。 但绝大数前端开发人员 基本都是用 脚手架 自动生成 一套开发环境 如&#xff1a; vue-cli , create-react-app等 , 但开发中总会遇到各种问题 &#xff0c;基本都是 webpack 配置问题 &#xff0c; 每次遇到基本都是…

MATLAB【七】———— matlab 高斯核使用,超像素图像模拟,矩阵转图像,深度相机模型实践实现

深度模型&#xff0c;图片转稀疏矩阵&#xff0c;稀疏矩阵转图片 %% mat to 2array temp_speckle ref_speckle; [row_index,col_index,v]find(temp_speckle); obj_matrix [row_index,col_index]; [obj_matrix_height,obj_matrix_width] size(obj_matrix);%% depth camera m…

jsp 出现cannot be resolved to a type问题解决办法

&#xff08;1&#xff09;检查<% page import>是否导入了相关的包。若是没有则需导入 &#xff08;2&#xff09;若导入相应的包后问题仍然存在则需创建相关的servlet转载于:https://www.cnblogs.com/wth21-1314/p/6126655.html

U盘中毒了?教你如何删除System Volume Information这个顽固文件夹

不得不说cmd命令很好用呢。最近我的U盘中毒了&#xff0c;格式化都删除不了System Volume Information这个顽固的文件夹&#xff0c;真心伤不起哇&#xff01;还好现在解决了问题。看来以后得好好对待U盘&#xff0c;不能乱用了。本篇文章教大家如何删除System Volume Informat…

69亿美元英伟达史上最大收购!这家基金又赢了

。另一方面&#xff0c;在虚拟货币的浪潮告一段落之后&#xff0c;英伟达需要给增速放缓的数据中心业务注入一枚强心剂。 有意思的是&#xff0c;英伟达对Mellanox的收购也成就了国际知名维权对冲基金Starboard Value LP的又一次投资胜利。 击败微软、英特尔&#xff0c;交易…

基础数据结构【一】————数组

二维数组相乘&#xff0c;矩阵相乘&#xff0c; #include <iostream> using namespace std;void MatrixMultiply(int*, int*, int*, int, int, int); int main() {int M, N, P;int i, j;//矩阵A部分 cout << "请输入矩阵A的维数(M,N): " << endl;…

Fragment 和 FragmentActivity的使用

Fragment 和 FragmentActivity的使用 http://blog.csdn.net/izy0001989624/article/details/17072211转载于:https://www.cnblogs.com/as3lib/p/6126761.html

win10 VMware15 安装 CentOS6.4 64位(慢慢弄吧,别急)

参考&#xff1a;CentOS 6.4安装&#xff08;超级详细图解教程&#xff09; 可以都不勾&#xff0c;有需要&#xff0c;以后使用中有需要再手动安装 除了KDE&#xff0c;其他都选就可以了 系统管理、虚拟化、负载平衡器、高可用性可以都不选

Nginx网站常见的跳转配置实例

相信大家在日常运维工作中如果你用到nginx作为前端反向代理服务器的话&#xff0c;你会对nginx的rewrite又爱又恨&#xff0c;爱它是因为你搞定了它&#xff0c;完成了开发人员的跳转需求后你会觉得很爽&#xff0c;觉得真的很强大&#xff0c;恨它是因为当一些稀奇古怪跳转的需…

基础数据结构【二】————动态数组,单向链表及链表的反转

DEMO1&#xff1a; 动态分配变量&#xff08;链表&#xff0c;而静态数组是线性表&#xff0c;意味着动态数组访问和遍历复杂度为O&#xff08;n&#xff09;,而插入和删除复杂度为O&#xff08;1&#xff09;&#xff0c;而静态数组线性表则完全相反&#xff09; int* in…

VMware15克隆虚拟机Centos

在克隆虚拟机之前&#xff0c;我们需要了解以下文件&#xff1a; 1、/etc/udev/rules.d/70-persistent-net.rules 这是网卡有关信息的配置文件&#xff0c;我们可以先查看一下master的网卡信息&#xff08;当然也可以用ifconfig命令查看&#xff09; 要注意的是网卡名称以及…

EXPDP 时ORA-27054 问题处置

现象&#xff1a;[oracleoracle1 ~]$ expdp xian/xian schemasxian directorydumpdir dumpfilexian.dmp LOGFILExian.logExport: Release 10.2.0.5.0 - 64bit Production on Friday, 02 December, 2016 20:19:48Copyright (c) 2003, 2007, Oracle. All rights reserved.Connec…

OSC源创会往期图文回顾链接地址收藏

为什么80%的码农都做不了架构师&#xff1f;>>> 格式&#xff1a;源创会报名链接地址 - 源创会结束后图文回顾链接地址 【深圳】第1期】- 图文回顾【广州】第2期】- 图文回顾【北京】第3期】- 图文回顾【珠海】第4期】- 图文回顾【深圳】第5期】- 图文回顾--------…

ionic + cordova+angularJs 搭建的H5 App完整版总结

为期半个月的项目实践开发&#xff0c;已完整告一段落&#xff0c;团队小组获得第一名&#xff0c;辛苦总算没有白费&#xff0c;想起有一天晚上&#xff0c;整个小组的人&#xff0c;联调到12点才从公司回去&#xff0c;真是心酸。这里总结一下&#xff0c;项目过程中遇到的问…

基础数据结构【三】————老鼠走迷宫问题————堆栈应用

假设&#xff1a;老鼠在一个二维地图中i行走&#xff0c;地图中大部分路径被墙阻断&#xff0c;无法前进。老鼠可以按照尝试错误的方法找到出口。只是&#xff0c;这只老鼠必须具备走错路时候就退回来&#xff0c;并且把走过的路记下来&#xff0c;避免下次走重复路&#xff0c…

eclipse Debug中step into功能失灵的问题

step into 和 step over功能一样&#xff0c;无法进入方法内部&#xff0c;解决方法如下&#xff1a; 需要使用jdk中的jre&#xff0c;而不是独立安装的jre 再次Debug&#xff0c;当运行到断点的时候&#xff0c;点击step into&#xff08;F5&#xff09;就可以看见println函数…

Linux 基金会宣布红队项目,致力于孵化开源安全工具

百度智能云 云生态狂欢季 热门云产品1折起>>> 谁都想软件有着很高的安全性吧。毕竟&#xff0c;每一天都会有不一样的安全漏洞&#xff0c;从糟糕软件的沼泽中冒出来。 在近期举办的开源领导力峰会上&#xff0c;Linux 基金会宣布了新的红队项目&#xff08;Red Tea…

基础数据结构【四】————环形链表与多项式

主要演示环形列表节点的创建插入&#xff0c; 删除&#xff0c;遍历&#xff0c;环形链表连接 。双向链表节点的建立与插入 &#xff0c;双向链表中节点的删除 以及环形链表在多项式中的应用 DEMO1:环形链表节点的创建与插入 /* [名称]:ch03_08.cpp [示范]:环形链表节点的创…

关联scala源码

首先需要去官网下载sources 将下载好的压缩包拷贝到scala安装的lib目录下&#xff0c;解压 ctrlb以后 查看源码, 选择要查看的方法或者类, 输入 ctrl b import scala.io.StdIn 如果想看StdIn的源码&#xff0c;则将光标放在StdIn处&#xff0c;ctrlb 如果想查看io包下的内容&…

MySQL安装使用的2个问题

问题:1.遇到不输入密码能登上 ,使用密码报错.2.(解压版的) 在cmd输入>mysql –u root –p 时&#xff0c;按enter回车时&#xff0c;会叫你输入密码Enter password____,否则出现错误&#xff1a;ERROR 1045(28000):Access denied for user’root’’localhost’(using passw…