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 ...
随机推荐
- pycharm的中文汉化
下载pycharm软件 然后通过下面的网站进行激活: http://idea.lanyus.com/ 激活好后下载汉化包:链接:http://pan.baidu.com/s/1i5zaGgX 密码:g ...
- CHECK约束表达式
1.性别:只能填写'男'和'女' (字段名='男'or 字段名='女') 注意:单引号里的值可以为其他任何字 2.规定密码长度不能小于6位数 (len([字段名])>(5)) 3.例:成绩在 ...
- 利用ASK/OOK 发射模块,实现信号重放
本文以打开无线控制的电动车库卷帘门为目标,深入研究了ASK/OOK的编/解码,并用树莓派+五元钱的ASK/OOK 发射模块 背景 车库装了电动卷帘门,为了了解其安全性,也是为了能自主控制,研究了下其遥 ...
- 使用Sublime Text 3进行Markdown 编辑+实时预览
这种做法可能会对你的磁盘IO造成一小部分性能负担,但负面影响足以忽略. 另外,由于这种频率的读写会被磁盘缓存接管,不必担心磁盘寿命的影响. 对于刚安装好的Sublime Text,我们需要安装一个软件 ...
- java.io.IOException: Could not delete path 'D:\mycode\reactnative\SecondTest\android\app\build\generated\source\r \release\android\support\v7
问题解决 直观上看是没有删除某个文件,产生的IOException异常,实际上是因为上次编译导致的缓存没有清空导致的. 进入到android目录下运行下面代码清除上次打包时的缓存: ./gradlew ...
- git教程: 创建版本库
转载:创建版本库 什么是版本库呢?版本库又名仓库,英文名repository,你可以简单理解成一个目录,这个目录里面的所有文件都可以被Git管理起来,每个文件的修改.删除,Git都能跟踪,以便任何时刻 ...
- 百战程序员-xml
1.用自己的语言说出,为什么需要XML? XML 是一种元标注语言,该语言提供一种描述结构数据的格式.这有助于更精确地声明内容,方便跨越多种平台的更有意义的搜索结果.此外,XML 将起用新一代的基于 ...
- h5 js判断是安卓还是ios设备,跳转到对应的下载地址
/*ios和安卓跳转 js*/$(function(){ var u = navigator.userAgent; var ua = navigator.userAgent.toLowerCase() ...
- yaf nginx 设置
#test1server { listen 80; listen [::]:80; root /vagrant_data/aaa/public; index index.html index.htm ...
- H3C交换机配置vlan
一,内存二,硬盘(分区,数据量大小)三,电源线,网络线四,raid(raid0,raid1,raid5)五,装系统(系统版本,分区)六,配置网络 1.创建用户 system-view #进入配置loc ...