做文本检测这个方向的同学应该都知道 deep features for text spotting 这篇ECCV14的文章。

用的是Matconvnet这个是深度学习框架来做文本检测,同时他还提供了代码:  eccv2014_textspotting

不过这个代码里的Matconvnet不同于原版本Matconvnet,原版本的内容比较全,而这个repository里的算是阉割版,同时还新加入了几个cpp,cu文件。。。

不幸的是,新加入的几个文件只在mac上有编译好的mex文件,linux上,windows上都需要自己编译。接下来就讲讲如何在linux和windows下编译这几个cpp,cu的mex文件。


linux 上的编译方法已经在repository中提到

. Edit matconvnet/Makefile to ensure MEX points to your matlab mex binary. Optinally ENABLE_GPU.
2. cd matconvnet/ && make

已经提供了编译的模板,主要是要修改好matconvnet/Makefile_Linux中几个变量的路径,就可以直接编译了。

比如 我是Ubuntu上装的CUDA7.0就修改如下:

MEX ?= /usr/local/MATLAB/R2014b/bin/mex
MEXARCH = mexa64
NVCC ?= /usr/local/cuda-7.0/bin/nvcc
ENABLE_GPU = true
MEXOPTS_GPU= $(MEXOPTS) -DENABLE_GPU -L /usr/local/cuda-7.0/targets/x86_64-linux/lib -lcudart -lcublas -lcudadevrt -f matlab/src/mex_CUDA_glnxa64.sh

然后重命名Makefile_linux为Makefile,然后 cd matconvnet/,然后 make

这里提供我编译好的 .mexa64文件,:linux_version 。     注意:我在Ubuntu下用cuda7.0编译的,matlab版本是2014b。

把这些mex文件放在 matconvnet\matlab\mex下就能跑整个代码了。


linux下用还是有点不方便,接下来主要讲一下windows下的编译

说来惭愧,本来想自己看明白makefile,然后逐个逐个编译的,但是在不知道nvcc和mex这两编译器该怎么个顺序,用啥编译参数,后来只能偷懒了。

Makefile里面说道了,主要是编译一下几个文件

cpp_src:=matlab/src/bits/im2col.cpp
cpp_src+=matlab/src/bits/pooling.cpp
cpp_src+=matlab/src/bits/normalize.cpp
mex_src:=matlab/src/gconv.cu
mex_src+=matlab/src/gpool.cu
mex_src+=matlab/src/gnormalize.cu
mex_src+=matlab/src/gsepconv.cu
mex_src+=matlab/src/gsepconv2.cu
cpp_src+=matlab/src/bits/im2col_gpu.cu
cpp_src+=matlab/src/bits/pooling_gpu.cu
cpp_src+=matlab/src/bits/normalize_gpu.cu

用过通用版的Matconvnet会有记得那边的windows编译很方便很简单,所以就直接用那边的程序编译了。

首先去下载一个通用版本的 Matconvnet : 通用版Matconvnet

然后用他提供的 matconvnet-master\matlab\vl_compilenn.m 进行编译,修改 vl_compilenn 这个文件里面 185来行的代码,原本是这样:

if opts.enableGpu, ext = 'cu' ; else ext='cpp' ; end
lib_src{end+} = fullfile(root,'matlab','src','bits',['data.' ext]) ;
lib_src{end+} = fullfile(root,'matlab','src','bits',['datamex.' ext]) ;
lib_src{end+} = fullfile(root,'matlab','src','bits',['nnconv.' ext]) ;
lib_src{end+} = fullfile(root,'matlab','src','bits',['nnfullyconnected.' ext]) ;
lib_src{end+} = fullfile(root,'matlab','src','bits',['nnsubsample.' ext]) ;
lib_src{end+} = fullfile(root,'matlab','src','bits',['nnpooling.' ext]) ;
lib_src{end+} = fullfile(root,'matlab','src','bits',['nnnormalize.' ext]) ;
lib_src{end+} = fullfile(root,'matlab','src','bits',['nnbnorm.' ext]) ;
lib_src{end+} = fullfile(root,'matlab','src','bits',['nnbias.' ext]) ;
mex_src{end+} = fullfile(root,'matlab','src',['vl_nnconv.' ext]) ;
mex_src{end+} = fullfile(root,'matlab','src',['vl_nnconvt.' ext]) ;
mex_src{end+} = fullfile(root,'matlab','src',['vl_nnpool.' ext]) ;
mex_src{end+} = fullfile(root,'matlab','src',['vl_nnnormalize.' ext]) ;
mex_src{end+} = fullfile(root,'matlab','src',['vl_nnbnorm.' ext]) ; % CPU-specific files
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','im2row_cpu.cpp') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','subsample_cpu.cpp') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','copy_cpu.cpp') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','pooling_cpu.cpp') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','normalize_cpu.cpp') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','bnorm_cpu.cpp') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','tinythread.cpp') ; % GPU-specific files
if opts.enableGpu
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','im2row_gpu.cu') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','subsample_gpu.cu') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','copy_gpu.cu') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','pooling_gpu.cu') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','normalize_gpu.cu') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','impl','bnorm_gpu.cu') ;
lib_src{end+} = fullfile(root,'matlab','src','bits','datacu.cu') ;
end

改成这样:

if opts.enableGpu, ext = 'cu' ; else ext='cpp' ; end
mex_src{end+1} = fullfile(root,'matlab','src',['gconv.' ext]) ;
mex_src{end+1} = fullfile(root,'matlab','src',['gnormalize.' ext]) ;
mex_src{end+1} = fullfile(root,'matlab','src',['gpool.' ext]) ;
mex_src{end+1} = fullfile(root,'matlab','src',['gsepconv.' ext]) ;
mex_src{end+1} = fullfile(root,'matlab','src',['gsepconv2.' ext]) % CPU-specific files
lib_src{end+1} = fullfile(root,'matlab','src','bits','im2col.cpp') ;
lib_src{end+1} = fullfile(root,'matlab','src','bits','pooling.cpp') ;
lib_src{end+1} = fullfile(root,'matlab','src','bits','normalize.cpp') ; % GPU-specific files
if opts.enableGpu
  lib_src{end+1} = fullfile(root,'matlab','src','bits','im2col_gpu.cu') ;
  lib_src{end+1} = fullfile(root,'matlab','src','bits','pooling_gpu.cu') ;
  lib_src{end+1} = fullfile(root,'matlab','src','bits','normalize_gpu.cu') ;
end

然后把 matconvnet-max-version\matlab\src\ 下 5个.cu文件 gconv.cu gnormalize.cu gpool.cu gsepconv.cu gsepconv2.cu ,还有 matconvnet-max-version\matlab\src\bits下的所有文件(除了mexutils.h),分别拷贝到拷贝到 matconvnet-master\matlab\src\ 和 matconvnet-master\matlab\src\bits下。

把vl_compilenn里的 opts.enableImreadJpeg 改为false, 其他不变。

matlab切换到 vl_compilenn.m根目录,以下列参数运行

vl_compilenn('enableGpu', true, ...
'cudaRoot', 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5', ...
'cudaMethod', 'nvcc')
'cudaRoot'设置为你windows上装CUDA的位置就行。

然后在mex目录下面就有.mexw64文件了。 就这么简单。

这里给我自己编译的  : window64位cuda6.5

环境: x64,matlab2014b,cuda 6.5

deep features for text spotting 在linux,windows上使用的更多相关文章

  1. 在Mac/Linux/Windows上编译corefx遇到的问题及解决方法

    这两天尝试在Mac/Linux/Windows三大平台上编译.NET跨平台三驾马车(coreclr/corefx/dnx)之一的corefx(.NET Core Framework),结果三个平台的编 ...

  2. Sublime Text编辑远程Linux服务器上的文件

    sublime有个叫sftp的插件,可以通过它直接打开远程机器上的文件进行编辑,并在保存后直接同步到远程linux服务器上. 用Package Control安装插件 按下Ctrl+Shift+P调出 ...

  3. Docker在Linux/Windows上运行NetCore文章系列

    Windows系列 因为Window很简单,VS提供界面化配置,所以只写了一篇文章 Docker在Windows上运行NetCore系列(一)使用命令控制台运行.NetCore控制台应用 Linux( ...

  4. Docker在Windows上运行NetCore系列(一)使用命令控制台运行.NetCore控制台应用

    系列文章:https://www.cnblogs.com/alunchen/p/10121379.html 本篇文章操作系统信息 Windows:Window 10 Visual Studio:201 ...

  5. 如何实现在Windows上运行Linux程序,附示例代码

    微软在去年发布了Bash On Windows, 这项技术允许在Windows上运行Linux程序, 我相信已经有很多文章解释过Bash On Windows的原理, 而今天的这篇文章将会讲解如何自己 ...

  6. .NET Core多平台开发体验[3]: Linux (Windows Linux子系统)

    如果想体验Linux环境下开发和运行.NET Core应用,我们有多种选择.一种就是在一台物理机上安装原生的Linux,我们可以根据自身的喜好选择某种Linux Distribution,目前来说像R ...

  7. How To Configure SAMBA Server And Transfer Files Between Linux & Windows

    If you are reading this article it means you have a network at home or office with Windows and Linux ...

  8. Linux (Windows Linux子系统)

    Linux (Windows Linux子系统) 如果想体验Linux环境下开发和运行.NET Core应用,我们有多种选择.一种就是在一台物理机上安装原生的Linux,我们可以根据自身的喜好选择某种 ...

  9. windows平台是上的sublime编辑远程linux平台上的文件

    sublime是个跨平台的强大的代码编辑工具,不多说. 想使用sublime完毕linux平台下django网站的代码编辑工作以提高效率(原来使用linux下的vim效率较低,适合编辑一些小脚本). ...

随机推荐

  1. 05.配置为开发模式、配置静态资源locations、自定义消息转化器、FastJson

    配置为开发模式,代码做了修改,不用重新运行 idea需要该配置,mac测试无效 <dependency> <groupId>org.springframework</gr ...

  2. 知道一个数组某个index对应的值 不知道下标的情况下删除该值

    for (index,item) in Arr.enumerated() { if item == item { Arr.remove(at: index) } } 更好的方法是用数组的filter尾 ...

  3. SQL_2008安装教程(完整版)

    Win 7 win xp系统中SQL2008安装注意事项一:SQL2008 镜像下载地址 http://download.microsoft.com/download/4/C/4/4C402E48-0 ...

  4. PHP curl_exec函数

    curl_exec — 执行一个cURL会话 说明 mixed curl_exec ( resource $ch ) 执行给定的cURL会话. 这个函数应该在初始化一个cURL会话并且全部的选项都被设 ...

  5. POJ 3348 Cows (凸包模板+凸包面积)

    Description Your friend to the south is interested in building fences and turning plowshares into sw ...

  6. php使用curl实现get和post请求的方法,数据传输urldecode和json

    PHP支持CURL库,利用URL语法规定来传输文件和数据的工具,支持很多协议,包括HTTP.FTP.TELNET等. 优点:是可以通过灵活的选项设置不同的HTTP协议参数,并且支持HTTPS.CURL ...

  7. 前端工具-让浏览器兼容ES6特性

    babel:将ES6翻译为ES5 问题: 可以处理import和export么? 不能,还是用Rollup或者webpack打包一下吧 可以处理Promise么? 不能,还是使用babel-plugi ...

  8. python赞乎--学习开发

  9. java多线程学习笔记(七)

    volatile关键字 关键字volatile的主要作用是使变量在多个线程间可见. public class PrintString { private boolean isContinue = tr ...

  10. Oracle基础数据类型与运算符

    Oracle基础数据类型: 1. 字符型:字符串 char(最大2000), nchar(最大1000, 支持                           Unicode)--->固定长 ...