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

Dependencies:   AsciiFont

Information

Please see here for Japanese version.
日本語版はこちらを参照ください。

What is this ?

This is a sample that runs OMRON HVC-P2 with GR-PEACH. In this sample, you can try following among the functions of HVC-P2 : Human Body Detection, Face Detection, Age Estimation, Gender Estimation, Expression Estimation and Face Recognition.
Both GR-PEACH and HVC-P2 use Renesas RZ/A1H included ARM® Cortex™-A9 processor.

/media/uploads/dkato/hvcp2_demo_img3.jpg

HVC-P2 (Human Vision Components B5T-007001) is a human-sensing component that recognizes people. It is an integrated module that is built into other device and provides both the OKAO Vision's ten types of image sensing and a camera module.
For details, please refer to the following link.

In the HVCApi folder of this sample, the code of the following link destination Sample Code "SampleCode_rev.2.0.2" is used. (You can download from "Product Information" -> "Sample Code" in the middle of the following page.)
http://www.omron.com/ecb/products/mobile/hvc_p2/

Constitution

  1. HVC-P2 x 1
  2. USBA-microUSB conversion cable x 2
  3. USBA-microUSB conversion adapter x 1
  4. GR-PEACH x 1
  5. 4.3inc LCD shield x 1

/media/uploads/dkato/composition_hvcp2_demo.jpg

/media/uploads/dkato/composition_hvcp2_demo_2.jpg

Please close JP3 of GR-PEACH.
/media/uploads/RyoheiHagimoto/usb.jpg

How to use

It starts when connecting the power supply USB cable. At startup, all functions are turned off. By pressing the button on the right of the screen you can switch the function on / off.

  • Function ON : orange or green
  • Function OFF : blue or gray

Only the FACE button changes to "FACE (blue) -> FACE (orange) -> RECOGNITION (green)". When FACE (blue), following buttons are gray and can not be operated : AGE, GENDER and EXPRESSION.
"Response time" at the bottom left of the screen indicates "image processing + USB transfer time". It is not pure image processing time.

Register Data (Face Recognition)

Set the FACE button to RECOGNITION (green), and touch the screen with one person on the screen to register the face. In this sample, face registration will record up to 10 people. Delete the old registrant when registering after 11 people. Registration information is stored in the RAM on the HVC-P2 side. It is discarded by power off and reset.

/media/uploads/dkato/hvcp2_demo_img2.jpg

Change parameters

When you press Config icon at the bottom right of the screen, the parameter setting screen is displayed. You can change threshold value, detection size and face angle parameters.

/media/uploads/dkato/hvcp2_demo_config_icon.jpg
/media/uploads/dkato/hvcp2_demo_config.jpg

Change transfer image size

By pressing USER_BUTTON0 on the back of the board, the image transfer size switches in the order of "160 x 120 -> 320 x 240 -> no image".
/media/uploads/dkato/gr-peach_switch2.jpg

Committer:
dkato
Date:
Fri Sep 28 05:16:44 2018 +0000
Revision:
8:92c19be0aced
Parent:
5:49a61433290a
Supports mbed-os-5.10

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 5:49a61433290a 1 /*---------------------------------------------------------------------------*/
dkato 5:49a61433290a 2 /* Copyright(C) 2017 OMRON Corporation */
dkato 5:49a61433290a 3 /* */
dkato 5:49a61433290a 4 /* Licensed under the Apache License, Version 2.0 (the "License"); */
dkato 5:49a61433290a 5 /* you may not use this file except in compliance with the License. */
dkato 5:49a61433290a 6 /* You may obtain a copy of the License at */
dkato 5:49a61433290a 7 /* */
dkato 5:49a61433290a 8 /* http://www.apache.org/licenses/LICENSE-2.0 */
dkato 5:49a61433290a 9 /* */
dkato 5:49a61433290a 10 /* Unless required by applicable law or agreed to in writing, software */
dkato 5:49a61433290a 11 /* distributed under the License is distributed on an "AS IS" BASIS, */
dkato 5:49a61433290a 12 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
dkato 5:49a61433290a 13 /* See the License for the specific language governing permissions and */
dkato 5:49a61433290a 14 /* limitations under the License. */
dkato 5:49a61433290a 15 /*---------------------------------------------------------------------------*/
dkato 5:49a61433290a 16
dkato 5:49a61433290a 17 /*
dkato 5:49a61433290a 18 STB Sample API
dkato 5:49a61433290a 19 */
dkato 5:49a61433290a 20
dkato 5:49a61433290a 21 #include <stdlib.h>
dkato 5:49a61433290a 22 #include "STBWrap.h"
dkato 5:49a61433290a 23
dkato 5:49a61433290a 24 #pragma comment(lib, "STB.lib")
dkato 5:49a61433290a 25
dkato 5:49a61433290a 26 #define STB_MAX_NUM 35
dkato 5:49a61433290a 27
dkato 5:49a61433290a 28 static HSTB m_Handle;
dkato 5:49a61433290a 29 static int m_nFaceCount;
dkato 5:49a61433290a 30 static STB_FACE m_Face[STB_MAX_NUM];
dkato 5:49a61433290a 31 static int m_nBodyCount;
dkato 5:49a61433290a 32 static STB_BODY m_Body[STB_MAX_NUM];
dkato 5:49a61433290a 33
dkato 5:49a61433290a 34
dkato 5:49a61433290a 35 int STB_Init(int inFuncFlag)
dkato 5:49a61433290a 36 {
dkato 5:49a61433290a 37 if(NULL != m_Handle){
dkato 5:49a61433290a 38 STB_DeleteHandle(m_Handle);
dkato 5:49a61433290a 39 m_Handle = NULL;
dkato 5:49a61433290a 40 }
dkato 5:49a61433290a 41
dkato 5:49a61433290a 42 m_Handle = STB_CreateHandle(inFuncFlag);
dkato 5:49a61433290a 43 if(NULL == m_Handle){
dkato 5:49a61433290a 44 return STB_ERR_INITIALIZE;
dkato 5:49a61433290a 45 }
dkato 5:49a61433290a 46 return STB_NORMAL;
dkato 5:49a61433290a 47 }
dkato 5:49a61433290a 48
dkato 5:49a61433290a 49 void STB_Final(void)
dkato 5:49a61433290a 50 {
dkato 5:49a61433290a 51 if(NULL != m_Handle){
dkato 5:49a61433290a 52 STB_DeleteHandle(m_Handle);
dkato 5:49a61433290a 53 m_Handle = NULL;
dkato 5:49a61433290a 54 }
dkato 5:49a61433290a 55 }
dkato 5:49a61433290a 56
dkato 5:49a61433290a 57 int STB_Exec(int inActiveFunc, const HVC_RESULT *inResult, int *pnSTBFaceCount, STB_FACE **pSTBFaceResult, int *pnSTBBodyCount, STB_BODY **pSTBBodyResult)
dkato 5:49a61433290a 58 {
dkato 5:49a61433290a 59 int ret;
dkato 5:49a61433290a 60 STB_FRAME_RESULT frameRes;
dkato 5:49a61433290a 61
dkato 5:49a61433290a 62 m_nFaceCount = 0;
dkato 5:49a61433290a 63 m_nBodyCount = 0;
dkato 5:49a61433290a 64 GetFrameResult(inActiveFunc, inResult, &frameRes);
dkato 5:49a61433290a 65 do{
dkato 5:49a61433290a 66 // Set frame information (Detection Result)
dkato 5:49a61433290a 67 ret = STB_SetFrameResult(m_Handle, &frameRes);
dkato 5:49a61433290a 68 if(STB_NORMAL != ret){
dkato 5:49a61433290a 69 break;
dkato 5:49a61433290a 70 }
dkato 5:49a61433290a 71
dkato 5:49a61433290a 72 // STB Execution
dkato 5:49a61433290a 73 ret = STB_Execute(m_Handle);
dkato 5:49a61433290a 74 if(STB_NORMAL != ret){
dkato 5:49a61433290a 75 break;
dkato 5:49a61433290a 76 }
dkato 5:49a61433290a 77
dkato 5:49a61433290a 78 // Get STB Result
dkato 5:49a61433290a 79 ret = STB_GetFaces(m_Handle, (STB_UINT32 *)&m_nFaceCount, m_Face);
dkato 5:49a61433290a 80 if(STB_NORMAL != ret){
dkato 5:49a61433290a 81 break;
dkato 5:49a61433290a 82 }
dkato 5:49a61433290a 83
dkato 5:49a61433290a 84 ret = STB_GetBodies(m_Handle, (STB_UINT32 *)&m_nBodyCount, m_Body);
dkato 5:49a61433290a 85 if(STB_NORMAL != ret){
dkato 5:49a61433290a 86 break;
dkato 5:49a61433290a 87 }
dkato 5:49a61433290a 88 }while(0);
dkato 5:49a61433290a 89
dkato 5:49a61433290a 90 *pnSTBFaceCount = m_nFaceCount;
dkato 5:49a61433290a 91 *pSTBFaceResult = m_Face;
dkato 5:49a61433290a 92 *pnSTBBodyCount = m_nBodyCount;
dkato 5:49a61433290a 93 *pSTBBodyResult = m_Body;
dkato 5:49a61433290a 94 return ret;
dkato 5:49a61433290a 95 }
dkato 5:49a61433290a 96
dkato 5:49a61433290a 97 int STB_Clear(void)
dkato 5:49a61433290a 98 {
dkato 5:49a61433290a 99 return STB_ClearFrameResults(m_Handle);
dkato 5:49a61433290a 100 }
dkato 5:49a61433290a 101
dkato 5:49a61433290a 102 int STB_SetTrParam(int inRetryCount, int inStbPosParam, int inStbSizeParam)
dkato 5:49a61433290a 103 {
dkato 5:49a61433290a 104 int ret;
dkato 5:49a61433290a 105 do{
dkato 5:49a61433290a 106 ret = STB_SetTrRetryCount(m_Handle, inRetryCount);
dkato 5:49a61433290a 107 if(STB_NORMAL != ret){
dkato 5:49a61433290a 108 break;
dkato 5:49a61433290a 109 }
dkato 5:49a61433290a 110
dkato 5:49a61433290a 111 ret = STB_SetTrSteadinessParam(m_Handle, inStbPosParam, inStbSizeParam);
dkato 5:49a61433290a 112 }while(0);
dkato 5:49a61433290a 113
dkato 5:49a61433290a 114 return ret;
dkato 5:49a61433290a 115 }
dkato 5:49a61433290a 116
dkato 5:49a61433290a 117 int STB_SetPeParam(int inThreshold, int inUDAngleMin, int inUDAngleMax, int inLRAngleMin, int inLRAngleMax, int inCompCount)
dkato 5:49a61433290a 118 {
dkato 5:49a61433290a 119 int ret;
dkato 5:49a61433290a 120 do{
dkato 5:49a61433290a 121 ret = STB_SetPeThresholdUse(m_Handle, inThreshold);
dkato 5:49a61433290a 122 if(STB_NORMAL != ret){
dkato 5:49a61433290a 123 break;
dkato 5:49a61433290a 124 }
dkato 5:49a61433290a 125
dkato 5:49a61433290a 126 ret = STB_SetPeAngleUse(m_Handle, inUDAngleMin, inUDAngleMax, inLRAngleMin, inLRAngleMax);
dkato 5:49a61433290a 127 if(STB_NORMAL != ret){
dkato 5:49a61433290a 128 break;
dkato 5:49a61433290a 129 }
dkato 5:49a61433290a 130
dkato 5:49a61433290a 131 ret = STB_SetPeCompleteFrameCount(m_Handle, inCompCount);
dkato 5:49a61433290a 132 }while(0);
dkato 5:49a61433290a 133
dkato 5:49a61433290a 134 return ret;
dkato 5:49a61433290a 135 }
dkato 5:49a61433290a 136
dkato 5:49a61433290a 137 int STB_SetFrParam(int inThreshold, int inUDAngleMin, int inUDAngleMax, int inLRAngleMin, int inLRAngleMax, int inCompCount, int inRatio)
dkato 5:49a61433290a 138 {
dkato 5:49a61433290a 139 int ret;
dkato 5:49a61433290a 140 do{
dkato 5:49a61433290a 141 ret = STB_SetFrThresholdUse(m_Handle, inThreshold);
dkato 5:49a61433290a 142 if(STB_NORMAL != ret){
dkato 5:49a61433290a 143 break;
dkato 5:49a61433290a 144 }
dkato 5:49a61433290a 145
dkato 5:49a61433290a 146 ret = STB_SetFrAngleUse(m_Handle, inUDAngleMin, inUDAngleMax, inLRAngleMin, inLRAngleMax);
dkato 5:49a61433290a 147 if(STB_NORMAL != ret){
dkato 5:49a61433290a 148 break;
dkato 5:49a61433290a 149 }
dkato 5:49a61433290a 150
dkato 5:49a61433290a 151 ret = STB_SetFrCompleteFrameCount(m_Handle, inCompCount);
dkato 5:49a61433290a 152 if(STB_NORMAL != ret){
dkato 5:49a61433290a 153 break;
dkato 5:49a61433290a 154 }
dkato 5:49a61433290a 155
dkato 5:49a61433290a 156 ret = STB_SetFrMinRatio(m_Handle, inRatio);
dkato 5:49a61433290a 157 }while(0);
dkato 5:49a61433290a 158
dkato 5:49a61433290a 159 return ret;
dkato 5:49a61433290a 160 }
dkato 5:49a61433290a 161
dkato 5:49a61433290a 162
dkato 5:49a61433290a 163
dkato 5:49a61433290a 164 static void GetFrameResult(int inActiveFunc, const HVC_RESULT *inResult, STB_FRAME_RESULT *outFrameResult)
dkato 5:49a61433290a 165 {
dkato 5:49a61433290a 166 int i;
dkato 5:49a61433290a 167
dkato 5:49a61433290a 168 // Body Detection
dkato 5:49a61433290a 169 outFrameResult->bodys.nCount = inResult->bdResult.num;
dkato 5:49a61433290a 170 if(inActiveFunc & HVC_ACTIV_BODY_DETECTION){
dkato 5:49a61433290a 171 for(i = 0; i < inResult->bdResult.num; i++){
dkato 5:49a61433290a 172 DETECT_RESULT dtRes = inResult->bdResult.bdResult[i];
dkato 5:49a61433290a 173 outFrameResult->bodys.body[i].center.nX = dtRes.posX;
dkato 5:49a61433290a 174 outFrameResult->bodys.body[i].center.nY = dtRes.posY;
dkato 5:49a61433290a 175 outFrameResult->bodys.body[i].nSize = dtRes.size;
dkato 5:49a61433290a 176 outFrameResult->bodys.body[i].nConfidence = dtRes.confidence;
dkato 5:49a61433290a 177 }
dkato 5:49a61433290a 178 }
dkato 5:49a61433290a 179
dkato 5:49a61433290a 180 outFrameResult->faces.nCount = inResult->fdResult.num;
dkato 5:49a61433290a 181 for(i = 0; i < inResult->fdResult.num; i++){
dkato 5:49a61433290a 182 // Face Detection
dkato 5:49a61433290a 183 if(inActiveFunc & HVC_ACTIV_FACE_DETECTION){
dkato 5:49a61433290a 184 DETECT_RESULT dtRes = inResult->fdResult.fcResult[i].dtResult;
dkato 5:49a61433290a 185 outFrameResult->faces.face[i].center.nX = dtRes.posX;
dkato 5:49a61433290a 186 outFrameResult->faces.face[i].center.nY = dtRes.posY;
dkato 5:49a61433290a 187 outFrameResult->faces.face[i].nSize = dtRes.size;
dkato 5:49a61433290a 188 outFrameResult->faces.face[i].nConfidence = dtRes.confidence;
dkato 5:49a61433290a 189 }
dkato 5:49a61433290a 190
dkato 5:49a61433290a 191 // Face Direction
dkato 5:49a61433290a 192 if(inActiveFunc & HVC_ACTIV_FACE_DIRECTION){
dkato 5:49a61433290a 193 DIR_RESULT dirRes = inResult->fdResult.fcResult[i].dirResult;
dkato 5:49a61433290a 194 outFrameResult->faces.face[i].direction.nUD = dirRes.pitch;
dkato 5:49a61433290a 195 outFrameResult->faces.face[i].direction.nLR = dirRes.yaw;
dkato 5:49a61433290a 196 outFrameResult->faces.face[i].direction.nRoll = dirRes.roll;
dkato 5:49a61433290a 197 outFrameResult->faces.face[i].direction.nConfidence = dirRes.confidence;
dkato 5:49a61433290a 198 } else {
dkato 5:49a61433290a 199 outFrameResult->faces.face[i].direction.nUD = 0;
dkato 5:49a61433290a 200 outFrameResult->faces.face[i].direction.nLR = 0;
dkato 5:49a61433290a 201 outFrameResult->faces.face[i].direction.nRoll = 0;
dkato 5:49a61433290a 202 outFrameResult->faces.face[i].direction.nConfidence = 0;
dkato 5:49a61433290a 203 }
dkato 5:49a61433290a 204
dkato 5:49a61433290a 205 // Age
dkato 5:49a61433290a 206 if(inActiveFunc & HVC_ACTIV_AGE_ESTIMATION){
dkato 5:49a61433290a 207 AGE_RESULT ageRes = inResult->fdResult.fcResult[i].ageResult;
dkato 5:49a61433290a 208 outFrameResult->faces.face[i].age.nAge = ageRes.age;
dkato 5:49a61433290a 209 outFrameResult->faces.face[i].age.nConfidence = ageRes.confidence;
dkato 5:49a61433290a 210 } else {
dkato 5:49a61433290a 211 outFrameResult->faces.face[i].age.nAge = -128;
dkato 5:49a61433290a 212 outFrameResult->faces.face[i].age.nConfidence = -128;
dkato 5:49a61433290a 213 }
dkato 5:49a61433290a 214
dkato 5:49a61433290a 215 // Gender
dkato 5:49a61433290a 216 if(inActiveFunc & HVC_ACTIV_GENDER_ESTIMATION){
dkato 5:49a61433290a 217 GENDER_RESULT genderRes = inResult->fdResult.fcResult[i].genderResult;
dkato 5:49a61433290a 218 outFrameResult->faces.face[i].gender.nGender = genderRes.gender;
dkato 5:49a61433290a 219 outFrameResult->faces.face[i].gender.nConfidence = genderRes.confidence;
dkato 5:49a61433290a 220 } else {
dkato 5:49a61433290a 221 outFrameResult->faces.face[i].gender.nGender = -128;
dkato 5:49a61433290a 222 outFrameResult->faces.face[i].gender.nConfidence = -128;
dkato 5:49a61433290a 223 }
dkato 5:49a61433290a 224
dkato 5:49a61433290a 225 // ”FØ
dkato 5:49a61433290a 226 if(inActiveFunc & HVC_ACTIV_FACE_RECOGNITION){
dkato 5:49a61433290a 227 RECOGNITION_RESULT recogRes = inResult->fdResult.fcResult[i].recognitionResult;
dkato 5:49a61433290a 228 outFrameResult->faces.face[i].recognition.nUID = recogRes.uid;
dkato 5:49a61433290a 229 outFrameResult->faces.face[i].recognition.nScore = recogRes.confidence;
dkato 5:49a61433290a 230 } else {
dkato 5:49a61433290a 231 outFrameResult->faces.face[i].recognition.nUID = -128;
dkato 5:49a61433290a 232 outFrameResult->faces.face[i].recognition.nScore = -128;
dkato 5:49a61433290a 233 }
dkato 5:49a61433290a 234 }
dkato 5:49a61433290a 235 }
dkato 5:49a61433290a 236