NVIDIA Jetson Nano學習筆記(七):即時影像偵測暨辨識系統(PiCamera+OpenCV+TensorFlow Lite+Firebase)

本文章假設讀者已完成TF Runtime的安裝,並且已經自行裝上Pi Camera、設定好Firebase的RealTime Database及Storage。

(1)尚未安裝TF Runtime的讀者可以參考:
NVIDIA Jetson Nano學習筆記(四):安裝與執行Tensorflow Lite Model官方範例

(2)尚未設定好Firebase的RealTime Database及Storage的讀者可以參考:

Learning Firebase(1):Create Your First Project
Learning Firebase(2):CRUD Our Database with Python
Learning Firebase(3):Upload Image to Firebase with Python

NVIDIA Jetson Nano學習筆記(五):即時影像分類系統(PiCamera+OpenCV+TensorFlow Lite+Firebase)一文當中,我和大家介紹了如何在Jetson Nano中,透過PiCamera進行即時的Image Classification。

NVIDIA Jetson Nano學習筆記(六):即時影像偵測系統(PiCamera+OpenCV+TensorFlow Lite)一文當中,我和大家介紹了如何在Jetson Nano中,透過PiCamera進行即時的Object Detection。


本文延續前兩次的主題,結合了Object Detection和Image Classification。

Google官方提供的Object Detection Pre-trained Model準確度還不錯,未來解決我們Self-trained Model誤判的情形,我們先用物件偵測來判斷是否為指定的Label,如果是,我們再透過影像分類,來做詳細Label Name分類。

GitHub Repo:


[1] Load Pre-trained (Object Detection) and Self-trained (Image Classification)TFLite Model with Argument.[2] Read image from PiCamera with OpenCV to do Real-Time Object Detection.[3] If detect specific object ("bird" in the code), save the image.[4] Use Self-trained Model to do Image Classification on the image with OpenCV.[5] Upload the Image and classification result (LabelName, ScoreValue, Time, Pubic-Access Image Url) to Firebase Database[6] Save the above result (LabelName, ScoreValue, Time, Pubic-Access Image Url) as a csv file with append mode.[7] Once the image and data have been uploaded to Firebase, delete the local images to prevent running out of disk space.


python3 object_detection_and_image_classification.py



Sample_TFLite_model/:Contain the object detection model and label


object_detection_and_image_classification.py:Our main program of this project.TFLite_Read_Image.py:Read Image with OpenCV to Image Classification.test.tflite:Image Classification TFLite Model.test.txt:Image Classification TFLite label.firebase_key.json:If you want to use firebase to store your data, you should have it.


Written by

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store