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 ...
随机推荐
- node.js学习一---------------------模块的导入
/** * 前端使用第三方包流程: * 导包:得到一个对象,所有对三方的API都是该对象的方法 * 使用包 * */ /** * 在node.js中叫做导模块 * 导模块:得到一个对象,所有第三方的A ...
- Linux系统基本操作命令
1.文件与文件夹(目录)操作命令 可以参考:http://www.runoob.com/linux/linux-command-manual.html 1)rm:删除命令 例:$ rm -i 文 ...
- c++ 生成dll文件并调用-转
.h(头文件) .lib(库文件) .dll(动态链接库文件) 之间的关系和作用的区分 .h头文件是编译时必须的,lib是链接时需要的,dll是运行时需要的. 附加依赖项的是.lib不是.dll, ...
- django rest_framework 分页出现报错
1.出现: WARNINGS: ?: (rest_framework.W001) You have specified a default PAGE_SIZE pagination rest_fram ...
- 网易2018校招内推编程题-堆棋子-C++实现
链接:https://www.nowcoder.com/questionTerminal/27f3672f17f94a289f3de86b69f8a25b来源:牛客网 [编程题]堆棋子 热度指数:14 ...
- python实现简单的定时任务
1.首先安装 schedule 模块 命令行安装 pip install schedule pyCharm编辑器安装 File->setting->project:youProject-& ...
- Java多线程入门中几个常用的方法
一.currentThread()方法 currentThread方法就是返回当前被调用的线程. 该方法为一个本地方法,原码如下: /** * Returns a reference to the c ...
- python 4
一.列表相关操作 l = ['布偶猫', '小断腿', '大白'] # . append l.append('哎呀') print(l) # . insert l.insert(, '小猪佩琪') p ...
- XXS level6
(1输入框输入与第五关 相同的payload 查看页面源代码,发现“href"变成了”hr_ef“ (2)查看PHP源代码 <?php ini_set("display_er ...
- java程序连接oracle12c报:java.sql.SQLException: ORA-28040: 没有匹配的验证协议。
报错信息: 2017-09-22 15:17:37,204 WARN [org.hibernate.cfg.SettingsFactory] - Could not obtain connection ...