本文主要研究以方向碼匹配(OCM, Orientation Code Matching)影像辨識技術,在FPGA (Field Programmable Gate Array)實現一個抗旋轉的影像辨識系統並應用在象棋辨識。為了實現象棋文字在旋轉後仍能辨識,首先將影像劃分為90個區塊,並將彩色影像由RGB轉換為HSV格式,以克服棋盤亮度不平均的問題。藉由HSV色彩判斷取得各區塊的影像二值化門檻值,再針對每枚棋子所在區塊影像進行OCM演算法辨識。OCM演算法會對區塊影像進行索貝爾(Sobel)邊緣偵測,由影像梯度角度轉換成16等分方向碼,再進行兩步驟的運算:(1)方向碼直方圖計算及方向碼匹配;(2)根據匹配結果判斷象棋旋轉角度並正確辨識出象棋角色。 本研究使用SoPC (System on a Programmable Chip)做為硬體平台,其上配置有FPGA晶片,在軟硬體協同設計的概念下,將上述方法予以實現。系統主要包含的硬體電路為影像處理電路、硬體周邊電路及OCM演算法電路;軟體部分主要由Nios II 處理器控制Flash存取模板影像,並使用液晶螢幕顯示辨識結果。完成之系統經實際測試證實,能達到影像辨識與抗旋轉的設計目標。
This thesis focuses on the realization of an orientation code matching technique upon a FPGA (Field Programmable Gate Array) for the identification of Chinese chess games. Firstly, an input image is divided into 90 image blocks and each image block is then transformed from RGB format to HSV format to determine its binarization threshold, in order to overcome the illumination varying problem on the chess board. Secondly, the OCM algorithm performs the Sobel edge detection for each image block and the resulting gradient is categorized into one of sixteen sectors. There are sixteen sectors, each with 22.5°, evenly distributed in a circle. Then a two-stage process is executed to realize the rotation-invariant template matching. First, the histogram of the input chess image is compared with the reference histogram. The second is to determine the rotation angle of the chess image and to recognize the chess correctly. This research utilizes a SoPC (System on a Programmable Chip) as the development platform. By following the hardware and software co-design concept the entire system is implemented and accommodated in the FPGA of the SoPC. The resulting system includes an image processing circuit, a peripheral circuit, and orientation code matching algorithm circuit, in software part, the Nios II processor uses a Flash memory to access the template images and uses a LCD screen to display the recognition results. It has experimentally been proven that the system satisfies the goal of image recognition and rotation-invariance.