2017年2月27日 星期一

FAST (Features from Accelerated Segment Test)

上一張經典的圖



















這張圖表示FAST取角點的方法
底下是python的範例

#!/usr/bin/env python3.4
import numpy as np
import cv2
from matplotlib import pyplot as plt

def main():
        """ Main behaviour """
        print("test")
        image = cv2.imread("lena.png")
        gray=cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        fast = cv2.FastFeatureDetector_create()
        keypoints = fast.detect(gray,None)
        image2 = cv2.drawKeypoints(gray, keypoints, image, color=(255,0,0))
        cv2.imshow("Image",image2)
        #取出keypoint的x,y用numpy版本
        np_pts = np.asarray([kp.pt for kp in keypoints])
        print(np_pts[0])
       #keypoint轉成List格式 
        index = []
        for point in keypoints:
          temp = (point.pt, point.size, point.angle, point.response, point.octave, point.class_id)
          index.append(temp)
        print(index[0])
        #---------------List轉keypoint----------------------------------
        #kps = []
        #for point in index:
        #  temp = cv2.KeyPoint(x=point[0][0],y=point[0][1],_size=point[1], _angle=point[2], _response=point[3], _octave=point[4], _class_id=point[5])
        #  kps.append(temp)
        #image3 = cv2.drawKeypoints(gray, kps, image, color=(0,0,255))
        #-------------------------------------------------
        #cv2.imwrite('fast_false.png',image2)
        cv2.waitKey(0)

if __name__ == "__main__":

        main()

2013年8月30日 星期五

Porting new defconfig from versatile_defconfig

First, you need to know that the bootloader pass two information to kernel:
1: register r0  <---- 0
     register r1 <---- machine ID   (it should exist in arch/arm/tools/mach-types and kernel will check it!)
2: parameters structure name ATAG

We copy the source code from versatile board:
$> cp -rf arch/arm/mach-versatile arch/arm/mach-neo
$> cp -rf arch/arm/plat-versatile arch/arm/plat-neo

We add our machine type in arch/arm/tools/mach-types:
$> vi arch/arm/tools/mach-types
----------------------------------------------------------------------------
neo                     MACH_NEO                NEO                    387
----------------------------------------------------------------------------

We modify arch/arm/Kconfig to add ARCH_NEO & PLAT_NEO and source them:
$> vi arch/arm/Kconfig
--------------------------
.................
config ARCH_NEO
        bool "NEO development board"
        select ARM_AMBA
        select ARM_VIC
        select CLKDEV_LOOKUP
        select HAVE_MACH_CLKDEV
        select ICST
        select GENERIC_CLOCKEVENTS
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select PLAT_NEO
        select PLAT_VERSATILE_CLCD
        select PLAT_VERSATILE_FPGA_IRQ
        select ARM_TIMER_SP804
        help
          This enables support for NEO development board.
...................
config PLAT_NEO
        bool
..................
source "arch/arm/mach-neo/Kconfig"
source "arch/arm/plat-neo/Kconfig"
..................
--------------------------

We modify arch/arm/Makefile to refer to mach-neo & plat-neo if we used:
$> vi arch/arm/Makefile
-------------------------
...................
machine-$(CONFIG_ARCH_NEO)      := neo
...................
plat-$(CONFIG_PLAT_NEO)         := neo
..................
-------------------------

We also need to modify arch/arm/mach-neo/Kconfig:
$> vi arch/arm/mach-neo/Kconfig
-------------------------
menu "NEO development board platform type"
        depends on ARCH_NEO

config ARCH_VERSATILE_PB
        bool "Support NEO Platform Baseboard for ARM926EJ-S"
        select CPU_ARM926T
        select MIGHT_HAVE_PCI
        default y
        help
          Include support for the ARM(R) Versatile Platform Baseboard
          for the ARM926EJ-S.

config MACH_VERSATILE_AB
        bool "Support NEO Application Baseboard for ARM926EJ-S"
        select CPU_ARM926T
        help
          Include support for the ARM(R) Versatile Application Baseboard
          for the ARM926EJ-S.

config MACH_VERSATILE_DT
        bool "Support NEO platform from device tree"
        select USE_OF
        select CPU_ARM926T
        help
          Include support for the ARM(R) Versatile/PB platform,
          using the device tree for discovery

endmenu
-------------------------

Modify arch/arm/plat-neo/Kconfig too:
$> vi arch/arm/plat-neo/Kconfig
-------------------------
if PLAT_NEO

config PLAT_VERSATILE_CLCD
        bool

config PLAT_VERSATILE_FPGA_IRQ
        bool

config PLAT_VERSATILE_LEDS
        def_bool y if LEDS_CLASS
        depends on ARCH_REALVIEW || ARCH_NEO

config PLAT_VERSATILE_SCHED_CLOCK
        def_bool y

endif
-------------------------

Now, we can create new defconfig:
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- versatile_defconfig
$> make ARCH=arm menuconfig
-------------------------
System Type  --->
    ARM system type (ARM Ltd. Versatile family)  --->
          (X) NEO development board
    NEO platform type  --->
          [*] Support NEO platform from device tree
          
Kernel Features  --->
     [*] Use the ARM EABI to compile the kernel                                            
     [*]   Allow old ABI binaries to run with this kernel (EXPERIMENTAL) (NEW) 
-------------------------
$> cp .config arch/arm/configs/neo_defconfig

We can make zImage by using our new defconfig:
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- neo_defconfig
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- zImage
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- versatile-pb.dtb

Emulator:
$> qemu-system-arm -M versatilepb -dtb ./versatile-pb.dtb -kernel zImage -initrd rootfs.img -serial stdio -append "root=/dev/ram rdinit=/sbin/init  console=ttyAMA0"


PS:
1 You can install QEMU in UBUNTU by:
$> sudo apt-get install qemu qmeu-kvm-extras
2 "CROSS_COMPILE=arm-none-linux-gnueabi-" depends on your toolchain.
3 rootfs.img.gz can be found in my old post named "Build Rootfs by Busybox for ARM on QEMU"
4 You can see versatile-pb.dts in path arch/arm/boot/dts
5 Because we use "-M versatilepb" to emulate, the machine type in  arch/arm/tools/mach-types should be 387.

Emulate Vexpress-a15 board on QEMU .............. (using Device Tree)

Download Linux Kernel 3.45 first:
$> wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.4.45.tar.bz2
$> tar xvf linux-3.4.45.tar.bz2

Configure:
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- vexpress_defconfig
$> make ARCH=arm menuconfig
------------------------------------------------------------------------------------------------------------
System Type  --->
     Versatile Express platform type  --->
          [*] Device Tree support for Versatile Express platforms
------------------------------------------------------------------------------------------------------------
Now we can build zImage:
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- zImage
Build dtb:
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- vexpress-v2p-ca15-tc1.dtb
Emulate:
$> qemu-system-arm -M vexpress-a15 -serial stdio -dtb ./vexpress-v2p-ca15-tc1.dtb -kernel zImage -initrd rootfs.img -append "root=/dev/ram rdinit=/sbin/init  console=ttyAMA0"



PS:
1 You can install QEMU in UBUNTU by:
$> sudo apt-get install qemu qmeu-kvm-extras
2 "CROSS_COMPILE=arm-none-linux-gnueabi-" depends on your toolchain.
3 rootfs.img.gz can be found in my old post named "Build Rootfs by Busybox for ARM on QEMU"
4 You can see vexpress-v2p-ca15-tc1.dts in path arch/arm/boot/dts

Emulate VersatilePB board on QEMU

Download Linux Kernel 3.45 first:
$> wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.4.45.tar.bz2
$> tar xvf linux-3.4.45.tar.bz2

Configure:
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- versatile_defconfig
$> make ARCH=arm menuconfig
------------------------------------------------------------------------------------------------------------

Kernel Features  --->
     [*] Use the ARM EABI to compile the kernel                                          
     [*]   Allow old ABI binaries to run with this kernel (EXPERIMENTAL) (NEW)

------------------------------------------------------------------------------------------------------------
Now we can build zImage:
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- zImage
Emulate:
$> qemu-system-arm -M versatilepb -m 128M -kernel arch/arm/boot/zImage -initrd ../rootfs.img.gz -append "root=/dev/ram rdinit=/sbin/init"



PS:
1 You can install QEMU in UBUNTU by:
$> sudo apt-get install qemu qmeu-kvm-extras
2 "CROSS_COMPILE=arm-none-linux-gnueabi-" depends on your toolchain.
3 rootfs.img.gz can be found in my old post named "Build Rootfs by Busybox for ARM on QEMU"

Build Rootfs by Busybox for ARM on QEMU

Download busybox first:
$> wget http://busybox.net/downloads/busybox-1.21.1.tar.bz2
$> tar xvf busybox-1.21.1.tar.bz2

Configure:
$> make menuconfig
------------------------------------------------------------------------------------------------------------
Busybox settings --> Build option
                                     "Build busybox as a static binary"
                           --> cross compiler prefix
                                      "arm-none-linux-gnueabi-"                       <----Depends on your cross_compiler
------------------------------------------------------------------------------------------------------------
$> make
$> make install
Now we can build rootfs.img:
$> cd _install
$> mkdir proc sys dev etc etc/init.d
$> cat << EOF > etc/init.d/rcS
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s
EOF
$> chmod +x etc/init.d/rcS
$> find . | cpio -o --format=newc > ../rootfs.img
Create rootfs.img.gz:
$> cd ..
$> gzip -c rootfs.img > rootfs.img.gz

2012年12月31日 星期一

VI

sudo apt-get install vim

選擇顏色方案:

ls /usr/share/vim/vim73/colors/
可以看到很多方案
blue.vim      
...
evening.vim
等等

sudo vi ~/.vimrc


set fileencodings=utf-8,cp936,big5,latin1 
set encoding=utf-8 
set termencoding=cp936 
set fileencoding=utf-8
colorscheme evening 
set number
set nobackup 
set autoindent 
set smartindent 
filetype indent on

2012年12月19日 星期三

VMware-player 使用vmnetcfg.exe

在cmd命令行進入VMware安裝文件所在的目錄下運行:
VMware-player-4.0.3-703057.exe /e ./vmware-player-extend
然後會生成vmware-player-extend目錄,在裏面找到network.cab,解壓它之後可以找到vmnetcfg.exe文件,拷貝它至VMwarePlayer安裝根目錄下並運行,通過而配置