Send the data of GR-PEACH_HVC-P2_sample to the cloud.

Dependencies:   AsciiFont GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP USBHost_custom easy-connect-gr-peach

Fork of mbed-os-example-client by mbed-os-examples

Note at the time of sample import

Please not check the "Update all libraries to the latest version" at the time of import.

Warning!

When exporting and using it, increase the following stack size.

mbed-os/features/FEATURE_LWIP/lwip-interface/lwipopts.h

#define TCPIP_THREAD_STACKSIZE      1024
->
#define TCPIP_THREAD_STACKSIZE      2048

Overview

This is a sample to send the analysis result of GR-PEACH_HVC-P2_sample to the cloud using mbed-client. Please refer to following for operation of HVC-P2.

Import programGR-PEACH_HVC-P2_sample

Sample to operate omron HVC-P2 on GR-PEACH.


Required hardware

Application setup

Client credentials

To register the application to mbed Device Connector, you need to create and set the client side certificate.

  1. Go to https://connector.mbed.com/ and log in with your mbed account
  2. On mbed Device Connector, go to https://connector.mbed.com/#credentials and click the Get my device security credentials button to get new credentials for your device.
  3. Replace the contents in security.h of this example with content copied above.

Ethernet settings

This sample uses Ethernet as the default connection type. To change the connection type, set WIFI_BP3595 in mbed_app.json:

mbed_app.json

"network-interface":{
    "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_BP3595",
    "value": "ETHERNET"
},


To specify MAC address, add fllowing function to main.cpp. (When using Wifi, setting of MAC address is not necessary.)

Specify MAC address

// set mac address
void mbed_mac_address(char *mac) {
    mac[0] = 0x00;
    mac[1] = 0x02;
    mac[2] = 0xF7;
    mac[3] = 0xF0;
    mac[4] = 0x00;
    mac[5] = 0x00;
}


Wifi settings

This example can use BP3595 Wifi Interface for managing the wireless connectivity. To run this example using Wifi, you need:

  1. A BP3595 Wifi module ( https://developer.mbed.org/components/BP3595-for-GR-PEACH/ )
  2. Mount BP3595 onto GR-PEACH
  3. Close GR-PEACH's JP21 (https://developer.mbed.org/teams/Renesas/wiki/Jumper-settings-of-GR-PEACH)
  4. In the mbed_app.json file, change

mbed_app.json

"network-interface":{
    "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_BP3595",
    "value": "WIFI_BP3595"
},


Provide your Wifi SSID and password here and leave \" in the beginning and end of your SSID and password as shown in the example below:

mbed_app.json

"wifi-ssid": {
    "help": "WiFi SSID",
    "value": "\"SSID\""
},
"wifi-password": {
    "help": "WIFI Password",
    "value": "\"Password\""
}


Specify the security type for connection to be used. When the security type is WPA2, you need to specify NSAPI_SECURITY_WAP as follows:

mbed_app.json

"wifi-security":{
    "help": "Options are NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2, NSAPI_SECURITY_WPA_WPA2",
    "value": "NSAPI_SECURITY_WEP"
},

By default, NSAPI_SECURITY_WPA_WPA2 is specified here.

Application resources

This example exposes four resources listed below:

  1. 3202/0/5700. Recognition result from HVC-P2 (GET).
  2. 3201/0/5850. Blink function, blinks LED when executed (POST).
  3. 3201/0/5853. Blink pattern, used by the blink function to determine how to blink. In the format of 1000:500:1000:500:1000:500 (PUT).
  4. 3201/0/5855. Blink color, used by the blink function. Any of red, green, blue, cyan, yellow and magenta is acceptable (PUT).

For more info on how to get notifications when resource 1 changes, or how to use resource 2, 3 and 4, please look at

Import programGR-PEACH_mbed-connector-ZXingSample-node

Node.js based Web Application for mbed Device Connector specific to GR-PEACH_mbed-os-client-ZXingSample

# This is a Web Application for GR-PEACH_mbed-os-client-ZXingSample, but it can also be used for this sample.

Committer:
dkato
Date:
Tue Mar 14 05:59:09 2017 +0000
Revision:
74:bf6d9bd511bd
Parent:
73:fbc0212c2eaf
Changed initial setting of mbed_app.json to ETHERNET.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 73:fbc0212c2eaf 1 /*---------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 2 /* Copyright(C) 2017 OMRON Corporation */
dkato 73:fbc0212c2eaf 3 /* */
dkato 73:fbc0212c2eaf 4 /* Licensed under the Apache License, Version 2.0 (the "License"); */
dkato 73:fbc0212c2eaf 5 /* you may not use this file except in compliance with the License. */
dkato 73:fbc0212c2eaf 6 /* You may obtain a copy of the License at */
dkato 73:fbc0212c2eaf 7 /* */
dkato 73:fbc0212c2eaf 8 /* http://www.apache.org/licenses/LICENSE-2.0 */
dkato 73:fbc0212c2eaf 9 /* */
dkato 73:fbc0212c2eaf 10 /* Unless required by applicable law or agreed to in writing, software */
dkato 73:fbc0212c2eaf 11 /* distributed under the License is distributed on an "AS IS" BASIS, */
dkato 73:fbc0212c2eaf 12 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
dkato 73:fbc0212c2eaf 13 /* See the License for the specific language governing permissions and */
dkato 73:fbc0212c2eaf 14 /* limitations under the License. */
dkato 73:fbc0212c2eaf 15 /*---------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 16
dkato 73:fbc0212c2eaf 17 #ifndef HVCDef_H__
dkato 73:fbc0212c2eaf 18 #define HVCDef_H__
dkato 73:fbc0212c2eaf 19
dkato 73:fbc0212c2eaf 20 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 21 /* Execution flag */
dkato 73:fbc0212c2eaf 22 #define HVC_ACTIV_BODY_DETECTION 0x00000001
dkato 73:fbc0212c2eaf 23 #define HVC_ACTIV_HAND_DETECTION 0x00000002
dkato 73:fbc0212c2eaf 24 #define HVC_ACTIV_FACE_DETECTION 0x00000004
dkato 73:fbc0212c2eaf 25 #define HVC_ACTIV_FACE_DIRECTION 0x00000008
dkato 73:fbc0212c2eaf 26 #define HVC_ACTIV_AGE_ESTIMATION 0x00000010
dkato 73:fbc0212c2eaf 27 #define HVC_ACTIV_GENDER_ESTIMATION 0x00000020
dkato 73:fbc0212c2eaf 28 #define HVC_ACTIV_GAZE_ESTIMATION 0x00000040
dkato 73:fbc0212c2eaf 29 #define HVC_ACTIV_BLINK_ESTIMATION 0x00000080
dkato 73:fbc0212c2eaf 30 #define HVC_ACTIV_EXPRESSION_ESTIMATION 0x00000100
dkato 73:fbc0212c2eaf 31 #define HVC_ACTIV_FACE_RECOGNITION 0x00000200
dkato 73:fbc0212c2eaf 32
dkato 73:fbc0212c2eaf 33 /* Image info of Execute command */
dkato 73:fbc0212c2eaf 34 #define HVC_EXECUTE_IMAGE_NONE 0x00000000
dkato 73:fbc0212c2eaf 35 #define HVC_EXECUTE_IMAGE_QVGA 0x00000001
dkato 73:fbc0212c2eaf 36 #define HVC_EXECUTE_IMAGE_QVGA_HALF 0x00000002
dkato 73:fbc0212c2eaf 37
dkato 73:fbc0212c2eaf 38 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 39 /* Error code */
dkato 73:fbc0212c2eaf 40
dkato 73:fbc0212c2eaf 41 /* Parameter error */
dkato 73:fbc0212c2eaf 42 #define HVC_ERROR_PARAMETER -1
dkato 73:fbc0212c2eaf 43
dkato 73:fbc0212c2eaf 44 /* Send signal timeout error */
dkato 73:fbc0212c2eaf 45 #define HVC_ERROR_SEND_DATA -10
dkato 73:fbc0212c2eaf 46
dkato 73:fbc0212c2eaf 47 /* Receive header signal timeout error */
dkato 73:fbc0212c2eaf 48 #define HVC_ERROR_HEADER_TIMEOUT -20
dkato 73:fbc0212c2eaf 49 /* Invalid header error */
dkato 73:fbc0212c2eaf 50 #define HVC_ERROR_HEADER_INVALID -21
dkato 73:fbc0212c2eaf 51 /* Receive data signal timeout error */
dkato 73:fbc0212c2eaf 52 #define HVC_ERROR_DATA_TIMEOUT -22
dkato 73:fbc0212c2eaf 53
dkato 73:fbc0212c2eaf 54
dkato 73:fbc0212c2eaf 55 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 56 /* Album data size */
dkato 73:fbc0212c2eaf 57 #define HVC_ALBUM_SIZE_MIN 32
dkato 73:fbc0212c2eaf 58 #define HVC_ALBUM_SIZE_MAX 816032
dkato 73:fbc0212c2eaf 59
dkato 73:fbc0212c2eaf 60 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 61 /* Expression */
dkato 73:fbc0212c2eaf 62 typedef enum {
dkato 73:fbc0212c2eaf 63 EX_NEUTRAL = 1,
dkato 73:fbc0212c2eaf 64 EX_HAPPINESS,
dkato 73:fbc0212c2eaf 65 EX_SURPRISE,
dkato 73:fbc0212c2eaf 66 EX_ANGER,
dkato 73:fbc0212c2eaf 67 EX_SADNESS
dkato 73:fbc0212c2eaf 68 }EXPRESSION;
dkato 73:fbc0212c2eaf 69
dkato 73:fbc0212c2eaf 70 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 71 /* Struct */
dkato 73:fbc0212c2eaf 72 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 73 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 74 /* Devicefs model and version info */
dkato 73:fbc0212c2eaf 75 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 76 typedef struct {
dkato 73:fbc0212c2eaf 77 UINT8 string[12];
dkato 73:fbc0212c2eaf 78 UINT8 major;
dkato 73:fbc0212c2eaf 79 UINT8 minor;
dkato 73:fbc0212c2eaf 80 UINT8 relese;
dkato 73:fbc0212c2eaf 81 UINT8 revision[4];
dkato 73:fbc0212c2eaf 82 }HVC_VERSION;
dkato 73:fbc0212c2eaf 83
dkato 73:fbc0212c2eaf 84 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 85 /* Detection result */
dkato 73:fbc0212c2eaf 86 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 87 typedef struct{
dkato 73:fbc0212c2eaf 88 INT32 posX; /* Center x-coordinate */
dkato 73:fbc0212c2eaf 89 INT32 posY; /* Center y-coordinate */
dkato 73:fbc0212c2eaf 90 INT32 size; /* Size */
dkato 73:fbc0212c2eaf 91 INT32 confidence; /* Degree of confidence */
dkato 73:fbc0212c2eaf 92 }DETECT_RESULT;
dkato 73:fbc0212c2eaf 93
dkato 73:fbc0212c2eaf 94 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 95 /* Face direction */
dkato 73:fbc0212c2eaf 96 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 97 typedef struct{
dkato 73:fbc0212c2eaf 98 INT32 yaw; /* Yaw angle */
dkato 73:fbc0212c2eaf 99 INT32 pitch; /* Pitch angle */
dkato 73:fbc0212c2eaf 100 INT32 roll; /* Roll angle */
dkato 73:fbc0212c2eaf 101 INT32 confidence; /* Degree of confidence */
dkato 73:fbc0212c2eaf 102 }DIR_RESULT;
dkato 73:fbc0212c2eaf 103
dkato 73:fbc0212c2eaf 104 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 105 /* Age */
dkato 73:fbc0212c2eaf 106 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 107 typedef struct{
dkato 73:fbc0212c2eaf 108 INT32 age; /* Age */
dkato 73:fbc0212c2eaf 109 INT32 confidence; /* Degree of confidence */
dkato 73:fbc0212c2eaf 110 }AGE_RESULT;
dkato 73:fbc0212c2eaf 111
dkato 73:fbc0212c2eaf 112 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 113 /* Gender */
dkato 73:fbc0212c2eaf 114 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 115 typedef struct{
dkato 73:fbc0212c2eaf 116 INT32 gender; /* Gender */
dkato 73:fbc0212c2eaf 117 INT32 confidence; /* Degree of confidence */
dkato 73:fbc0212c2eaf 118 }GENDER_RESULT;
dkato 73:fbc0212c2eaf 119
dkato 73:fbc0212c2eaf 120 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 121 /* Gaze */
dkato 73:fbc0212c2eaf 122 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 123 typedef struct{
dkato 73:fbc0212c2eaf 124 INT32 gazeLR; /* Yaw angle */
dkato 73:fbc0212c2eaf 125 INT32 gazeUD; /* Pitch angle */
dkato 73:fbc0212c2eaf 126 }GAZE_RESULT;
dkato 73:fbc0212c2eaf 127
dkato 73:fbc0212c2eaf 128 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 129 /* Blink */
dkato 73:fbc0212c2eaf 130 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 131 typedef struct{
dkato 73:fbc0212c2eaf 132 INT32 ratioL; /* Left eye blink result */
dkato 73:fbc0212c2eaf 133 INT32 ratioR; /* Right eye blink result */
dkato 73:fbc0212c2eaf 134 }BLINK_RESULT;
dkato 73:fbc0212c2eaf 135
dkato 73:fbc0212c2eaf 136 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 137 /* Expression */
dkato 73:fbc0212c2eaf 138 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 139 typedef struct{
dkato 73:fbc0212c2eaf 140 INT32 topExpression; /* Top expression */
dkato 73:fbc0212c2eaf 141 INT32 topScore; /* Top score */
dkato 73:fbc0212c2eaf 142 INT32 score[5]; /* Score of 5 expression */
dkato 73:fbc0212c2eaf 143 INT32 degree; /* Negative-positive degree */
dkato 73:fbc0212c2eaf 144 }EXPRESSION_RESULT;
dkato 73:fbc0212c2eaf 145
dkato 73:fbc0212c2eaf 146 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 147 /* Face Recognition */
dkato 73:fbc0212c2eaf 148 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 149 typedef struct{
dkato 73:fbc0212c2eaf 150 INT32 uid; /* User ID */
dkato 73:fbc0212c2eaf 151 INT32 confidence; /* Degree of confidence */
dkato 73:fbc0212c2eaf 152 }RECOGNITION_RESULT;
dkato 73:fbc0212c2eaf 153
dkato 73:fbc0212c2eaf 154 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 155 /* Face Detection & Estimations result */
dkato 73:fbc0212c2eaf 156 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 157 typedef struct{
dkato 73:fbc0212c2eaf 158 DETECT_RESULT dtResult; /* Face detection result */
dkato 73:fbc0212c2eaf 159 DIR_RESULT dirResult; /* Face direction estimation result */
dkato 73:fbc0212c2eaf 160 AGE_RESULT ageResult; /* Age Estimation result */
dkato 73:fbc0212c2eaf 161 GENDER_RESULT genderResult; /* Gender Estimation result */
dkato 73:fbc0212c2eaf 162 GAZE_RESULT gazeResult; /* Gaze Estimation result */
dkato 73:fbc0212c2eaf 163 BLINK_RESULT blinkResult; /* Blink Estimation result */
dkato 73:fbc0212c2eaf 164 EXPRESSION_RESULT expressionResult; /* Expression Estimation result */
dkato 73:fbc0212c2eaf 165 RECOGNITION_RESULT recognitionResult; /* Face Recognition result */
dkato 73:fbc0212c2eaf 166 }FACE_RESULT;
dkato 73:fbc0212c2eaf 167
dkato 73:fbc0212c2eaf 168 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 169 /* Human Body Detection results */
dkato 73:fbc0212c2eaf 170 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 171 typedef struct{
dkato 73:fbc0212c2eaf 172 UINT8 num; /* Number of Detection */
dkato 73:fbc0212c2eaf 173 DETECT_RESULT bdResult[35]; /* Detection result */
dkato 73:fbc0212c2eaf 174 }BD_RESULT;
dkato 73:fbc0212c2eaf 175
dkato 73:fbc0212c2eaf 176 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 177 /* Hand Detection results */
dkato 73:fbc0212c2eaf 178 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 179 typedef struct{
dkato 73:fbc0212c2eaf 180 UINT8 num; /* Number of Detection */
dkato 73:fbc0212c2eaf 181 DETECT_RESULT hdResult[35]; /* Detection result */
dkato 73:fbc0212c2eaf 182 }HD_RESULT;
dkato 73:fbc0212c2eaf 183
dkato 73:fbc0212c2eaf 184 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 185 /* Face Detection & Estimations results */
dkato 73:fbc0212c2eaf 186 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 187 typedef struct{
dkato 73:fbc0212c2eaf 188 UINT8 num; /* Number of Detection */
dkato 73:fbc0212c2eaf 189 FACE_RESULT fcResult[35]; /* Detection & Estimations result */
dkato 73:fbc0212c2eaf 190 }FD_RESULT;
dkato 73:fbc0212c2eaf 191
dkato 73:fbc0212c2eaf 192 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 193 /* Image data */
dkato 73:fbc0212c2eaf 194 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 195 typedef struct{
dkato 73:fbc0212c2eaf 196 INT32 width;
dkato 73:fbc0212c2eaf 197 INT32 height;
dkato 73:fbc0212c2eaf 198 UINT8 image[320*240];
dkato 73:fbc0212c2eaf 199 }HVC_IMAGE;
dkato 73:fbc0212c2eaf 200
dkato 73:fbc0212c2eaf 201 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 202 /* Eesult data of Execute command */
dkato 73:fbc0212c2eaf 203 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 204 typedef struct{
dkato 73:fbc0212c2eaf 205 INT32 executedFunc; /* Execution flag */
dkato 73:fbc0212c2eaf 206 BD_RESULT bdResult; /* Human Body Detection results */
dkato 73:fbc0212c2eaf 207 HD_RESULT hdResult; /* Hand Detection results */
dkato 73:fbc0212c2eaf 208 FD_RESULT fdResult; /* Face Detection & Estimations results */
dkato 73:fbc0212c2eaf 209 HVC_IMAGE image; /* Image data */
dkato 73:fbc0212c2eaf 210 }HVC_RESULT;
dkato 73:fbc0212c2eaf 211
dkato 73:fbc0212c2eaf 212 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 213 /* Threshold of confidence */
dkato 73:fbc0212c2eaf 214 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 215 typedef struct{
dkato 73:fbc0212c2eaf 216 INT32 bdThreshold; /* Threshold of confidence of Human Body Detection */
dkato 73:fbc0212c2eaf 217 INT32 hdThreshold; /* Threshold of confidence of Hand Detection */
dkato 73:fbc0212c2eaf 218 INT32 dtThreshold; /* Threshold of confidence of Face Detection */
dkato 73:fbc0212c2eaf 219 INT32 rsThreshold; /* Threshold of confidence of Face Recognition */
dkato 73:fbc0212c2eaf 220 }HVC_THRESHOLD;
dkato 73:fbc0212c2eaf 221
dkato 73:fbc0212c2eaf 222 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 223 /* Detection size */
dkato 73:fbc0212c2eaf 224 /*----------------------------------------------------------------------------*/
dkato 73:fbc0212c2eaf 225 typedef struct{
dkato 73:fbc0212c2eaf 226 INT32 bdMinSize; /* Minimum detection size of Human Body Detection */
dkato 73:fbc0212c2eaf 227 INT32 bdMaxSize; /* Maximum detection size of Human Body Detection */
dkato 73:fbc0212c2eaf 228 INT32 hdMinSize; /* Minimum detection size of Hand Detection */
dkato 73:fbc0212c2eaf 229 INT32 hdMaxSize; /* Maximum detection size of Hand Detection */
dkato 73:fbc0212c2eaf 230 INT32 dtMinSize; /* Minimum detection size of Face Detection */
dkato 73:fbc0212c2eaf 231 INT32 dtMaxSize; /* Maximum detection size of Face Detection */
dkato 73:fbc0212c2eaf 232 }HVC_SIZERANGE;
dkato 73:fbc0212c2eaf 233
dkato 73:fbc0212c2eaf 234 #endif /* HVCDef_H__ */