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:
Tue Sep 05 10:01:51 2017 +0000
Revision:
5:49a61433290a
Add HVC sensing result stabilizing library

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 #include "FrInterface.h"
dkato 5:49a61433290a 18 #include "STBFrAPI.h"
dkato 5:49a61433290a 19
dkato 5:49a61433290a 20 /*Value range check*/
dkato 5:49a61433290a 21 #define ISVALID_RANGE( val , min , max ) ( ( (min) <= (val) ) && ( (val) <= (max) ) )
dkato 5:49a61433290a 22
dkato 5:49a61433290a 23 /*---------------------------------------------------------------------
dkato 5:49a61433290a 24 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 25 /*error check*/
dkato 5:49a61433290a 26 /*---------------------------------------------------------------------
dkato 5:49a61433290a 27 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 28 static STB_INT32 FrIsValidValue(
dkato 5:49a61433290a 29 const STB_INT32 nValue ,
dkato 5:49a61433290a 30 const STB_INT32 nLimitMin ,
dkato 5:49a61433290a 31 const STB_INT32 nLimitMax )
dkato 5:49a61433290a 32 {
dkato 5:49a61433290a 33 STB_INT32 nRet;
dkato 5:49a61433290a 34 for( nRet = STB_ERR_INVALIDPARAM; nRet != STB_NORMAL; nRet = STB_NORMAL ){
dkato 5:49a61433290a 35 if( ! ISVALID_RANGE( nValue , nLimitMin , nLimitMax ) ){ break; }
dkato 5:49a61433290a 36 }
dkato 5:49a61433290a 37 return nRet;
dkato 5:49a61433290a 38 }
dkato 5:49a61433290a 39 /*---------------------------------------------------------------------
dkato 5:49a61433290a 40 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 41 static STB_INT32 FrIsValidPointer( const VOID* pPointer )
dkato 5:49a61433290a 42 {
dkato 5:49a61433290a 43 STB_INT32 nRet;
dkato 5:49a61433290a 44 for( nRet = STB_ERR_INVALIDPARAM; nRet != STB_NORMAL; nRet = STB_NORMAL ){
dkato 5:49a61433290a 45 if( NULL == pPointer ){ break; }
dkato 5:49a61433290a 46 }
dkato 5:49a61433290a 47 return nRet;
dkato 5:49a61433290a 48 }
dkato 5:49a61433290a 49
dkato 5:49a61433290a 50 /*------------------------------------------------------------------------------------------------------------------*/
dkato 5:49a61433290a 51 /* CalcFrSize */
dkato 5:49a61433290a 52 /*------------------------------------------------------------------------------------------------------------------*/
dkato 5:49a61433290a 53 STB_UINT32 CalcFrSize ( STB_UINT32 nTraCntMax )
dkato 5:49a61433290a 54 {
dkato 5:49a61433290a 55 STB_UINT32 retVal ;
dkato 5:49a61433290a 56
dkato 5:49a61433290a 57 retVal = 0 ;
dkato 5:49a61433290a 58
dkato 5:49a61433290a 59 retVal += 100 ;///Margin : alignment
dkato 5:49a61433290a 60
dkato 5:49a61433290a 61
dkato 5:49a61433290a 62
dkato 5:49a61433290a 63 retVal += sizeof( FR_DET ) * nTraCntMax ; // frDet.fcDet
dkato 5:49a61433290a 64 retVal += sizeof( STB_FR_DET ) * STB_FR_BACK_MAX ; // frDetRec
dkato 5:49a61433290a 65 retVal += sizeof( FR_DET ) * nTraCntMax * nTraCntMax ; // frDetRec[t].fcDet
dkato 5:49a61433290a 66 retVal += sizeof( FR_RES ) * nTraCntMax ; // frRes.frFace
dkato 5:49a61433290a 67
dkato 5:49a61433290a 68 return retVal;
dkato 5:49a61433290a 69 }
dkato 5:49a61433290a 70 /*------------------------------------------------------------------------------------------------------------------*/
dkato 5:49a61433290a 71 /* ShareFrSize */
dkato 5:49a61433290a 72 /*------------------------------------------------------------------------------------------------------------------*/
dkato 5:49a61433290a 73 void ShareFrSize ( FRHANDLE handle )
dkato 5:49a61433290a 74 {
dkato 5:49a61433290a 75
dkato 5:49a61433290a 76 STB_UINT32 t;
dkato 5:49a61433290a 77 STB_INT8 *stbPtr = handle->frPtr ;
dkato 5:49a61433290a 78 STB_UINT32 nTraCntMax = handle->frCntMax ;
dkato 5:49a61433290a 79
dkato 5:49a61433290a 80 handle->frDet.fcDet = ( FR_DET* ) stbPtr; stbPtr += ( sizeof( FR_DET ) * nTraCntMax );
dkato 5:49a61433290a 81 handle->frDetRec = ( STB_FR_DET* ) stbPtr; stbPtr += ( sizeof( STB_FR_DET ) * STB_FR_BACK_MAX);
dkato 5:49a61433290a 82 for( t = 0 ; t < STB_FR_BACK_MAX ; t++ )
dkato 5:49a61433290a 83 {
dkato 5:49a61433290a 84 handle->frDetRec[t].fcDet = ( FR_DET* ) stbPtr; stbPtr += ( sizeof( FR_DET ) * nTraCntMax );
dkato 5:49a61433290a 85 }
dkato 5:49a61433290a 86 handle->frRes.frFace = ( FR_RES * ) stbPtr; stbPtr += ( sizeof( FR_RES ) * nTraCntMax );
dkato 5:49a61433290a 87
dkato 5:49a61433290a 88 }
dkato 5:49a61433290a 89 /*---------------------------------------------------------------------
dkato 5:49a61433290a 90 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 91 /*Create handle*/
dkato 5:49a61433290a 92 FRHANDLE FrCreateHandle( const STB_INT32 nTraCntMax )
dkato 5:49a61433290a 93
dkato 5:49a61433290a 94 {
dkato 5:49a61433290a 95
dkato 5:49a61433290a 96 FRHANDLE handle;
dkato 5:49a61433290a 97 STB_INT32 t , i ;
dkato 5:49a61433290a 98 STB_INT32 tmpVal;
dkato 5:49a61433290a 99
dkato 5:49a61433290a 100
dkato 5:49a61433290a 101
dkato 5:49a61433290a 102 if( nTraCntMax < 1 || STB_FR_TRA_CNT_MAX < nTraCntMax )
dkato 5:49a61433290a 103 {
dkato 5:49a61433290a 104 return NULL;
dkato 5:49a61433290a 105 }
dkato 5:49a61433290a 106
dkato 5:49a61433290a 107 /*do handle's Malloc here*/
dkato 5:49a61433290a 108 handle = (FRHANDLE)malloc(sizeof(*handle));
dkato 5:49a61433290a 109 if(handle == NULL)
dkato 5:49a61433290a 110 {
dkato 5:49a61433290a 111 return NULL;
dkato 5:49a61433290a 112 }
dkato 5:49a61433290a 113
dkato 5:49a61433290a 114
dkato 5:49a61433290a 115 /*initial value---------------------------------------------------------------------*/
dkato 5:49a61433290a 116 handle->frFaceDirUDMax = STB_FR_DIR_MAX_UD_INI ;
dkato 5:49a61433290a 117 handle->frFaceDirUDMin = STB_FR_DIR_MIN_UD_INI ;
dkato 5:49a61433290a 118 handle->frFaceDirLRMax = STB_FR_DIR_MAX_LR_INI ;
dkato 5:49a61433290a 119 handle->frFaceDirLRMin = STB_FR_DIR_MIN_LR_INI ;
dkato 5:49a61433290a 120 handle->frCntMax = nTraCntMax ;//Maximum number of tracking people
dkato 5:49a61433290a 121 handle->frFaceDirThr = STB_FR_DIR_THR_INI ;//If the confidence of Face direction estimation doesn't exceed the reference value, the recognition result isn't trusted.
dkato 5:49a61433290a 122 handle->frFrameCount = STB_FR_FRAME_CNT_INI ;
dkato 5:49a61433290a 123 handle->frFrameRatio = STB_FR_FRAME_RATIO_INI ;
dkato 5:49a61433290a 124 handle->frPtr = NULL;
dkato 5:49a61433290a 125 handle->frDet.num = 0;
dkato 5:49a61433290a 126 handle->frDet.fcDet = NULL;
dkato 5:49a61433290a 127 handle->frDetRec = NULL;
dkato 5:49a61433290a 128 handle->frRes.frCnt = 0;
dkato 5:49a61433290a 129 handle->frRes.frFace = NULL;
dkato 5:49a61433290a 130
dkato 5:49a61433290a 131 tmpVal = CalcFrSize ( nTraCntMax ); /*calculate necessary amount in the Fr handle*/
dkato 5:49a61433290a 132 handle->frPtr = NULL;
dkato 5:49a61433290a 133 handle->frPtr = ( STB_INT8 * )malloc( tmpVal ); /*keeping necessary amount in the Fr handle*/
dkato 5:49a61433290a 134 if( handle->frPtr == NULL )
dkato 5:49a61433290a 135 {
dkato 5:49a61433290a 136 free ( handle->frPtr );
dkato 5:49a61433290a 137 free ( handle );
dkato 5:49a61433290a 138 return NULL;
dkato 5:49a61433290a 139 }
dkato 5:49a61433290a 140
dkato 5:49a61433290a 141 /* Malloc-area is allocated to things that need Malloc in FR handle */
dkato 5:49a61433290a 142 ShareFrSize ( handle );
dkato 5:49a61433290a 143
dkato 5:49a61433290a 144
dkato 5:49a61433290a 145
dkato 5:49a61433290a 146
dkato 5:49a61433290a 147 for( t = 0 ; t < STB_FR_BACK_MAX ; t++ )
dkato 5:49a61433290a 148 {
dkato 5:49a61433290a 149 handle->frDetRec [ t ].num = 0;
dkato 5:49a61433290a 150 for( i = 0 ; i < handle->frCntMax ; i++ )
dkato 5:49a61433290a 151 {
dkato 5:49a61433290a 152 handle->frDetRec [ t ].fcDet[i].nDetID = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 153 handle->frDetRec [ t ].fcDet[i].nTraID = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 154 handle->frDetRec [ t ].fcDet[i].dirDetPitch = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 155 handle->frDetRec [ t ].fcDet[i].dirDetRoll = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 156 handle->frDetRec [ t ].fcDet[i].dirDetYaw = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 157 handle->frDetRec [ t ].fcDet[i].frDetConf = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 158 handle->frDetRec [ t ].fcDet[i].frDetID = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 159 handle->frDetRec [ t ].fcDet[i].frDetConf = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 160 handle->frDetRec [ t ].fcDet[i].frStatus = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 161
dkato 5:49a61433290a 162 }
dkato 5:49a61433290a 163 }
dkato 5:49a61433290a 164
dkato 5:49a61433290a 165 return handle;
dkato 5:49a61433290a 166 }
dkato 5:49a61433290a 167
dkato 5:49a61433290a 168 /*---------------------------------------------------------------------
dkato 5:49a61433290a 169 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 170 /*Delete handle*/
dkato 5:49a61433290a 171 STB_INT32 FrDeleteHandle(FRHANDLE handle){
dkato 5:49a61433290a 172 STB_INT32 nRet;
dkato 5:49a61433290a 173
dkato 5:49a61433290a 174 /*NULL check*/
dkato 5:49a61433290a 175 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 176 if(nRet != STB_ERR_NOHANDLE){
dkato 5:49a61433290a 177 return nRet;
dkato 5:49a61433290a 178 }
dkato 5:49a61433290a 179
dkato 5:49a61433290a 180 free ( handle->frPtr );
dkato 5:49a61433290a 181 free ( handle );
dkato 5:49a61433290a 182
dkato 5:49a61433290a 183 return STB_NORMAL;
dkato 5:49a61433290a 184 }
dkato 5:49a61433290a 185
dkato 5:49a61433290a 186
dkato 5:49a61433290a 187 /*---------------------------------------------------------------------
dkato 5:49a61433290a 188 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 189 /*Set the result*/
dkato 5:49a61433290a 190 STB_INT32 FrSetDetect(FRHANDLE handle,const STB_FR_DET *stbFrDet){
dkato 5:49a61433290a 191
dkato 5:49a61433290a 192 STB_INT32 nRet;
dkato 5:49a61433290a 193 STB_INT32 i;
dkato 5:49a61433290a 194
dkato 5:49a61433290a 195 /*NULL check*/
dkato 5:49a61433290a 196 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 197 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 198 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 199 }
dkato 5:49a61433290a 200
dkato 5:49a61433290a 201 nRet = FrIsValidPointer(stbFrDet);
dkato 5:49a61433290a 202 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 203 return nRet;
dkato 5:49a61433290a 204 }
dkato 5:49a61433290a 205
dkato 5:49a61433290a 206 /*Input value check*/
dkato 5:49a61433290a 207 nRet = STB_FrIsValidValue ( stbFrDet );
dkato 5:49a61433290a 208 if(nRet != STB_TRUE)
dkato 5:49a61433290a 209 {
dkato 5:49a61433290a 210 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 211 }
dkato 5:49a61433290a 212
dkato 5:49a61433290a 213
dkato 5:49a61433290a 214 /*Set the received result to the handle*/
dkato 5:49a61433290a 215 /* Face */
dkato 5:49a61433290a 216 if( stbFrDet->num > handle->frCntMax )
dkato 5:49a61433290a 217 {
dkato 5:49a61433290a 218 return STB_ERR_PROCESSCONDITION;
dkato 5:49a61433290a 219 }
dkato 5:49a61433290a 220 handle->frDet.num = stbFrDet->num;
dkato 5:49a61433290a 221 for( i = 0 ; i < handle->frDet.num ; i++ )
dkato 5:49a61433290a 222 {
dkato 5:49a61433290a 223
dkato 5:49a61433290a 224 handle->frDet.fcDet[i].nDetID = stbFrDet->fcDet[i].nDetID ;
dkato 5:49a61433290a 225 handle->frDet.fcDet[i].nTraID = stbFrDet->fcDet[i].nTraID ;
dkato 5:49a61433290a 226 handle->frDet.fcDet[i].dirDetPitch = stbFrDet->fcDet[i].dirDetPitch;
dkato 5:49a61433290a 227 handle->frDet.fcDet[i].dirDetRoll = stbFrDet->fcDet[i].dirDetRoll ;
dkato 5:49a61433290a 228 handle->frDet.fcDet[i].dirDetYaw = stbFrDet->fcDet[i].dirDetYaw ;
dkato 5:49a61433290a 229 handle->frDet.fcDet[i].dirDetConf = stbFrDet->fcDet[i].dirDetConf ;
dkato 5:49a61433290a 230 handle->frDet.fcDet[i].frDetID = stbFrDet->fcDet[i].frDetID ;
dkato 5:49a61433290a 231 handle->frDet.fcDet[i].frDetConf = stbFrDet->fcDet[i].frDetConf ;
dkato 5:49a61433290a 232
dkato 5:49a61433290a 233 }
dkato 5:49a61433290a 234
dkato 5:49a61433290a 235
dkato 5:49a61433290a 236
dkato 5:49a61433290a 237 return STB_NORMAL;
dkato 5:49a61433290a 238 }
dkato 5:49a61433290a 239 /*---------------------------------------------------------------------
dkato 5:49a61433290a 240 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 241 /*Main process execution*/
dkato 5:49a61433290a 242 STB_INT32 FrExecute(FRHANDLE handle){
dkato 5:49a61433290a 243 STB_INT32 nRet;
dkato 5:49a61433290a 244 /*NULL check*/
dkato 5:49a61433290a 245 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 246 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 247 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 248 }
dkato 5:49a61433290a 249
dkato 5:49a61433290a 250 /*Main processing here*/
dkato 5:49a61433290a 251 nRet = StbFrExec ( handle );
dkato 5:49a61433290a 252
dkato 5:49a61433290a 253 return STB_NORMAL;
dkato 5:49a61433290a 254 }
dkato 5:49a61433290a 255 /*---------------------------------------------------------------------
dkato 5:49a61433290a 256 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 257 /*Get-Function of results*/
dkato 5:49a61433290a 258 STB_INT32 FrGetResult(FRHANDLE handle,STB_FR_RES* frResult){
dkato 5:49a61433290a 259 STB_INT32 nRet;
dkato 5:49a61433290a 260 int i;
dkato 5:49a61433290a 261
dkato 5:49a61433290a 262 /*NULL check*/
dkato 5:49a61433290a 263 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 264 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 265 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 266 }
dkato 5:49a61433290a 267
dkato 5:49a61433290a 268 nRet = FrIsValidPointer(frResult);
dkato 5:49a61433290a 269 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 270 return nRet;
dkato 5:49a61433290a 271 }
dkato 5:49a61433290a 272
dkato 5:49a61433290a 273 /*Get result from handle*/
dkato 5:49a61433290a 274 frResult->frCnt = handle->frRes.frCnt ;
dkato 5:49a61433290a 275 for( i = 0 ; i < frResult->frCnt ; i++ ){
dkato 5:49a61433290a 276 frResult->frFace[i].nTraID = handle->frRes.frFace[i].nTraID ;
dkato 5:49a61433290a 277 frResult->frFace[i].frRecog.value = handle->frRes.frFace[i].frRecog.value ;
dkato 5:49a61433290a 278 frResult->frFace[i].frRecog.status = handle->frRes.frFace[i].frRecog.status ;
dkato 5:49a61433290a 279 frResult->frFace[i].frRecog.conf = handle->frRes.frFace[i].frRecog.conf ;
dkato 5:49a61433290a 280 }
dkato 5:49a61433290a 281
dkato 5:49a61433290a 282 return STB_NORMAL;
dkato 5:49a61433290a 283 }
dkato 5:49a61433290a 284 /*---------------------------------------------------------------------
dkato 5:49a61433290a 285 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 286 STB_INT32 FrSetFaceDirMinMax(FRHANDLE handle , STB_INT32 nMinUDAngle , STB_INT32 nMaxUDAngle ,STB_INT32 nMinLRAngle , STB_INT32 nMaxLRAngle)
dkato 5:49a61433290a 287 {
dkato 5:49a61433290a 288
dkato 5:49a61433290a 289 STB_INT32 nRet;
dkato 5:49a61433290a 290 /*NULL check*/
dkato 5:49a61433290a 291 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 292 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 293 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 294 }
dkato 5:49a61433290a 295
dkato 5:49a61433290a 296 if( nMinUDAngle < STB_FR_DIR_MIN_UD_MIN || STB_FR_DIR_MIN_UD_MAX < nMinUDAngle)
dkato 5:49a61433290a 297 {
dkato 5:49a61433290a 298 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 299 }
dkato 5:49a61433290a 300 if( nMaxUDAngle < STB_FR_DIR_MAX_UD_MIN || STB_FR_DIR_MAX_UD_MAX < nMaxUDAngle)
dkato 5:49a61433290a 301 {
dkato 5:49a61433290a 302 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 303 }
dkato 5:49a61433290a 304 if( nMaxUDAngle < nMinUDAngle)
dkato 5:49a61433290a 305 {
dkato 5:49a61433290a 306 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 307 }
dkato 5:49a61433290a 308
dkato 5:49a61433290a 309
dkato 5:49a61433290a 310 if( nMinLRAngle < STB_FR_DIR_MIN_LR_MIN || STB_FR_DIR_MIN_LR_MAX < nMinLRAngle)
dkato 5:49a61433290a 311 {
dkato 5:49a61433290a 312 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 313 }
dkato 5:49a61433290a 314 if( nMaxLRAngle < STB_FR_DIR_MAX_LR_MIN || STB_FR_DIR_MAX_LR_MAX < nMaxLRAngle)
dkato 5:49a61433290a 315 {
dkato 5:49a61433290a 316 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 317 }
dkato 5:49a61433290a 318 if( nMaxLRAngle < nMinLRAngle)
dkato 5:49a61433290a 319 {
dkato 5:49a61433290a 320 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 321 }
dkato 5:49a61433290a 322
dkato 5:49a61433290a 323
dkato 5:49a61433290a 324 handle->frFaceDirUDMin = nMinUDAngle;
dkato 5:49a61433290a 325 handle->frFaceDirUDMax = nMaxUDAngle;
dkato 5:49a61433290a 326 handle->frFaceDirLRMin = nMinLRAngle;
dkato 5:49a61433290a 327 handle->frFaceDirLRMax = nMaxLRAngle;
dkato 5:49a61433290a 328 return STB_NORMAL;
dkato 5:49a61433290a 329 }
dkato 5:49a61433290a 330 /*---------------------------------------------------------------------
dkato 5:49a61433290a 331 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 332 STB_INT32 FrGetFaceDirMinMax(FRHANDLE handle , STB_INT32 *pnMinUDAngle , STB_INT32 *pnMaxUDAngle ,STB_INT32 *pnMinLRAngle, STB_INT32 *pnMaxLRAngle )
dkato 5:49a61433290a 333 {
dkato 5:49a61433290a 334 STB_INT32 nRet;
dkato 5:49a61433290a 335 /*NULL check*/
dkato 5:49a61433290a 336 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 337 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 338 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 339 }
dkato 5:49a61433290a 340 nRet = FrIsValidPointer(pnMinUDAngle);
dkato 5:49a61433290a 341 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 342 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 343 }
dkato 5:49a61433290a 344 nRet = FrIsValidPointer(pnMaxUDAngle);
dkato 5:49a61433290a 345 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 346 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 347 }
dkato 5:49a61433290a 348 nRet = FrIsValidPointer(pnMinLRAngle);
dkato 5:49a61433290a 349 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 350 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 351 }
dkato 5:49a61433290a 352 nRet = FrIsValidPointer(pnMaxLRAngle);
dkato 5:49a61433290a 353 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 354 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 355 }
dkato 5:49a61433290a 356
dkato 5:49a61433290a 357
dkato 5:49a61433290a 358 *pnMinUDAngle = handle->frFaceDirUDMin ;
dkato 5:49a61433290a 359 *pnMaxUDAngle = handle->frFaceDirUDMax ;
dkato 5:49a61433290a 360 *pnMinLRAngle = handle->frFaceDirLRMin ;
dkato 5:49a61433290a 361 *pnMaxLRAngle = handle->frFaceDirLRMax ;
dkato 5:49a61433290a 362 return STB_NORMAL;
dkato 5:49a61433290a 363 }
dkato 5:49a61433290a 364 /*---------------------------------------------------------------------
dkato 5:49a61433290a 365 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 366 STB_INT32 FrClear ( FRHANDLE handle )
dkato 5:49a61433290a 367 {
dkato 5:49a61433290a 368 //clear processing
dkato 5:49a61433290a 369
dkato 5:49a61433290a 370 STB_INT32 t , i ;
dkato 5:49a61433290a 371 STB_INT32 nRet;
dkato 5:49a61433290a 372
dkato 5:49a61433290a 373 /*NULL check*/
dkato 5:49a61433290a 374 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 375 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 376 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 377 }
dkato 5:49a61433290a 378
dkato 5:49a61433290a 379 for( t = 0 ; t < STB_FR_BACK_MAX ; t++ )
dkato 5:49a61433290a 380 {
dkato 5:49a61433290a 381 handle->frDetRec [ t ].num = 0;
dkato 5:49a61433290a 382 for( i = 0 ; i < handle->frCntMax ; i++ )
dkato 5:49a61433290a 383 {
dkato 5:49a61433290a 384 handle->frDetRec [ t ].fcDet[i].nDetID = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 385 handle->frDetRec [ t ].fcDet[i].nTraID = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 386 handle->frDetRec [ t ].fcDet[i].dirDetPitch = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 387 handle->frDetRec [ t ].fcDet[i].dirDetRoll = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 388 handle->frDetRec [ t ].fcDet[i].dirDetYaw = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 389 handle->frDetRec [ t ].fcDet[i].dirDetConf = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 390 handle->frDetRec [ t ].fcDet[i].frDetID = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 391 handle->frDetRec [ t ].fcDet[i].frDetConf = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 392 handle->frDetRec [ t ].fcDet[i].frStatus = STB_STATUS_NO_DATA ;
dkato 5:49a61433290a 393
dkato 5:49a61433290a 394 }
dkato 5:49a61433290a 395 }
dkato 5:49a61433290a 396 return STB_NORMAL;
dkato 5:49a61433290a 397
dkato 5:49a61433290a 398
dkato 5:49a61433290a 399 }
dkato 5:49a61433290a 400 /*---------------------------------------------------------------------
dkato 5:49a61433290a 401 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 402 /*---------------------------------------------------------------------
dkato 5:49a61433290a 403 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 404 STB_INT32 FrSetFaceDirThreshold(FRHANDLE handle , STB_INT32 threshold )
dkato 5:49a61433290a 405 {
dkato 5:49a61433290a 406 STB_INT32 nRet;
dkato 5:49a61433290a 407 /*NULL check*/
dkato 5:49a61433290a 408 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 409 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 410 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 411 }
dkato 5:49a61433290a 412
dkato 5:49a61433290a 413 if( threshold < STB_FR_DIR_THR_MIN || STB_FR_DIR_THR_MAX < threshold)
dkato 5:49a61433290a 414 {
dkato 5:49a61433290a 415 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 416 }
dkato 5:49a61433290a 417 handle->frFaceDirThr = threshold;
dkato 5:49a61433290a 418 return STB_NORMAL;
dkato 5:49a61433290a 419 }
dkato 5:49a61433290a 420 /*---------------------------------------------------------------------
dkato 5:49a61433290a 421 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 422 STB_INT32 FrGetFaceDirThreshold(FRHANDLE handle , STB_INT32* threshold )
dkato 5:49a61433290a 423 {
dkato 5:49a61433290a 424 STB_INT32 nRet;
dkato 5:49a61433290a 425
dkato 5:49a61433290a 426 /*NULL check*/
dkato 5:49a61433290a 427 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 428 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 429 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 430 }
dkato 5:49a61433290a 431 nRet = FrIsValidPointer(threshold);
dkato 5:49a61433290a 432 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 433 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 434 }
dkato 5:49a61433290a 435
dkato 5:49a61433290a 436 *threshold = handle->frFaceDirThr ;
dkato 5:49a61433290a 437 return STB_NORMAL;
dkato 5:49a61433290a 438 }
dkato 5:49a61433290a 439 /*---------------------------------------------------------------------
dkato 5:49a61433290a 440 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 441 STB_INT32 FrSetFrameCount(FRHANDLE handle , STB_INT32 nFrameCount )
dkato 5:49a61433290a 442 {
dkato 5:49a61433290a 443
dkato 5:49a61433290a 444 STB_INT32 nRet;
dkato 5:49a61433290a 445 /*NULL check*/
dkato 5:49a61433290a 446 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 447 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 448 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 449 }
dkato 5:49a61433290a 450 if( nFrameCount < STB_FR_FRAME_CNT_MIN || STB_FR_FRAME_CNT_MAX < nFrameCount)
dkato 5:49a61433290a 451 {
dkato 5:49a61433290a 452 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 453 }
dkato 5:49a61433290a 454 handle->frFrameCount = nFrameCount;
dkato 5:49a61433290a 455 return STB_NORMAL;
dkato 5:49a61433290a 456 }
dkato 5:49a61433290a 457 /*---------------------------------------------------------------------
dkato 5:49a61433290a 458 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 459 STB_INT32 FrGetFrameCount(FRHANDLE handle , STB_INT32* nFrameCount )
dkato 5:49a61433290a 460 {
dkato 5:49a61433290a 461 STB_INT32 nRet;
dkato 5:49a61433290a 462 /*NULL check*/
dkato 5:49a61433290a 463 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 464 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 465 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 466 }
dkato 5:49a61433290a 467 nRet = FrIsValidPointer(nFrameCount);
dkato 5:49a61433290a 468 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 469 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 470 }
dkato 5:49a61433290a 471
dkato 5:49a61433290a 472 *nFrameCount = handle->frFrameCount ;
dkato 5:49a61433290a 473 return STB_NORMAL;
dkato 5:49a61433290a 474 }
dkato 5:49a61433290a 475 /*---------------------------------------------------------------------
dkato 5:49a61433290a 476 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 477 STB_INT32 FrSetMinRatio(FRHANDLE handle , STB_INT32 nMinRatio )
dkato 5:49a61433290a 478 {
dkato 5:49a61433290a 479 STB_INT32 nRet;
dkato 5:49a61433290a 480 /*NULL check*/
dkato 5:49a61433290a 481 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 482 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 483 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 484 }
dkato 5:49a61433290a 485 if( nMinRatio < STB_FR_FRAME_RATIO_MIN || STB_FR_FRAME_RATIO_MAX < nMinRatio)
dkato 5:49a61433290a 486 {
dkato 5:49a61433290a 487 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 488 }
dkato 5:49a61433290a 489 handle->frFrameRatio = nMinRatio;
dkato 5:49a61433290a 490 return STB_NORMAL;
dkato 5:49a61433290a 491 }
dkato 5:49a61433290a 492 /*---------------------------------------------------------------------
dkato 5:49a61433290a 493 ---------------------------------------------------------------------*/
dkato 5:49a61433290a 494 STB_INT32 FrGetMinRatio(FRHANDLE handle , STB_INT32* nMinRatio )
dkato 5:49a61433290a 495 {
dkato 5:49a61433290a 496 STB_INT32 nRet;
dkato 5:49a61433290a 497 /*NULL check*/
dkato 5:49a61433290a 498 nRet = FrIsValidPointer(handle);
dkato 5:49a61433290a 499 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 500 return STB_ERR_NOHANDLE;
dkato 5:49a61433290a 501 }
dkato 5:49a61433290a 502 nRet = FrIsValidPointer(nMinRatio);
dkato 5:49a61433290a 503 if(nRet != STB_NORMAL){
dkato 5:49a61433290a 504 return STB_ERR_INVALIDPARAM;
dkato 5:49a61433290a 505 }
dkato 5:49a61433290a 506
dkato 5:49a61433290a 507 *nMinRatio = handle->frFrameRatio ;
dkato 5:49a61433290a 508 return STB_NORMAL;
dkato 5:49a61433290a 509 }