New Function Update: Object Classification
userhead
HuskyLens Team 2020-06-05 14:46:49
recommend article


HuskyLens Update: Object Classificationled

In the new version 0.4.9Class, a new function “Object Classification” is released. The expected machine learning capabilities are finally coming. What could we do with this new function? Let’s check it out.


What is the object classification?

The object classification function of HuskyLens can learn from multiple photos of different objects by built-in machine learning algorithms. After completing the object classification learning, when HuskyLens detects the learned object, it  can recognize and display the object ID number. Well, the more it learns, the more accurate the recognition can be.  


What could we do with the object classification?

 Now we all know HuskyLens supports 6 basic functions: face recognition, object tracking, object recognition, line tracking, color recognition and tag recognition.

Well, when a popular project Mask Recognition comes, which is to recognize whether people are wearing masks. What could HuskyLens do? 

Face recognition cannot distinguish masks, object tracking cannot learn multiple masks, object recognition cannot recognize them, not to mention color recognition and tag recognition. But now, with the new function - object classification, HuskyLens can recognize and distinguish face with a mask. But how to do?

 First, learn a face without a mask(class1).

 Then, learn the face with a simple mask(class2).

 And, you can also learn the face with a KN95 mask(class3). 

Afterward, HuskyLens can recognize them . You will find that when HuskyLens show ID1 when recognizing the object without a mask, show ID2 when to recognize the object with a simple mask, and show ID3 when to recognize the object with a KN95 mask. What’s more, the best thing is that the object classification does not distinguish faces of different peoples, everyone can do that. 

Let’s practice it!


Example 1:  Mask Recognition


Step1
Update the Firmware

Update the firmware to the  HUSKYLENSWithModelV0.4.9Class.kfpkg with K-Flash.

Please refer to Section 4 in the wiki for more details. 

projectImage
Step2
Train to Learn

Switch to the Object Classification, press the learning button to learn images without a mask. With a long press, HuskyLens can learn images from different angles. Again, the more it learns, the more accurate the recognition can be. Pictures of more than 30 are recommended. Release the button, then the learning process is accomplished. 

Next, similar operations, let HuskyLens learn images with a mask, also learn more than 30 pictures, then release the learning button.

projectImage
Step3
Recognition Test

After the learning is accomplished, point HuskyLens to the image without a mask, and the image with a mask, if the screen shows ID1 and ID2 respectively, which means HuskyLens has already defined these 2 types objects. 

projectImage
Step4
Coding

Once HuskyLens can recognize objects, we can create a project with the mainboard, such as Arduino or micro:bit. 

Here we use micro:bit to realize a mask alarm. If HuskyLens detects a mask in a face, the '√' will be on. Otherwise, the '×' will be ON. 

The object classification does not have to switch algorithms, you can read the amount of learned boxes and IDs of boxes.

Please refer to Setcion 10 in the wiki for more details about the wiring, loading extension and etc.

The sample code based on makecode for micro:bit is shown as below.

projectImage

The sample code for Arduino is shown as below. The communication is I2C.

Please refer to Setcion 8 in the wiki for more details about the wiring, installing arduino library and etc.

CODE
					#include "HUSKYLENS.h"
#include "SoftwareSerial.h"

HUSKYLENS huskylens;
//HUSKYLENS green line >> SDA; blue line >> SCL
void printResult(HUSKYLENSResult result);

void setup() {
    Serial.begin(115200);
    Wire.begin();
    while (!huskylens.begin(Wire))
    {
        Serial.println(F("Begin failed!"));
        Serial.println(F("1.Please recheck the \"Protocol Type\" in HUSKYLENS (General Settings>>Protocol Type>>I2C)"));
        Serial.println(F("2.Please recheck the connection."));
        delay(100);
    }
}

void loop() {
    if (!huskylens.request()) Serial.println(F("Fail to request data from HUSKYLENS, recheck the connection!"));
    else if(!huskylens.available()) Serial.println(F("No block or arrow appears on the screen!"));
    else
    {
        Serial.println(F("###########"));
        while (huskylens.available())
        {
            HUSKYLENSResult result = huskylens.read();
            printResult(result);
        }    
    }
}

void printResult(HUSKYLENSResult result){
    if (result.command == COMMAND_RETURN_BLOCK){
        if(result.ID == 1){
        Serial.println("Face with Mask");
        }
        else if(result.ID == 2){
        Serial.println("Just Face");  
        }
        else{
        Serial.println("Defualt");
        }
     }
    else{
        Serial.println("Object unknown!");
    }
}
				
Step5
Test

When a mask is recognized, the '√' will be displayed, which indicates passable. Otherwise, without a mask, the '×' wil be displayed, which means impassable. 

projectImage

Example 2: Rock Paper Scissors

Machine gestures learning can realize gesture recognition. It can be extended such as gesture digital recognition, sign language, sign recognition, and so on. 

projectImage

Example 3: Rubbish Classification 

Seemingly very advanced garbage classification function, through machine learning is very simple to achieve. And then connect the main control board control a few rudders can simulate the real garbage classification function. Since it can sort garbage, functions such as coin sorting, fruit sorting, canteen self-clearing and others can also be easily realized.

projectImage

Example 4: Number Recognition

 Whether it's a cartoon number, a handwritten number, or a capital number to an Arabic number, it's okay to play with HuskyLens.

projectImage

 Example 5: Position Recognition 

Although the classification of objects cannot return the coordinate values of objects, we can learn by placing objects in different locations, indirectly achieving position recognition. Using this function, you will find that it can also be used to do patrol lines, lines on the left or right, even intersections, T-junctions are recognizable, as well as intersection identification, analog traffic lights and so on can be simply and directly implemented. That's right, the driverless feature sits on easily! 

projectImage

Summary

All examples above are just to start further explorations. Applying the object classification function, we can implement many of the functions that we used to do only by relying on a computer camera on this small AI camera. With machine learning, the conceivable idea becomes very large, although it seems to have only one function, but can surpass the basic 6 functions. 

HuskyLens can learn, then as long as you want to let it recognize, just give him a look. Come to open your mind or idea, join us to train your HuskyLens, unlock more new plays, let it become more intelligent and powerful! 

License
1
All Rights
Reserved
[[i.text]]
licensBg
2
3
COMMENTS ([[commentTotla]])
[[c.user_name]] [[c.create_time]]
[[c.parent_comment.count]]
[[c.comment_content]]