
Raspberry Pi 花色辨識技術揭秘
以下為官方發布原文照登(未改寫、未翻譯),來源連結見本頁。(原文語言:英文)

This Maker Monday , a project with potential for clinical applications caught our eye. A Raspberry Pi 3 Model B+ and a Raspberry Pi Camera Module 3 use OpenCV to determine the colour of the iris looking into the camera.
For the majority of people, just checking in the mirror and recognising your eye colour is fairly simple. Our brains are able to process that information pretty easily. How would a computer do it, though? If you read our magazine, chances are you already have a half-formed answer in your head based around computer vision. Srikrishna Karthick, a student currently working for the Indian Space Research Organisation (ISRO) on their thesis, already has the answer for you.

“Every year, the Muscle Physiology Laboratory at IISER Tirupati [in India] participates in National Science Day celebrations by setting up an exhibit alongside other laboratories and student groups,” Srikrishna tells us. “The Muscle Physiology Lab displays fruit flies (Drosophila) with different eye-colour phenotypes, for explaining the genetic mechanisms underlying the inheritance of eye colour. To make the demonstration more engaging and relatable to visitors, it was proposed that the eye colours of attendees could also be recorded and their distribution displayed in real time.”
To avoid a manual tally and manual data analysis, an electronic method was proposed. With an objective to inspire younger students, and a short deadline, Raspberry Pi ended up being the obvious choice.
The build mainly consists of a Raspberry Pi 3 Model B+ and a Raspberry Pi Camera Module 3 . A button — connected to Raspberry Pi’s GPIO header — is pushed, which triggers the capture of a photo that is then handed over to OpenCV for processing.

“The captured image is automatically processed to detect the subject’s face and eyes using OpenCV Haar cascade classifiers,” Srikrishna explains. “Once the eye region is identified, the iris is localised using a Daugman-inspired circular gradient search algorithm that estimates the iris boundary.”
“Pixels contained within the detected iris region are extracted, while non-iris areas such as the sclera are removed through brightness and saturation-based filtering. Colour information is subsequently analysed using both RGB and HSV colour histograms. To determine the dominant iris colour, k-means clustering is performed on the extracted iris pixels in both RGB and HSV feature spaces, and the largest cluster is selected as the representative iris colour. Finally, the dominant colour is classified into categories such as dark brown, brown, light brown, blue, green, amber, or grey using predefined HSV threshold ranges.”
The results showing the eye colour distribution among attendees are displayed in a histogram.

This was Srikrishna’s first time using a Raspberry Pi, but he found the abundant online resources more than enough to help get the final project working within the short week-long deadline.
“[The project was] a resounding success; it ran without a glitch and worked as intended for roughly 350 visitors,” Srikrishna says. “The ML code was rigorously tested with datasets of human face images. The algorithms that were used are known for their high reliability (such as the Daugman algorithm [that] is used for iris recognition worldwide). The hardware was quite reliable; though I was initially worried, our Raspberry Pi didn’t overheat. The push-button connection was fairly simple, so once connected properly, there were no hitches along the way.”

Srikrishna notes that clinical applications of computer vision and machine learning have become popular recently, and this project can be modified to benefit that.
“The plan is to upscale the computer vision code for diagnosing cataracts and various kinds of fungal infections of the eye,” Srikrishna explains. “We have a small team of enthusiastic students working on this since the last three months and would love to be joined by interested folks who’re reading this article.”
Srikrishna would like to thank Dr Prasanna Katti (Principal Investigator of the Muscle Physiology Lab) and the Science Day Committee at IISER Tirupati for approving the purchase of a Raspberry Pi and accessories for this project.
This article appeared in issue 168 of Raspberry Pi Official Magazine , which you can access online .

You can find Raspberry Pi Official Magazine on Facebook , X , Threads , LinkedIn , and Mastodon . You can also contact the team via email: [email protected]

Δ document.getElementById( "ak_js_1" ).setAttribute( "value", ( new Date() ).getTime() );
規格
- 主要硬體
- Raspberry Pi 3 Model B+ 和 Raspberry Pi Camera Module 3
- 影像處理演算法
- OpenCV Haar 梯度分類器、Daugman 等式圓形梯度搜索演算法
- 顏色分析方法
- RGB 和 HSV 色彩直方圖、K-means 聚類
來源連結
規格與發布資訊引用自官方來源;本文評析為本站原創。
在這次的實驗中,Srikrishna Karthick 運用 Raspberry Pi 和 Raspberry Pi Camera Module 3 建立了一個花色辨識系統。他的目標是通過自動化的資料分析讓展示更有趣也更具吸引力。
該系統主要通過攝像頭捕捉 Attendees 的照片,利用 OpenCV 和 Haar 梯度分類器進行面部和眼睛檢測。經過一系列的影像處理步驟,最終可以確定並展示出 Attendees 眼睛顏色的分佈。
儘管是首次使用 Raspberry Pi,但 Srikrishna 表示他對這項技術的應用感到非常滿意。未來他計劃進一步改進系統,並將其應用於更多的實際場景中。
優點
- 低成本且易於部署
- 可自動化資料分析過程
缺點
- 需要一定程式設計技能才能設定和維護
討論區