做文本检测这个方向的同学应该都知道 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. shell脚本检索所有mysql数据库中没有primary key的表

    1.mkdir -p /root/scripts/ 2. cd /root/scripts/ vim query.sql,代码如下: SELECT CONCAT(t.table_schema,&quo ...

  2. python基础:8.正则表达式

    1.概念 正则表达式是对字符串操作的一种逻辑公式,就是用事先定义好的一些特定字符.及这些特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种过滤逻辑. re模块的常见方法: ...

  3. call_user_func_array — 调用回调函数,并把一个数组参数作为回调函数的参数

    <?php function foobar($arg, $arg2) { echo __FUNCTION__, " got $arg and $arg2\n"; } clas ...

  4. 7天玩转 ASP.NET MVC

    在开始时请先设置firefox中about:config中browser.cache.check_doc_frequecy设置为1,这样才能在关闭浏览器时及时更新JS 第一.二天的内容与之前的重复,这 ...

  5. CentOS7 安装xen(在虚拟机上成功,实体机测试死机!)

    此文章只做操作记录,其中有些地方可能漏了!!我只贴出自己的操作过程!其它有差别的地方请自己网上查找参考! 只有在全虚拟化下才能安装Windows,这就需要有硬件支持,并在BIOS中开启Virtuali ...

  6. ExtJS5.0 菜鸟的第一天

    1.新项目开始啦,后台用户管理页面涉及到表格数据添加,修改内容比较多.准备用EXTJS框架搞下,对于我这种JS不咋地的人来说,还真是个挑战.整了2天,才搞出一个Hello,world!我也是醉了.. ...

  7. C++ 常用数学运算(加减乘除)代码实现 Utils.h, Utils.cpp(有疑问欢迎留言)

    Utils.h #pragma once class Utils { public: static double* array_diff(double*A,double B[],int n); sta ...

  8. uiautomator python版本

    摘要: 利用jsonrpc技术直接包装uiautomator,调用uiautomator的api在本地直接编写脚本,然后运行测试case,这样比用Java写,然后再打包,runcase要简单的多,关键 ...

  9. “TypeError: list indices must be integers or slices, not str”有关报错解决方案

  10. CALayer的mask属性

    可以对图层按path进行指定裁剪 //#import "ViewController.h" // //@interface ViewController () // //@end ...