Self-Learning Classifier Example
Self-learning classifier lets HUSKYLENS 2 learn objects and later auto recognize them by ID and name in real time, like a camera that remembers faces. It’s like giving the sensor flashcards it can read back on screen.
1.Self-Learning Classifier Blocks
Before You Start:
1.1 Recognize Learned Objects and Output ID/Name
Under the self-learning classification function, after an object has been learned, HUSKYLENS 2 can recognize it when it sees it again. The following example program can be used to get the corresponding ID and name of the recognized learned object.
from unihiker import GUI
from pinpong.board import Board
from dfrobot_huskylensv2 import *
u_gui=GUI()
Board().begin()
huskylens = HuskylensV2_I2C()
huskylens.knock()
huskylens.switchAlgorithm(ALGORITHM_SELF_LEARNING_CLASSIFICATION)
line1=u_gui.draw_text(text="",x=0,y=0,font_size=16, color="#0000FF")
line2=u_gui.draw_text(text="",x=0,y=40,font_size=16, color="#0000FF")
while True:
huskylens.getResult(ALGORITHM_SELF_LEARNING_CLASSIFICATION)
if (huskylens.available(ALGORITHM_SELF_LEARNING_CLASSIFICATION)):
line1.config(text=(str("Object ID:") + str((huskylens.getCachedCenterResult(ALGORITHM_SELF_LEARNING_CLASSIFICATION).ID if huskylens.getCachedCenterResult(ALGORITHM_SELF_LEARNING_CLASSIFICATION) else -1))))
line2.config(text=(str("Object name:") + str((huskylens.getCachedCenterResult(ALGORITHM_SELF_LEARNING_CLASSIFICATION).name if huskylens.getCachedCenterResult(ALGORITHM_SELF_LEARNING_CLASSIFICATION) else -1))))
Click 'Run' in Mind+ and wait for the program to upload.
After HUSKYLENS 2 finishes learning the object, point the HUSKYLENS 2 camera at the learned object and observe the output results. For detailed instructions on how to learn objects, refer to: Self-Learning Classifier.
Output Result:As shown below, when a learned object appears in the frame, it will be framed, and its name, ID, and confidence level will be displayed. If the object's name has not been set, the default output name is: Object. For how to set the name, please see Self-Learning Classifier.
Was this article helpful?
