SensiML Analytics Studioによる機械学習」で機械学習した動作認識モデルをQuickLogic Featherに組み込み、Quickfeather development kit上のaccelerometerを平行移動・上下移動をさせて、動作の認識ができることを確認します。

  1. 「SensiML Analytics Studioによる機械学習」でダウンロードした動作認識モデルのフォルダ「knowledgepack_project」を「Quickfeather Simple Streaming Interface AI Application Project」のフォルダ「qf_ssi_ai_app\knowledgepack」の内容と置き換えます。
  2. 次のマクロで認識モードに変更します。
  3. sensor_ssss.h

            …
    /* Settings for the sensor processing modes, Enable only one of these mode */
    #define SENSOR_SSSS_RECOG_ENABLED      1    /* Enable SensiML recognition */
    #define SENSOR_SSSS_LIVESTREAM_ENABLED 0    /* Enable live-streaming for data collection */
            …
    
  4. 次のようにプログラムを変更し、認識した動作に従って、停止は「緑」、上下は「青」、水平移動は「赤」でLEDを点灯させます。
  5. sml_output.c

             …
       kb_get_feature_vector(model, sensor_ssss_ai_fv_arr, &sensor_ssss_ai_fv_len);
    	
    	//**tomo
    	switch((int)classification){
    	  case 1:
        	HAL_GPIO_Write(GPIO_5, 0); //green LED
            HAL_GPIO_Write(GPIO_4, 0); //blue LED
        	HAL_GPIO_Write(GPIO_6, 1); //red LED
    	    break;
    	  case 2:
        	HAL_GPIO_Write(GPIO_6, 0); //red LED
            HAL_GPIO_Write(GPIO_4, 0); //blue LED
        	HAL_GPIO_Write(GPIO_5, 1); //green LED
    	    break;
    	  case 3:
        	HAL_GPIO_Write(GPIO_5, 0); //green LED
        	HAL_GPIO_Write(GPIO_6, 0); //red LED
            HAL_GPIO_Write(GPIO_4, 1); //blue LED
    	    break;
    	  default:
    	    break;
    	}
    	
        count = snprintf(sensor_ssss_ai_result_buf, buflen,
            …
    
  6. 変更したプログラムをコンパイルして実行すると、つぎのメッセージがシリアル端末に表示されます。「”Classification”:」に認識した動作のID番号が表示され、対応する色のLEDが表示されます。
  7.                                             {"ModelNumber":0,"Classification":2,"FeatureLength":2,"FeatureVector":[101,1]}
         {"ModelNumber":0,"Classification":2,"FeatureLength":2,"FeatureVector":[107,1]}
                                                                                       {"ModelNumber":0,"Classification":1,"FeatureLength":2,"FeatureVector":[165,2]}
                                                {"ModelNumber":0,"Classification":1,"FeatureLength":2,"FeatureVector":[135,1]}
         {"ModelNumber":0,"Classification":2,"FeatureLength":2,"FeatureVector":[118,2]}
                                                                                       {"ModelNumber":0,"Classification":2,"FeatureLength":2,"FeatureVector":[105,2]}
                                                {"ModelNumber":0,"Classification":1,"FeatureLength":2,"FeatureVector":[145,0]}
         {"ModelNumber":0,"Classification":1,"FeatureLength":2,"FeatureVector":[172,4]}
                                                                                       {"ModelNumber":0,"Classification":2,"FeatureLength":2,"FeatureVector":[123,1]}
                                                {"ModelNumber":0,"Classification":1,"FeatureLength":2,"FeatureVector":[169,3]}
         {"ModelNumber":0,"Classification":1,"FeatureLength":2,"FeatureVector":[148,2]}
                                                                                       {"ModelNumber":0,"Classification":2,"FeatureLength":2,"FeatureVector":[65,0]}
                                               {"ModelNumber":0,"Classification":2,"FeatureLength":2,"FeatureVector":[5,2]}
      {"ModelNumber":0,"Classification":2,"FeatureLength":2,"FeatureVector":[75,7]}
                                                                                   {"ModelNumber":0,"Classification":3,"FeatureLength":2,"FeatureVector":[137,77]}
                                             {"ModelNumber":0,"Classification":3,"FeatureLength":2,"FeatureVector":[152,146]}
        {"ModelNumber":0,"Classification":3,"FeatureLength":2,"FeatureVector":[87,177]}
                                                                                       {"ModelNumber":0,"Classification":3,"FeatureLength":2,"FeatureVector":[38,125]}
                                                 {"ModelNumber":0,"Classification":3,"FeatureLength":2,"FeatureVector":[83,88]}
          {"ModelNumber":0,"Classification":3,"FeatureLength":2,"FeatureVector":[163,105]}
                                                                                          {"ModelNumber":0,"Classification":2,"FeatureLength":2,"FeatureVector":[41,6]}
                                                  {"ModelNumber":0,"Classification":2,"FeatureLength":2,"FeatureVector":[1,1