• Open Source Computer Vision Library

OpenCV在龙芯电脑上的测试

Wikipedia,自由的百科全书

龙芯是一种MIPS指令集的通用RISC处理器,由中科院计算所研发,中科龙梦生产,具有低功耗的特点。在一些计算机视觉的应用中,应该可以使用龙芯系统来完成某些功能。为了为大家提供一个参考,特进行了一次OpenCV在龙芯电脑的测试。

测试电脑为使用龙芯2E CPU的福珑迷你电脑,俗称龙芯盒子。

目录

硬件配置

CPU信息

命令 cat /proc/cpuinfo 的输出为:

system type             : Lemote Fulong mini-PC board
processor               : 0
cpu model               : Godson2 V0.2  FPU V0.1
BogoMIPS                : 444.41
wait instruction        : no
microsecond timers      : yes
tlb_entries             : 64
extra interrupt vector  : no
hardware watchpoint     : no
ASEs implemented        :
VCED exceptions         : not available
VCEI exceptions         : not available

内存信息

命令 cat /proc/meminfo 的输出为:

MemTotal:       514592 kB
MemFree:         64768 kB
Buffers:         11104 kB
Cached:         134288 kB
SwapCached:          0 kB
Active:         371216 kB
Inactive:        36960 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       514592 kB
LowFree:         64768 kB
SwapTotal:      247312 kB
SwapFree:       247072 kB
Dirty:             368 kB
Writeback:           0 kB
AnonPages:      262816 kB
Mapped:         101584 kB
Slab:            27408 kB
PageTables:       5216 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:    504608 kB
Committed_AS:   536736 kB
VmallocTotal: 137438953472 kB
VmallocUsed:      4592 kB
VmallocChunk: 137438948592 kB

操作系统与软件

Debian,内核为2.6.18,

命令 uname -a 的输出为 uname -a

Linux debian 2.6.18.1-loongson2e-lm32 #1 PREEMPT Fri Sep 14 04:40:24 CST 2007 mips64 GNU/Linux

命令 gcc -v 的输出为:

Using built-in specs.
Target: mipsel-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix 
--enable-nls --with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1 --enable-__cxa_atexit 
--enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --disable-libssp 
--enable-checking=release mipsel-linux-gnu
Thread model: posix
gcc version 4.1.3 20070831 (prerelease) (Debian 4.1.2-16)

命令 g++ -v 的输出为:

Using built-in specs.
Target: mipsel-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix 
--enable-nls --with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1 --enable-__cxa_atexit 
--enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr 
--disable-libssp --enable-checking=release mipsel-linux-gnu
Thread model: posix
gcc version 4.1.3 20070831 (prerelease) (Debian 4.1.2-16)

OpenCV安装

目前Debian的软件仓库中已经包含了OpenCV 1.0, 可以按照本网站提供的Debian下安装,一个命令搞定安装。

apt-get install libcv-dev libcvaux-dev libhighgui-dev


OpenCV测试

测试程序为OpenCV 1.0源代码中tests目录下的测试程序。

cxcore模块测试

OpenCV源代码解压后,先进入tests/cxcore/src目录, 运行下面的命令生成测试程序cxcoretest。

g++ `pkg-config --libs --cflags opencv` -o cxcoretest *.cpp  ../../cxts/*.cpp -I../../cxts

然后运行./cxcoretest,69个测试全部通过,耗时33分37秒。

该测试在Intel P4 3.0G计算机上需要的时间是4分49秒,69个测试也全部通过。

cxcoretest的输出结果如下:


WARNING: config name is not specified, using default parameters
Engine: CxTest 0.1
Execution Date & Time: Sun Sep 16 19:56:31 2007
Config File: (null)
Tested Libraries: cxcore: 1.0.0, cv: 1.0.0
Optimized Low-level Plugin's: 
=================================================
-------------------------------------------------
arithm-absdiff: ..............................................  Ok
-------------------------------------------------
arithm-absdiffs: .............................................  Ok
-------------------------------------------------
arithm-add: ..................................................  Ok
-------------------------------------------------
arithm-adds: .................................................  Ok
-------------------------------------------------
arithm-addweighted: ..........................................  Ok
-------------------------------------------------
arithm-div: ..................................................  Ok
-------------------------------------------------
arithm-max: ..................................................  Ok
-------------------------------------------------
arithm-maxs: .................................................  Ok
-------------------------------------------------
arithm-min: ..................................................  Ok
-------------------------------------------------
arithm-mins: .................................................  Ok
-------------------------------------------------
arithm-mul: ..................................................  Ok
-------------------------------------------------
arithm-recip: ................................................  Ok
-------------------------------------------------
arithm-sub: ..................................................  Ok
-------------------------------------------------
arithm-subrs: ................................................  Ok
-------------------------------------------------
cmp-cmp: .....................................................  Ok
-------------------------------------------------
cmp-cmps: ....................................................  Ok
-------------------------------------------------
cmp-inrange: .................................................  Ok
-------------------------------------------------
cmp-inranges: ................................................  Ok
-------------------------------------------------
cvt-scale: ...................................................  Ok
-------------------------------------------------
cvt-scaleabs: ................................................  Ok
-------------------------------------------------
ds-graph: ..................................................................................................................................................k      Ok
-------------------------------------------------
ds-seq-base: ......................     Ok
-------------------------------------------------
ds-seq-sortinv: ............................................................................................................................................................................. Ok
-------------------------------------------------
ds-set: .............................   Ok
-------------------------------------------------
dxt-dct: .....................................................  Ok
-------------------------------------------------
dxt-dft: .....................................................  Ok
-------------------------------------------------
dxt-mulspectrums: ............................................  Ok
-------------------------------------------------
logic-and: ...................................................  Ok
-------------------------------------------------
logic-ands: ..................................................  Ok
-------------------------------------------------
logic-not: ...................................................  Ok
-------------------------------------------------
logic-or: ....................................................  Ok
-------------------------------------------------
logic-ors: ...................................................  Ok
-------------------------------------------------
logic-xor: ...................................................  Ok
-------------------------------------------------
logic-xors: ..................................................  Ok
-------------------------------------------------
math-cart2polar: .............................................  Ok
-------------------------------------------------
math-exp: ....................................................  Ok
-------------------------------------------------
math-log: ....................................................  Ok
-------------------------------------------------
math-polar2cart: .............................................  Ok
-------------------------------------------------
math-pow: ....................................................  Ok
-------------------------------------------------
matrix-covar: ................................................  Ok
-------------------------------------------------
matrix-crossproduct: .........................................  Ok
-------------------------------------------------
matrix-det: ..................................................  Ok
-------------------------------------------------
matrix-dotproduct: ...........................................  Ok
-------------------------------------------------
matrix-gemm: .................................................  Ok
-------------------------------------------------
matrix-invert: ...............................................  Ok
-------------------------------------------------
matrix-mahalanobis: ..........................................  Ok
-------------------------------------------------
matrix-multransposed: ........................................  Ok
-------------------------------------------------
matrix-perspective: ..........................................  Ok
-------------------------------------------------
matrix-scaleadd: .............................................  Ok
-------------------------------------------------
matrix-solve: ................................................  Ok
-------------------------------------------------
matrix-svbksb: ...............................................  Ok
-------------------------------------------------
matrix-svd: ..................................................  Ok
-------------------------------------------------
matrix-trace: ................................................  Ok
-------------------------------------------------
matrix-transform: ............................................  Ok
-------------------------------------------------
mem-copy: ....................................................  Ok
-------------------------------------------------
mem-fill: ....................................................  Ok
-------------------------------------------------
mem-flip: ....................................................  Ok
-------------------------------------------------
mem-merge: ...................................................  Ok
-------------------------------------------------
mem-setidentity: .............................................  Ok
-------------------------------------------------
mem-setzero: .................................................  Ok
-------------------------------------------------
mem-split: ...................................................  Ok
-------------------------------------------------
mem-transpose: ...............................................  Ok
-------------------------------------------------
stat-mean: ...................................................  Ok
-------------------------------------------------
stat-mean_stddev: ............................................  Ok
-------------------------------------------------
stat-minmaxloc: ..............................................  Ok
-------------------------------------------------
stat-nonzero: ................................................  Ok
-------------------------------------------------
stat-norm: ...................................................  Ok
-------------------------------------------------
stat-sum: ....................................................  Ok
=================================================
Summary: 0 out of 69 tests failed
Running time: 00:33:37

cv模块测试

OpenCV源代码解压后,先进入tests/cv/src目录, 运行下面的命令生成测试程序cvtest,并将生成的cvtest放入到一个子目录中(cvtest程序从../../testdata中寻找测试数据)。

g++ `pkg-config --libs --cflags opencv` -o cvtest *.cpp  ../../cxts/*.cpp -I../../cxts
mkdir tmp
mv cvtest tmp/
cd tmp
./cvtest

然后运行./cvtest,78个测试通过77个,有一个(shape-moments)因为精度问题出错(Bad accuracy)),耗时45分39秒。

该测试在Intel P4 3.0G计算机上需要的时间是3分46秒,78个测试全部通过。

WARNING: config name is not specified, using default parameters
Engine: CxTest 0.1
Execution Date & Time: Sun Sep 16 20:59:59 2007
Config File: (null)
Tested Libraries: cxcore: 1.0.0, cv: 1.0.0
Optimized Low-level Plugin's: 
=================================================
-------------------------------------------------
_3d-cvt-homogen: .............................................  Ok
-------------------------------------------------
_3d-epilines: ................................................  Ok
-------------------------------------------------
_3d-fundam: ..................................................  Ok
-------------------------------------------------
_3d-rodrigues: ...............................................  Ok
-------------------------------------------------
accum-acc: ...................................................  Ok
-------------------------------------------------
accum-mulacc: ................................................  Ok
-------------------------------------------------
accum-runavg: ................................................  Ok
-------------------------------------------------
accum-squareacc: .............................................  Ok
-------------------------------------------------
calibratecamera:        Ok
-------------------------------------------------
canny: .......................................................  Ok
-------------------------------------------------
chessboard-detector: .......    Ok
-------------------------------------------------
color-bayer: .................................................  Ok
-------------------------------------------------
color-gray: ..................................................  Ok
-------------------------------------------------
color-hls: ...................................................  Ok
-------------------------------------------------
color-hsv: ...................................................  Ok
-------------------------------------------------
color-lab: ...................................................  Ok
-------------------------------------------------
color-luv: ...................................................  Ok
-------------------------------------------------
color-rgb: ...................................................  Ok
-------------------------------------------------
color-xyz: ...................................................  Ok
-------------------------------------------------
color-ycc: ...................................................  Ok
-------------------------------------------------
contour-approx:         Ok
-------------------------------------------------
contour-find: ................................................  Ok
-------------------------------------------------
distrans: ....................................................  Ok
-------------------------------------------------
emd:    Ok
-------------------------------------------------
features-evalvec: ............................................  Ok
-------------------------------------------------
features-mineval: ............................................  Ok
-------------------------------------------------
features-precorner: ..........................................  Ok
-------------------------------------------------
filter-blur: .................................................  Ok
-------------------------------------------------
filter-gaussian: .............................................  Ok
-------------------------------------------------
filter-generic: ..............................................  Ok
-------------------------------------------------
filter-laplace: ..............................................  Ok
-------------------------------------------------
filter-median: ...............................................  Ok
-------------------------------------------------
filter-sobel: ................................................  Ok
-------------------------------------------------
floodfill: ...................................................  Ok
-------------------------------------------------
hist-backproj: ...............................................  Ok
-------------------------------------------------
hist-backprojpatch: ..........................................  Ok
-------------------------------------------------
hist-bayesianprob: ...........................................  Ok
-------------------------------------------------
hist-calc: ..................................................   Ok
-------------------------------------------------
hist-compare: ................................................  Ok
-------------------------------------------------
hist-minmax: .................................................  Ok
-------------------------------------------------
hist-normalize: ..............................................  Ok
-------------------------------------------------
hist-query: ..................................................  Ok
-------------------------------------------------
hist-threshold: ..............................................  Ok
-------------------------------------------------
integral: ....................................................  Ok
-------------------------------------------------
kalman:         Ok
-------------------------------------------------
match-template: ..............................................  Ok
-------------------------------------------------
mhi-global: ..................................................  Ok
-------------------------------------------------
mhi-gradient: ................................................  Ok
-------------------------------------------------
mhi-update: ..................................................  Ok
-------------------------------------------------
moments-hu: ..................................................  Ok
-------------------------------------------------
moments-raster: ..............................................  Ok
-------------------------------------------------
morph-dilate: ................................................  Ok
-------------------------------------------------
morph-erode: .................................................  Ok
-------------------------------------------------
optflow-pyrlk:  Ok
-------------------------------------------------
posit: ...................      Ok
-------------------------------------------------
pyramid-down: ................................................  Ok
-------------------------------------------------
pyramid-up: ..................................................  Ok
-------------------------------------------------
segmentation-pyramid:   Ok
-------------------------------------------------
shape-convhull: ..............................................  Ok
-------------------------------------------------
shape-fit-ellipse: ...........................................  Ok
-------------------------------------------------
shape-fit-line: ..............................................  Ok
-------------------------------------------------
shape-minarearect: ...........................................  Ok
-------------------------------------------------
shape-mincircle: .............................................  Ok
-------------------------------------------------
shape-moments: ...................      FAIL(Bad accuracy)
-------------------------------------------------
shape-perimeter: .............................................  Ok
-------------------------------------------------
snakes: .       Ok
-------------------------------------------------
subdiv: .....................................................   Ok
-------------------------------------------------
thresh-simple: ...............................................  Ok
-------------------------------------------------
track-camshift: ..............................................  Ok
-------------------------------------------------
track-meanshift: .............................................  Ok
-------------------------------------------------
warp-affine: .................................................  Ok
-------------------------------------------------
warp-perspective: ............................................  Ok
-------------------------------------------------
warp-remap: ..................................................  Ok
-------------------------------------------------
warp-resize: .................................................  Ok
-------------------------------------------------
warp-subpix-quad: ............................................  Ok
-------------------------------------------------
warp-subpix-rect: ............................................  Ok
-------------------------------------------------
warp-undistort: ..............................................  Ok
-------------------------------------------------
warp-undistort-map: ..........................................  Ok
=================================================
Summary: 1 out of 78 tests failed
Running time: 00:45:39

综合评价

OpenCV可以在龙芯电脑上使用,且计算结果准确度没有问题(cvtest中的shape-moments因精度问题测试未通过不是严重问题),但是计算速度比目前流行PC慢,在对实时性要求高的应用中应该注意算法复杂度。

测试人与致谢

  • 测试人:于仕琪
  • 测试时间:2007年9月16日
  • 感谢安恒公司的刘世伟经理提供测试环境。
Views
Personal tools