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 ...
随机推荐
- python非技术性问题整理
针对软件安装包,安装时出现下类问题, 解决方法时, 以管理员身份运行命令行, 可以看到,包 正常安装. 在使用bs4,分析html或者xml文档时, 代码无法识别lxml 指令, 可能是python ...
- effective java——12考虑实现coparable接口
float和double类型的主要设计目标是为了科学计算和工程计算.他们执行二进制浮点运算,这是为了在广域数值范围上提供较为精确的快速近似计算而精心设计的.然而,它们没有提供完全精确的结果,所以不应该 ...
- Java语法基础学习DaySixteen(多线程)
一.多线程的创建 1.作用 程序需要同时执行两个或多个任务时需要多线程. 程序需要实现需要等待的任务时,如用户输入.文件读写操作.网络操作.搜索等,需要多线程. 需要一些后台运行的程序时,需要多线程. ...
- JPA问题汇总
JPATools生成的实体类对大小写敏感.如果一个数据库中大小写混乱,生成的实体类也会大小写都有.这种情况会导致HibernateSQL语句查询,每次都会查询第一个大小写字段,所以需要加映射关系.@C ...
- linux日常命令之一
zcat Linux中,cat命令可查看文本内容: 对于压缩包内的文本,可使用zcat命令,在不解压的情况下查看文本内容: iconv file -i 可查看文件字符集: iconv为字符集转换命令, ...
- Python全栈之路----递归
alex博客中递归的博文 我之前确实没讲明白递归这个东西 递归就是在函数的运行过程中调用自己. 但递归不断调用自己是有限度的,默认限度为1000.函数不断被压进栈,当超过递归限度时会造成栈溢出 ...
- python中序列化模块json和pickle
json模块:json是第三方包,不是系统内置模块,以字符串序列 常用操作有: json.dumps() # 将变量序列化,即将功能性字符转化为字符串 例: >>> import j ...
- CSS3 实现圆形、椭圆形、三角形等各种形状样式
CSS3 圆形 #css3-circle{ width: 150px; height: 150px; border-radius: 50%; background-color: #232323;} C ...
- 通过用户名&密码验证访问远程共享文件夹 C#
通过代码先在cmd中运行net use进行验证,然后就可访问共享文件了. 验证方法如下: public string connectState(string path/*要访问的文件路径*/, str ...
- Python数据类型的可变与不可变
首先,我们需要知道在python中哪些是可变数据类型,哪些是不可变数据类型.可变数据类型:列表list和字典dict:不可变数据类型:整型int.浮点型float.字符串型string和元组tuple ...