halcon分离路径名称
用haclon程序将目录名分离的算法。
ParseFileName:='F:/D705/4-20/缺陷/81.bmp'
parse_filename(ParseFileName, BaseName, Extension, Directory)
* This procedure gets a filename (with full path) as input
* and returns the directory path, the base filename and the extension
* in three different strings.
*
* In the output path the path separators will be replaced
* by '/' in all cases.
*
* The procedure shows the possibilities of regular expressions in HALCON.
*
* Input parameters:
* FileName: The input filename
*
* Output parameters:
* BaseName: The filename without directory description and file extension
* Extension: The file extension
* Directory: The directory path
*
* Example:
* basename('C:/images/part_01.png',...) returns
* BaseName = 'part_01'
* Extension = 'png'
* Directory = 'C:\\images\\' (on Windows systems)
*
* Explanation of the regular expressions:
*
* '([^\\\\/]*?)(?:\\.[^.]*)?$':
* To start at the end, the '$' matches the end of the string,
* so it is best to read the expression from right to left.
* The part in brackets (?:\\.[^.}*) denotes a non-capturing group.
* That means, that this part is matched, but not captured
* in contrast to the first bracketed group ([^\\\\/], see below.)
* \\.[^.]* matches a dot '.' followed by as many non-dots as possible.
* So (?:\\.[^.]*)? matches the file extension, if any.
* The '?' at the end assures, that even if no extension exists,
* a correct match is returned.
* The first part in brackets ([^\\\\/]*?) is a capture group,
* which means, that if a match is found, only the part in
* brackets is returned as a result.
* Because both HDevelop strings and regular expressions need a '\\'
* to describe a backslash, inside regular expressions within HDevelop
* a backslash has to be written as '\\\\'.
* [^\\\\/] matches any character but a slash or backslash ('\\' in HDevelop)
* [^\\\\/]*? matches a string od ..n characters (except '/' or '\\')
* where the '?' after the '*' switches the greediness off,
* that means, that the shortest possible match is returned.
* This option is necessary to cut off the extension
* but only if (?:\\.[^.]*)? is able to match one.
* To summarize, the regular expression matches that part of
* the input string, that follows after the last '/' or '\\' and
* cuts off the extension (if any) after the last '.'.
*
* '\\.([^.]*)$':
* This matches everything after the last '.' of the input string.
* Because ([^.]) is a capturing group,
* only the part after the dot is returned.
*
* '.*[\\\\/]':
* This matches the longest substring with a '/' or a '\\' at the end.
*
tuple_regexp_match (FileName, '.*[\\\\/]', DirectoryTmp)
tuple_substr (FileName, strlen(DirectoryTmp), strlen(FileName) - , Substring)
tuple_regexp_match (Substring, '([^\\\\/]*?)(?:\\.[^.]*)?$', BaseName)
tuple_regexp_match (Substring, '\\.([^.]*)$', Extension)
*
*
* Finally all found backslashes ('\\') are converted
* to a slash to get consistent paths
tuple_regexp_replace (DirectoryTmp, ['\\\\','replace_all'], '/', Directory)
return ()
halcon分离路径名称的更多相关文章
- python获取某路径下,某种特定类型的文件名称,os.walk(路径)生成器;os.listdir(路径),os.path.splitext(名称),os.path.join(路径,名称),os.path.isdir(路径\名称)
#获取某文件夹下制定类型文件# import os# def filep(fp):# l=[]# a=os.walk(fp) #生成器# for nowp,sonp,oth in a: #当前目录,子 ...
- Foxpro数据库连接错误解决方法--【VFP DBF文件不是一个有效的路径。 确定路径名称拼写是否正确,以及是否连接到文件存放的服务器】
直接访问vfp dbf文件时报错: 错误描述: 'd:\vfpData\test.dbf'不是一个有效的路径. 确定路径名称拼写是否正确,以及是否连接到文件存放的服务器. 解决办法:Data Sour ...
- 【转】如何解决Ubuntu终端里面显示路径名称太长
原文网址:http://jingyan.baidu.com/article/3d69c5516c129df0ce02d77b.html Ubuntu 默认的终端下面,进入很多层的目录后,前面那个提示符 ...
- Python根据路径名称获取文件的名称以及所在的路径
大神一看题目就知道用python中的string.split('\'),记得之前处理大量的文件的时候,有时候有几十万的文本文件,经常会读取获取名称,并且保存为名字一样的另外一种格式的文件 其实pyth ...
- 解决Ubuntu终端里面显示路径名称太长
方法/步骤 找到配置文件先进行备份: cp ~/.bashrc ~/.bashrc-bak 找到配置文件修改: vi ~/.bashrc 备份是为了防止配置修改出错,可以还原: 下面是我的/h ...
- Ubuntu终端里面显示路径名称太长,怎么设置变短【转】
转自:http://blog.csdn.net/id19870510/article/details/8276914 $: sudo vi ~/.bashrc 这个文件记录了用户终端配置 找到 if ...
- glob - 形成路径名称
描述 (DESCRIPTION) 很久以前 在 UNIX V6 版 中 有一个 程序 /etc/glob 用来 展开 通配符模板. 不久以后 它 成为 shell 内建功能. 现在 人们 开发了 类似 ...
- 根据ID和parentID利用Java递归获取全路径名称
如下图所示,本文参考资源:https://jie-bosshr.iteye.com/blog/1996607 感谢大佬的无私奉献. 思路: 定义一个方法getParentName参数为int类型的c ...
- 获取driver网络路径名称
'get the web path of the drive s: Dim MM As New Management.ManagementObject(String.Format("win3 ...
随机推荐
- Linux磁盘挂载
mount命令 用于加载文件系统到指定的加载点.此命令的最常用于挂载cdrom,使我们可以访问cdrom中的数据,因为你将光盘插入cdrom中,Linux并不会自动挂载,必须使用Lin ...
- effective_java第23条:请不要新代码中使用原生态类型
从这条开始涉及泛型相关的点. 从JDK5开始Java新增了“泛型”新特性,例如:List<String>,在这之前则只有List不会限定类型. 如今的JDK版本中还是可以写原生类型,但这会 ...
- Alpha冲刺8
前言 队名:拖鞋旅游队 组长博客:https://www.cnblogs.com/Sulumer/p/10023260.html 作业博客:https://edu.cnblogs.com/campus ...
- GPU知识了解
前言 今天在使用阿里云的时候,无意间看到了有GPU服务器,于是对它做了一个大概的了解. 概念 GPU是Graphics Processing Unit的缩写,翻译成中文就是图形处理器.是一种专门在个人 ...
- grep、head和tail
一.请给出打印test.txt内容时,不包含oldboy字符串的命令 Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Globa ...
- React Native 安卓 程序运行报错: React Native version mismatch(转载)
这个问题已经得到解决,参照stackoverflow上的问题:https://stackoverflow.com/que...这个问题的原因就处在Android工程中app/build.gradle中 ...
- Python多进程并发操作中进程池Pool的应用
Pool类 在使用Python进行系统管理时,特别是同时操作多个文件目录或者远程控制多台主机,并行操作可以节约大量的时间.如果操作的对象数目不大时,还可以直接使用Process类动态的生成多个进程,十 ...
- Address localhost:1099 is already in use
在 ItelliJ idea中创建了Servlet,启动tomcat时系统报错: Error running Tomcat 7.0.47: Address localhost:1099 is alre ...
- 利用Aspectj实现Oval的自动参数校验
前言: Oval参数校验框架确实小巧而强大, 他通过注解的方式配置类属性, 然后通过Oval本身自带的工具类, 快速便捷执行参数校验. 但是工具类的校验需要额外的代码编写, 同时Oval对函数参数级的 ...
- Netty权威指南(笔记一)
转载:http://blog.csdn.net/clarkkentyang/article/details/52529785 第一章(略) 第二章 NIO入门 2.1传统的BIO编程(同步阻塞I/O服 ...