基于zed的tesseract移植过程记录
道什么原 因,在挂载目录下面也不能执行tesseract命令,以为找不到库文件,即使我指定了LD_LIBRARY宏还是不得行,于是又尝试了下把相关的lib 和bin弄到根文件系统里面去,然后做成镜像文件,替换那个ramdisk8M, 可是根本执行不了。。这咋办捏。。记录之。。
/usr/local/share # cp /mnt/tesseract-3.01/bin/* /usr/local/bin/
/usr/local/share # cp /mnt/tesseract-3.01/lib/* /usr/local/lib/
cp: write error: No space left on device
cp: write error: No space left on device
/usr/local/share #
----------------------------------分割线---------------------------------------
我记录自己所做的东西,已经到了交叉编译好了leptonica和tesseract了,就等着在板子上运行一下,看对不对了。结果发现把相关的文 件弄到板子上的时候就提示说空间不够,要说我是个新手呢,说到底还是理解的不够啊,不过还好小组里面其他人理解了,说是因为根文件系统制作的时候只有8M 的空间,那些库文件可不小哦,所以放不下赛,于是小组的阳平同学又做了个1G镜像文件,启动还是从ramdisk8M这个根文件系统开始,前面都差不多, 在读取了设备数,正确引导内核执行rcS文件里面的东西的时候,添加了代码,意思是把挂载那个1G的文件系统,然后切换根目录,就相当于现在整个运行空间 是1G的空间,不在是那个8M 的空间了。但说为什么不直接一开始就不要那个ramdisk8M,直接只用这个1G的呢,因为我们不知道怎么产生正确U-boot啊!引导的工作都是交给 u-boot的,至于那个boot.bin只不过还包含了PS,PL的配置而已。像书附件光盘的第二个实验就只提供了 boot.bin,这个没有多大的参考,因为大家的PS,PL需要不同的配置。以上这些都是阳平做的工作,哈哈
现在空间够了,首先把SD卡挂载到虚拟机的 /mnt/sdcard/下面:mount -t vboxsf SDCARD /mnt/sdcard
然后把sd卡中的1G的镜像挂载:mount /mnt/sdcard/disk1G.img /mnt/disk1g
然后把在虚拟上用交叉工具编译好的,安装好的相关文件拷贝,其实就是拷贝bin 和lib文件就可以执行了。当然还需要包括 leptonica·的库文件,才能正确调用相关的图像处理库函数。
cp /home/gzw/install/tesseract-3.01/lib/* /mnt/disk1g/usr/local/lib/
cp /home/gzw/install/tesseract-3.01/bin/* /mnt/disk1g/usr/local/bin/
还需要拷贝eng.traineddata 到/mnt/disk1g/usr//local/share/tessdata/
别以为拷贝完这些就够了,还不够,在执行的出现错误提示说没找到 libstdc++.so库什么的,我找了一下这个文件的位置,发现在我们的交叉编译工具里面arm-xilin-linux-gnueabi/libc /usr/lib 下面,这个文件夹下面的东西在制作根文件系统的时候没有可拷贝的,所以这里也需要拷贝才行。
在所以得都拷贝完成之后,将SD卡插入到ZED上面,然后启动成功之后,切换到执行目录下面/usr/local/bin,然后export LD_LIBRARAY_PATH=/usr/local/bin指定库文件,export TESSDATA_PREFIX=/usr/local/share/ 指定数据库文件,其实就是字库,我实验用的英文的字库,需要识别的图片也是一副全是英文的图片。
然后执行./tesseract phototest.bmp phototest.txt -l eng,没有提示错误表示成功输出了,并且在当前目录下面产生txt文件,就是识别的结果,利用cat可以将文件内容显示出来,如下:
This is a lot of 12 point text to test the
ocr code and see if it works on all types
of file format.
The quick brown dog jumped over the
lazy fox. The quick brown dog jumped
over the lazy fox. The quick brown dog
jumped over the lazy fox. The quick
brown dog jumped over the lazy fox.
原图片就是上面这些英文的图片。
说明:在执行程序的时候很多时候提示我找不到相关的图像处理的函数,这些函数 应该需要一些图像处理的库,我只拷贝了leptonica库和tesseract的库,以及tesseract的bin,最后发现只能识别处理bmp图 像。需要处理其他图像只需要把那些图像处理库拷贝应该就可以了,虽然说leptonica应该就包含了很多的图像处理,应该是够用的,结果发现不够。呵呵 呵额呵呵。
一下就只执行的输出的,mark一下。。。。
[ 0.800000] xusbps-ehci xusbps-ehci.0: irq 53, io mem 0x00000000
[ 0.830000] xusbps-ehci xusbps-ehci.0: USB 2.0 started, EHCI 1.00
[ 0.830000] hub 1-0:1.0: USB hub found
[ 0.830000] hub 1-0:1.0: 1 port detected
[ 0.840000] IniTIalizing USB Mass Storage driver...
[ 0.840000] usbcore: registered new interface driver usb-storage
[ 0.850000] USB Mass Storage support registered.
[ 0.850000] Xilinx PS USB Device Controller driver (Apr 01, 2011)
[ 0.860000] mousedev: PS/2 mouse device common for all mice
[ 0.860000] Linux video capture interface: v2.00
[ 0.870000] gspca_main: v2.14.0 registered
[ 0.870000] usbcore: registered new interface driver uvcvideo
[ 0.870000] USB Video Class driver (1.1.1)
[ 0.880000] WDT OF probe
[ 0.880000] xwdtps f8005000.swdt: Xilinx Watchdog TImer at 0xe081c000 with TI
meout 10 seconds
[ 0.890000] sdhci: Secure Digital Host Controller Interface driver
[ 0.890000] sdhci: Copyright(c) Pierre Ossman
[ 0.900000] sdhci-pltfm: SDHCI platform and OF driver helper
[ 0.900000] mmc0: Invalid maximum block size, assuming 512 bytes
[ 0.910000] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using A
DMA
[ 0.910000] usbcore: registered new interface driver usbhid
[ 0.920000] usbhid: USB HID core driver
[ 0.920000] No connectors reported connected with modes
[ 0.930000] adv7511 0-0039: Failed to add route DAI IN->TMDS
[ 0.940000] [drm] Cannot find any crtc or sizes - going 1024x768
[ 0.940000] drivers/gpu/drm/analog/analog_drm_fbdev.c:analog_drm_fbdev_probe[
241]
[ 0.960000] asoc: adv7511 <-> 75c00000.axi-spdif-tx mapping ok
[ 0.970000] axi-spdif 75c00000.axi-spdif-tx: Failed to set DAI format: -22
[ 0.970000] Console: switching to colour frame buffer device 128x48
[ 0.980000] ALSA device list:
[ 0.980000] #0: HDMI monitor
[ 0.980000] TCP cubic registered
[ 0.980000] NET: Registered protocol family 17
[ 0.980000] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9
rev 4
[ 0.980000] Registering SWP/SWPB emulaTIon handler
[ 0.980000] registered taskstats version 1
[ 0.980000] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[ 1.000000] mmc0: new high speed SDHC card at address b368
[ 1.000000] mmcblk0: mmc0:b368 F0F0F 3.71 GiB
[ 1.030000] mmcblk0: p1
[ 1.030000] fb0: frame buffer device
[ 1.030000] drm: registered panic notifier
[ 1.030000] [drm] Initialized analog_drm 1.0.0 20110530 on minor 0
[ 1.050000] RAMDISK: gzip image found at block 0
[ 1.480000] EXT4-fs (ram0): warning: mounting unchecked fs, running e2fsck is
recommended
[ 1.490000] EXT4-fs (ram0): mounted filesystem without journal. Opts: (null)
[ 1.500000] VFS: Mounted root (ext4 filesystem) on device 1:0.
[ 1.500000] Freeing init memory: 152K
Starting rcS...
++ Mounting filesystem (0)
++ Setting up mdev (0)
++ Changing root filesystem
[ 1.830000] EXT4-fs (loop0): mounting ext2 file system using the ext4 subsyst
em
[ 1.850000] EXT4-fs (loop0): warning: mounting unchecked fs, running e2fsck i
s recommended
[ 1.850000] EXT4-fs (loop0): mounted filesystem without journal. Opts: (null)
++ Mounting filesystem (1)
++ Setting up mdev (1)
++ Starting telnet daemon
++ Starting http daemon
++ Starting ftp daemon
++ Starting dropbear (ssh) daemon
/bin/sh: can't access tty; job control turned off
/ # export LD_LIBRARY_PATH=/usr/local/lib
/ # export TESSDATA_PREFIX=/usr/local/share/
/ # cd /usr/local/bin
/usr/local/bin # ls
1.out.txt phototest.GIF tesseract
cntraining phototest.JPG unicharset_extractor
combine_tessdata phototest.PNG wordlist2dawg
eng.traineddata phototest.bmp
mftraining phototest.tif
/usr/local/bin # ./tesseract phototest.bmp phototest.txt -l eng
Tesseract Open Source OCR Engine v3.01 with Leptonica
/usr/local/bin # cat phototest.txt
cat: can't open 'phototest.txt': No such file or directory
/usr/local/bin # ls
1.out.txt phototest.GIF phototest.txt.txt
cntraining phototest.JPG tesseract
combine_tessdata phototest.PNG unicharset_extractor
eng.traineddata phototest.bmp wordlist2dawg
mftraining phototest.tif
/usr/local/bin # cat phototest.txt.txt
This is a lot of 12 point text to test the
ocr code and see if it works on all types
of file format.
The quick brown dog jumped over the
lazy fox. The quick brown dog jumped
over the lazy fox. The quick brown dog
jumped over the lazy fox. The quick
brown dog jumped over the lazy fox.