![](/media/cache/group/renesas_logomark_l.jpg.50x50_q85.jpg)
Sample program that can send the recognition data from HVC-P2 to Fujitsu IoT Platform using REST (HTTP)
Dependencies: AsciiFont GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP USBHost_custom easy-connect-gr-peach mbed-http picojson
Information
Here are both English and Japanese description. First, English description is shown followed by Japanese one. 本ページには英語版と日本語版の説明があります。まず英語版、続いて日本語版の説明となります。
Overview
This sample program shows how to send the cognitive data gathered by Omron HVC-P2 (Human Vision Components B5T-007001) to IoT Platform managed by FUJITSU ( http://jp.fujitsu.com/solutions/cloud/k5/function/paas/iot-platform/ ).
Hardware Configuration
- GR-PEACH 1 set ( https://developer.mbed.org/platforms/Renesas-GR-PEACH/ )
- LCD Shield 1 set ( https://developer.mbed.org/teams/Renesas/Wiki/LCD-shield )
- HVC-P2 1 set ( Human Vision Components B5T-007001 ) ( https://plus-sensin.omron.com/product/B5T-007001/ )
- USBA - Micro USB Cable 2 sets
- USBA (Female) - Micro USB (Male) Adapter 1 set
When executing this sample program, please configure the above H/W as shown below:
Also, please close JP3 of GR-PEACH as follows:
Application Preconfiguration
- Configure Ethernet settings. For details, please refer to the following link:
https://developer.mbed.org/teams/Renesas/code/GR-PEACH_IoT_Platform_HTTP_sample/wiki/Ethernet-settings - On IoT Platform, set up the resource and its access code where the gathered data would be stored. For details on resource and access code, please refer to the following links:
https://iot-docs.jp-east-1.paas.cloud.global.fujitsu.com/en/manual/userguide_en.pdf
https://iot-docs.jp-east-1.paas.cloud.global.fujitsu.com/en/manual/apireference_en.pdf
https://iot-docs.jp-east-1.paas.cloud.global.fujitsu.com/en/manual/portalmanual_en.pdf
Build Procedure
- Import this sample program onto mbed Compiler
- In GR-PEACH_HVC-P2_IoTPlatform_http/IoT_Platform/iot_platform.cpp, please replace <ACCESS CODE> with the access code you set up on IoT Platform. For details on how to set up Access Code, please refer to the above Application Setup. Then, please delete the line beginning with #error macro.
Access Code configuration
#define ACCESS_CODE <Access CODE> #error "You need to replace <Access CODE for your resource> with yours"
- In GR-PEACH_HVC-P2_IoTPlatform_http/IoT_Platform/iot_platform.cpp, please replace <Base URI>, <Tenant ID> and <Path-to-Resource> below with yours and delete the line beginning with #error macro. For details on <Base URI> and <Tenant ID>, please contact FUJITSU LIMITED. Also, for details on <Path-to-Resource>, please refer to the above Application Setup.
URI configuration
std::string put_uri_base("<Base URI>/v1/<Tenant ID>/<Path-to-Resource>.json"); #error "You need to replace <Base URI>, <Tenant ID> and <Path-to-Resource> with yours" **snip** std::string get_uri("<Base URI>/v1/<Tenant ID>/<Path-to-Resource>/_past.json"); #error "You need to replace <Base URI>, <Tenant ID> and <Path-to-Resource> with yours"
- Compile the program. If compilation is successfully terminated, the binary should be downloaded on your PC.
- Plug Ethernet cable into GR-PEACH
- Plug micro-USB cable into the port which lies on the next to RESET button. If GR-PEACH is successfully recognized, it appears as the USB flash disk named mbed as show below:
- Copy the downloaded binary to mbed drive
- Press RESET button on GR-PEACH in order to run the program. If it's successfully run, you can see the following message on terminal:
Format of Data to be sent to IoT Platform
In this program, the cognitive data sent from HVC-P2 is serialized in the following JSON format and send it to IoT Platform:
- Face detection data
{ "RecodeType": "HVC-P2(face)" "id": <GR-PEACH ID>-<Sensor ID>" "FaceRectangle": { "Height": xxxx, "Left": xxxx, "Top": xxxx, "Width": xxxx, }, "Gender": "male" or "female", "Scores": { "Anger": zzz, "Hapiness": zzz, "Neutral": zzz, "Sadness": zzz, "Surprise": zzz } } xxxx: Top-left coordinate, width and height of the rectangle circumscribing the detected face in LCD display coordinate system zzz: the value indicating the expression estimated from the detected face
//
- Body detection data
{ "RecodeType": "HVC-P2(body)" "id": <GR-PEACH ID>-<Sensor ID>" "BodyRectangle": { "Height": xxxx, "Left": xxxx, "Top": xxxx, "Width": xxxx, } } xxxx: Top-left coordinate, width and height of the rectangle circumscribing the detected body in LCD display coordinate system
概要
本プログラムは、オムロン社製HVC-P2 (Human Vision Components B5T-007001)で収集した各種認識データを、富士通社のIoT Platform ( http://jp.fujitsu.com/solutions/cloud/k5/function/paas/iot-platform/ ) に送信するサンプルプログラムです。
ハードウェア構成
- GR-PEACH 1式 ( https://developer.mbed.org/platforms/Renesas-GR-PEACH/ )
- LCD Shield 1式 ( https://developer.mbed.org/teams/Renesas/Wiki/LCD-shield )
- HVC-P2 1式 ( Human Vision Components B5T-007001 ) ( https://plus-sensin.omron.com/product/B5T-007001/ )
- USBA - Micro USBケーブル 2式
- USBA (メス) - Micro USB (オス)変換アダプタ 1式
本プログラムを動作させる場合、上記H/Wを下図のように接続してください。
また下図に示すGR-PEACHのJP3をショートしてください。
アプリケーションの事前設定
- Ethernetの設定を行います。詳細は下記リンクを参照ください。
https://developer.mbed.org/teams/Renesas/code/GR-PEACH_IoT_Platform_HTTP_sample/wiki/Ethernet-settings - HVC-P2で収集したデータを格納するリソース、およびそのアクセスコードをIoT Platform上で設定します。詳細は下記リンクを参照ください。
https://iot-docs.jp-east-1.paas.cloud.global.fujitsu.com/en/manual/userguide_en.pdf https://iot-docs.jp-east-1.paas.cloud.global.fujitsu.com/en/manual/apireference_en.pdf https://iot-docs.jp-east-1.paas.cloud.global.fujitsu.com/en/manual/portalmanual_en.pdf
ビルド手順
- 本サンプルプログラムをmbed Compilerにインポートします
- 下記に示すGR-PEACH_HVC-P2_IoTPlatform_http/IoT_Platform/iot_platform.cpp中の<ACCESS CODE> を、IoT Platform上で設定したアクセスコードで上書きしてください。<Access Code>の設定方法につきましては、上述のApplication Setupを参照願います。また #errorマクロで始まる行を削除してください。
Access Code configuration
#define ACCESS_CODE <Access CODE> #error "You need to replace <Access CODE for your resource> with yours"
- 下記に示すGR-PEACH_HVC-P2_IoTPlatform_http/IoT_Platform/iot_platform.cpp中の<Base URI>と <Tenant ID>、および<Path-to-Resource>>を適当な値に置換えるとともに、#errorマクロで始まる行を削除してください。ここで、<Base URI>、 <Tenant ID>の詳細につきましては富士通社へご確認願います。また<Path-to-Resource>>につきましては、Application Setupの項を参照ください。
URI configuration
std::string put_uri_base("<Base URI>/v1/<Tenant ID>/<Path-to-Resource>.json"); #error "You need to replace <Base URI>, <Tenant ID> and <Path-to-Resource> with yours" (中略) std::string get_uri("<Base URI>/v1/<Tenant ID>/<Path-to-Resource>/_past.json"); #error "You need to replace <Base URI>, <Tenant ID> and <Path-to-Resource> with yours"
- プログラムをコンパイルします。コンパイルが正常終了すると、バイナリがお使いのPCにダウンロードされます。
- GR-PEACHのRJ-45コネクタにEthernetケーブルを差し込んでください。
- USBA - Micro USBケーブルを、GR-PEACHのRESETボタンの隣に配置されたMicro USBポートに差し込んでください。GR-PEACHが正常に認識されると、下図に示すようにGR-PEACHがmbedという名称のUSBドライブとして認識されます。
- ダウンロードしたバイナリをmbedドライブにコピーします。
- RESETボタンを押下してプログラムを実行します。正常に実行された場合、下記に示すメッセージがターミナル上に表示されます。
送信データフォーマット
本プログラムでは、HVC-P2が収集した認識データを下記のJSONフォーマットにシリアライズし、IoT Platformへ送信します。
- Face detection data
{ "RecodeType": "HVC-P2(face)" "id": <GR-PEACH ID>-<Sensor ID>" "FaceRectangle": { "Height": xxxx, "Left": xxxx, "Top": xxxx, "Width": xxxx, }, "Gender": "male" or "female", "Scores": { "Anger": zzz, "Hapiness": zzz, "Neutral": zzz, "Sadness": zzz, "Surprise": zzz } } xxxx: LCD表示座標系における検出した顔に外接する矩形の左上座標・幅・高さ zzz: 検出した顔から推定した各種感情を示す数値
//
- Body detection data
{ "RecodeType": "HVC-P2(body)" "id": <GR-PEACH ID>-<Sensor ID>" "BodyRectangle": { "Height": xxxx, "Left": xxxx, "Top": xxxx, "Width": xxxx, } } xxxx: LCD表示座標系における検出した人体に外接する矩形の左上座標・幅・高さ
HVCApi/HVCApi.c@0:813a237f1c50, 2017-09-07 (annotated)
- Committer:
- Osamu Nakamura
- Date:
- Thu Sep 07 18:15:54 2017 +0900
- Revision:
- 0:813a237f1c50
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Osamu Nakamura |
0:813a237f1c50 | 1 | /*---------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 2 | /* Copyright(C) 2017 OMRON Corporation */ |
Osamu Nakamura |
0:813a237f1c50 | 3 | /* */ |
Osamu Nakamura |
0:813a237f1c50 | 4 | /* Licensed under the Apache License, Version 2.0 (the "License"); */ |
Osamu Nakamura |
0:813a237f1c50 | 5 | /* you may not use this file except in compliance with the License. */ |
Osamu Nakamura |
0:813a237f1c50 | 6 | /* You may obtain a copy of the License at */ |
Osamu Nakamura |
0:813a237f1c50 | 7 | /* */ |
Osamu Nakamura |
0:813a237f1c50 | 8 | /* http://www.apache.org/licenses/LICENSE-2.0 */ |
Osamu Nakamura |
0:813a237f1c50 | 9 | /* */ |
Osamu Nakamura |
0:813a237f1c50 | 10 | /* Unless required by applicable law or agreed to in writing, software */ |
Osamu Nakamura |
0:813a237f1c50 | 11 | /* distributed under the License is distributed on an "AS IS" BASIS, */ |
Osamu Nakamura |
0:813a237f1c50 | 12 | /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ |
Osamu Nakamura |
0:813a237f1c50 | 13 | /* See the License for the specific language governing permissions and */ |
Osamu Nakamura |
0:813a237f1c50 | 14 | /* limitations under the License. */ |
Osamu Nakamura |
0:813a237f1c50 | 15 | /*---------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 16 | |
Osamu Nakamura |
0:813a237f1c50 | 17 | /* |
Osamu Nakamura |
0:813a237f1c50 | 18 | HVC Sample API |
Osamu Nakamura |
0:813a237f1c50 | 19 | */ |
Osamu Nakamura |
0:813a237f1c50 | 20 | |
Osamu Nakamura |
0:813a237f1c50 | 21 | #include <stdlib.h> |
Osamu Nakamura |
0:813a237f1c50 | 22 | #include "HVCApi.h" |
Osamu Nakamura |
0:813a237f1c50 | 23 | #include "HVCExtraUartFunc.h" |
Osamu Nakamura |
0:813a237f1c50 | 24 | |
Osamu Nakamura |
0:813a237f1c50 | 25 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 26 | /* Command number */ |
Osamu Nakamura |
0:813a237f1c50 | 27 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 28 | #define HVC_COM_GET_VERSION (UINT8)0x00 |
Osamu Nakamura |
0:813a237f1c50 | 29 | #define HVC_COM_SET_CAMERA_ANGLE (UINT8)0x01 |
Osamu Nakamura |
0:813a237f1c50 | 30 | #define HVC_COM_GET_CAMERA_ANGLE (UINT8)0x02 |
Osamu Nakamura |
0:813a237f1c50 | 31 | #define HVC_COM_EXECUTE (UINT8)0x03 |
Osamu Nakamura |
0:813a237f1c50 | 32 | #define HVC_COM_EXECUTEEX (UINT8)0x04 |
Osamu Nakamura |
0:813a237f1c50 | 33 | #define HVC_COM_SET_THRESHOLD (UINT8)0x05 |
Osamu Nakamura |
0:813a237f1c50 | 34 | #define HVC_COM_GET_THRESHOLD (UINT8)0x06 |
Osamu Nakamura |
0:813a237f1c50 | 35 | #define HVC_COM_SET_SIZE_RANGE (UINT8)0x07 |
Osamu Nakamura |
0:813a237f1c50 | 36 | #define HVC_COM_GET_SIZE_RANGE (UINT8)0x08 |
Osamu Nakamura |
0:813a237f1c50 | 37 | #define HVC_COM_SET_DETECTION_ANGLE (UINT8)0x09 |
Osamu Nakamura |
0:813a237f1c50 | 38 | #define HVC_COM_GET_DETECTION_ANGLE (UINT8)0x0A |
Osamu Nakamura |
0:813a237f1c50 | 39 | #define HVC_COM_SET_BAUDRATE (UINT8)0x0E |
Osamu Nakamura |
0:813a237f1c50 | 40 | #define HVC_COM_REGISTRATION (UINT8)0x10 |
Osamu Nakamura |
0:813a237f1c50 | 41 | #define HVC_COM_DELETE_DATA (UINT8)0x11 |
Osamu Nakamura |
0:813a237f1c50 | 42 | #define HVC_COM_DELETE_USER (UINT8)0x12 |
Osamu Nakamura |
0:813a237f1c50 | 43 | #define HVC_COM_DELETE_ALL (UINT8)0x13 |
Osamu Nakamura |
0:813a237f1c50 | 44 | #define HVC_COM_GET_PERSON_DATA (UINT8)0x15 |
Osamu Nakamura |
0:813a237f1c50 | 45 | #define HVC_COM_SAVE_ALBUM (UINT8)0x20 |
Osamu Nakamura |
0:813a237f1c50 | 46 | #define HVC_COM_LOAD_ALBUM (UINT8)0x21 |
Osamu Nakamura |
0:813a237f1c50 | 47 | #define HVC_COM_WRITE_ALBUM (UINT8)0x22 |
Osamu Nakamura |
0:813a237f1c50 | 48 | |
Osamu Nakamura |
0:813a237f1c50 | 49 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 50 | /* Header for send signal data */ |
Osamu Nakamura |
0:813a237f1c50 | 51 | typedef enum { |
Osamu Nakamura |
0:813a237f1c50 | 52 | SEND_HEAD_SYNCBYTE = 0, |
Osamu Nakamura |
0:813a237f1c50 | 53 | SEND_HEAD_COMMANDNO, |
Osamu Nakamura |
0:813a237f1c50 | 54 | SEND_HEAD_DATALENGTHLSB, |
Osamu Nakamura |
0:813a237f1c50 | 55 | SEND_HEAD_DATALENGTHMSB, |
Osamu Nakamura |
0:813a237f1c50 | 56 | SEND_HEAD_NUM |
Osamu Nakamura |
0:813a237f1c50 | 57 | }SEND_HEADER; |
Osamu Nakamura |
0:813a237f1c50 | 58 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 59 | /* Header for receive signal data */ |
Osamu Nakamura |
0:813a237f1c50 | 60 | typedef enum { |
Osamu Nakamura |
0:813a237f1c50 | 61 | RECEIVE_HEAD_SYNCBYTE = 0, |
Osamu Nakamura |
0:813a237f1c50 | 62 | RECEIVE_HEAD_STATUS, |
Osamu Nakamura |
0:813a237f1c50 | 63 | RECEIVE_HEAD_DATALENLL, |
Osamu Nakamura |
0:813a237f1c50 | 64 | RECEIVE_HEAD_DATALENLM, |
Osamu Nakamura |
0:813a237f1c50 | 65 | RECEIVE_HEAD_DATALENML, |
Osamu Nakamura |
0:813a237f1c50 | 66 | RECEIVE_HEAD_DATALENMM, |
Osamu Nakamura |
0:813a237f1c50 | 67 | RECEIVE_HEAD_NUM |
Osamu Nakamura |
0:813a237f1c50 | 68 | }RECEIVE_HEADER; |
Osamu Nakamura |
0:813a237f1c50 | 69 | |
Osamu Nakamura |
0:813a237f1c50 | 70 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 71 | /* Send command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 72 | /* param : UINT8 inCommandNo command number */ |
Osamu Nakamura |
0:813a237f1c50 | 73 | /* : INT32 inDataSize sending signal data size */ |
Osamu Nakamura |
0:813a237f1c50 | 74 | /* : UINT8 *inData sending signal data */ |
Osamu Nakamura |
0:813a237f1c50 | 75 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 76 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 77 | /* : -10...timeout error */ |
Osamu Nakamura |
0:813a237f1c50 | 78 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 79 | static INT32 HVC_SendCommand(UINT8 inCommandNo, INT32 inDataSize, UINT8 *inData) |
Osamu Nakamura |
0:813a237f1c50 | 80 | { |
Osamu Nakamura |
0:813a237f1c50 | 81 | INT32 i; |
Osamu Nakamura |
0:813a237f1c50 | 82 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 83 | UINT8 sendData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 84 | |
Osamu Nakamura |
0:813a237f1c50 | 85 | /* Create header */ |
Osamu Nakamura |
0:813a237f1c50 | 86 | sendData[SEND_HEAD_SYNCBYTE] = (UINT8)0xFE; |
Osamu Nakamura |
0:813a237f1c50 | 87 | sendData[SEND_HEAD_COMMANDNO] = (UINT8)inCommandNo; |
Osamu Nakamura |
0:813a237f1c50 | 88 | sendData[SEND_HEAD_DATALENGTHLSB] = (UINT8)(inDataSize&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 89 | sendData[SEND_HEAD_DATALENGTHMSB] = (UINT8)((inDataSize>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 90 | |
Osamu Nakamura |
0:813a237f1c50 | 91 | for(i = 0; i < inDataSize; i++){ |
Osamu Nakamura |
0:813a237f1c50 | 92 | sendData[SEND_HEAD_NUM + i] = inData[i]; |
Osamu Nakamura |
0:813a237f1c50 | 93 | } |
Osamu Nakamura |
0:813a237f1c50 | 94 | |
Osamu Nakamura |
0:813a237f1c50 | 95 | /* Send command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 96 | ret = UART_SendData(SEND_HEAD_NUM+inDataSize, sendData); |
Osamu Nakamura |
0:813a237f1c50 | 97 | if(ret != SEND_HEAD_NUM+inDataSize){ |
Osamu Nakamura |
0:813a237f1c50 | 98 | return HVC_ERROR_SEND_DATA; |
Osamu Nakamura |
0:813a237f1c50 | 99 | } |
Osamu Nakamura |
0:813a237f1c50 | 100 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 101 | } |
Osamu Nakamura |
0:813a237f1c50 | 102 | |
Osamu Nakamura |
0:813a237f1c50 | 103 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 104 | /* Send command signal of LoadAlbum */ |
Osamu Nakamura |
0:813a237f1c50 | 105 | /* param : UINT8 inCommandNo command number */ |
Osamu Nakamura |
0:813a237f1c50 | 106 | /* : INT32 inDataSize sending signal data size */ |
Osamu Nakamura |
0:813a237f1c50 | 107 | /* : UINT8 *inData sending signal data */ |
Osamu Nakamura |
0:813a237f1c50 | 108 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 109 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 110 | /* : -10...timeout error */ |
Osamu Nakamura |
0:813a237f1c50 | 111 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 112 | static INT32 HVC_SendCommandOfLoadAlbum(UINT8 inCommandNo, INT32 inDataSize, UINT8 *inData) |
Osamu Nakamura |
0:813a237f1c50 | 113 | { |
Osamu Nakamura |
0:813a237f1c50 | 114 | INT32 i; |
Osamu Nakamura |
0:813a237f1c50 | 115 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 116 | UINT8 *pSendData = NULL; |
Osamu Nakamura |
0:813a237f1c50 | 117 | |
Osamu Nakamura |
0:813a237f1c50 | 118 | pSendData = (UINT8*)malloc(SEND_HEAD_NUM + 4 + inDataSize); |
Osamu Nakamura |
0:813a237f1c50 | 119 | |
Osamu Nakamura |
0:813a237f1c50 | 120 | /* Create header */ |
Osamu Nakamura |
0:813a237f1c50 | 121 | pSendData[SEND_HEAD_SYNCBYTE] = (UINT8)0xFE; |
Osamu Nakamura |
0:813a237f1c50 | 122 | pSendData[SEND_HEAD_COMMANDNO] = (UINT8)inCommandNo; |
Osamu Nakamura |
0:813a237f1c50 | 123 | pSendData[SEND_HEAD_DATALENGTHLSB] = (UINT8)4; |
Osamu Nakamura |
0:813a237f1c50 | 124 | pSendData[SEND_HEAD_DATALENGTHMSB] = (UINT8)0; |
Osamu Nakamura |
0:813a237f1c50 | 125 | |
Osamu Nakamura |
0:813a237f1c50 | 126 | pSendData[SEND_HEAD_NUM + 0] = (UINT8)(inDataSize & 0x000000ff); |
Osamu Nakamura |
0:813a237f1c50 | 127 | pSendData[SEND_HEAD_NUM + 1] = (UINT8)((inDataSize >> 8) & 0x000000ff); |
Osamu Nakamura |
0:813a237f1c50 | 128 | pSendData[SEND_HEAD_NUM + 2] = (UINT8)((inDataSize >> 16) & 0x000000ff); |
Osamu Nakamura |
0:813a237f1c50 | 129 | pSendData[SEND_HEAD_NUM + 3] = (UINT8)((inDataSize >> 24) & 0x000000ff); |
Osamu Nakamura |
0:813a237f1c50 | 130 | |
Osamu Nakamura |
0:813a237f1c50 | 131 | for(i = 0; i < inDataSize; i++){ |
Osamu Nakamura |
0:813a237f1c50 | 132 | pSendData[SEND_HEAD_NUM + 4 + i] = inData[i]; |
Osamu Nakamura |
0:813a237f1c50 | 133 | } |
Osamu Nakamura |
0:813a237f1c50 | 134 | |
Osamu Nakamura |
0:813a237f1c50 | 135 | /* Send command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 136 | ret = UART_SendData(SEND_HEAD_NUM+4+inDataSize, pSendData); |
Osamu Nakamura |
0:813a237f1c50 | 137 | if(ret != SEND_HEAD_NUM + 4 + inDataSize){ |
Osamu Nakamura |
0:813a237f1c50 | 138 | ret = HVC_ERROR_SEND_DATA; |
Osamu Nakamura |
0:813a237f1c50 | 139 | } |
Osamu Nakamura |
0:813a237f1c50 | 140 | else{ |
Osamu Nakamura |
0:813a237f1c50 | 141 | ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 142 | } |
Osamu Nakamura |
0:813a237f1c50 | 143 | free(pSendData); |
Osamu Nakamura |
0:813a237f1c50 | 144 | |
Osamu Nakamura |
0:813a237f1c50 | 145 | return ret; |
Osamu Nakamura |
0:813a237f1c50 | 146 | } |
Osamu Nakamura |
0:813a237f1c50 | 147 | |
Osamu Nakamura |
0:813a237f1c50 | 148 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 149 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 150 | /* param : INT32 inTimeOutTime timeout time */ |
Osamu Nakamura |
0:813a237f1c50 | 151 | /* : INT32 *outDataSize receive signal data length */ |
Osamu Nakamura |
0:813a237f1c50 | 152 | /* : UINT8 *outStatus status */ |
Osamu Nakamura |
0:813a237f1c50 | 153 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 154 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 155 | /* : -20...timeout error */ |
Osamu Nakamura |
0:813a237f1c50 | 156 | /* : -21...invalid header error */ |
Osamu Nakamura |
0:813a237f1c50 | 157 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 158 | static INT32 HVC_ReceiveHeader(INT32 inTimeOutTime, INT32 *outDataSize, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 159 | { |
Osamu Nakamura |
0:813a237f1c50 | 160 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 161 | UINT8 headerData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 162 | |
Osamu Nakamura |
0:813a237f1c50 | 163 | /* Get header part */ |
Osamu Nakamura |
0:813a237f1c50 | 164 | ret = UART_ReceiveData(inTimeOutTime, RECEIVE_HEAD_NUM, headerData); |
Osamu Nakamura |
0:813a237f1c50 | 165 | if(ret != RECEIVE_HEAD_NUM){ |
Osamu Nakamura |
0:813a237f1c50 | 166 | return HVC_ERROR_HEADER_TIMEOUT; |
Osamu Nakamura |
0:813a237f1c50 | 167 | } |
Osamu Nakamura |
0:813a237f1c50 | 168 | else if((UINT8)0xFE != headerData[RECEIVE_HEAD_SYNCBYTE]){ |
Osamu Nakamura |
0:813a237f1c50 | 169 | /* Different value indicates an invalid result */ |
Osamu Nakamura |
0:813a237f1c50 | 170 | return HVC_ERROR_HEADER_INVALID; |
Osamu Nakamura |
0:813a237f1c50 | 171 | } |
Osamu Nakamura |
0:813a237f1c50 | 172 | |
Osamu Nakamura |
0:813a237f1c50 | 173 | /* Get data length */ |
Osamu Nakamura |
0:813a237f1c50 | 174 | *outDataSize = headerData[RECEIVE_HEAD_DATALENLL] + |
Osamu Nakamura |
0:813a237f1c50 | 175 | (headerData[RECEIVE_HEAD_DATALENLM]<<8) + |
Osamu Nakamura |
0:813a237f1c50 | 176 | (headerData[RECEIVE_HEAD_DATALENML]<<16) + |
Osamu Nakamura |
0:813a237f1c50 | 177 | (headerData[RECEIVE_HEAD_DATALENMM]<<24); |
Osamu Nakamura |
0:813a237f1c50 | 178 | |
Osamu Nakamura |
0:813a237f1c50 | 179 | /* Get command execution result */ |
Osamu Nakamura |
0:813a237f1c50 | 180 | *outStatus = headerData[RECEIVE_HEAD_STATUS]; |
Osamu Nakamura |
0:813a237f1c50 | 181 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 182 | } |
Osamu Nakamura |
0:813a237f1c50 | 183 | |
Osamu Nakamura |
0:813a237f1c50 | 184 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 185 | /* Receive data */ |
Osamu Nakamura |
0:813a237f1c50 | 186 | /* param : INT32 inTimeOutTime timeout time */ |
Osamu Nakamura |
0:813a237f1c50 | 187 | /* : INT32 inDataSize receive signal data size */ |
Osamu Nakamura |
0:813a237f1c50 | 188 | /* : UINT8 *outResult receive signal data */ |
Osamu Nakamura |
0:813a237f1c50 | 189 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 190 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 191 | /* : -20...timeout error */ |
Osamu Nakamura |
0:813a237f1c50 | 192 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 193 | static INT32 HVC_ReceiveData(INT32 inTimeOutTime, INT32 inDataSize, UINT8 *outResult) |
Osamu Nakamura |
0:813a237f1c50 | 194 | { |
Osamu Nakamura |
0:813a237f1c50 | 195 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 196 | |
Osamu Nakamura |
0:813a237f1c50 | 197 | if ( inDataSize <= 0 ) return 0; |
Osamu Nakamura |
0:813a237f1c50 | 198 | |
Osamu Nakamura |
0:813a237f1c50 | 199 | /* Receive data */ |
Osamu Nakamura |
0:813a237f1c50 | 200 | ret = UART_ReceiveData(inTimeOutTime, inDataSize, outResult); |
Osamu Nakamura |
0:813a237f1c50 | 201 | if(ret != inDataSize){ |
Osamu Nakamura |
0:813a237f1c50 | 202 | return HVC_ERROR_DATA_TIMEOUT; |
Osamu Nakamura |
0:813a237f1c50 | 203 | } |
Osamu Nakamura |
0:813a237f1c50 | 204 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 205 | } |
Osamu Nakamura |
0:813a237f1c50 | 206 | |
Osamu Nakamura |
0:813a237f1c50 | 207 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 208 | /* HVC_GetVersion */ |
Osamu Nakamura |
0:813a237f1c50 | 209 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 210 | /* : HVC_VERSION *outVersion version data */ |
Osamu Nakamura |
0:813a237f1c50 | 211 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 212 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 213 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 214 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 215 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 216 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 217 | INT32 HVC_GetVersion(INT32 inTimeOutTime, HVC_VERSION *outVersion, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 218 | { |
Osamu Nakamura |
0:813a237f1c50 | 219 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 220 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 221 | |
Osamu Nakamura |
0:813a237f1c50 | 222 | if((NULL == outVersion) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 223 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 224 | } |
Osamu Nakamura |
0:813a237f1c50 | 225 | |
Osamu Nakamura |
0:813a237f1c50 | 226 | /* Send GetVersion command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 227 | ret = HVC_SendCommand(HVC_COM_GET_VERSION, 0, NULL); |
Osamu Nakamura |
0:813a237f1c50 | 228 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 229 | |
Osamu Nakamura |
0:813a237f1c50 | 230 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 231 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 232 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 233 | |
Osamu Nakamura |
0:813a237f1c50 | 234 | if ( size > (INT32)sizeof(HVC_VERSION) ) { |
Osamu Nakamura |
0:813a237f1c50 | 235 | size = sizeof(HVC_VERSION); |
Osamu Nakamura |
0:813a237f1c50 | 236 | } |
Osamu Nakamura |
0:813a237f1c50 | 237 | |
Osamu Nakamura |
0:813a237f1c50 | 238 | /* Receive data */ |
Osamu Nakamura |
0:813a237f1c50 | 239 | return HVC_ReceiveData(inTimeOutTime, size, (UINT8*)outVersion); |
Osamu Nakamura |
0:813a237f1c50 | 240 | } |
Osamu Nakamura |
0:813a237f1c50 | 241 | |
Osamu Nakamura |
0:813a237f1c50 | 242 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 243 | /* HVC_SetCameraAngle */ |
Osamu Nakamura |
0:813a237f1c50 | 244 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 245 | /* : INT32 inAngleNo camera angle number */ |
Osamu Nakamura |
0:813a237f1c50 | 246 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 247 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 248 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 249 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 250 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 251 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 252 | INT32 HVC_SetCameraAngle(INT32 inTimeOutTime, INT32 inAngleNo, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 253 | { |
Osamu Nakamura |
0:813a237f1c50 | 254 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 255 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 256 | UINT8 sendData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 257 | |
Osamu Nakamura |
0:813a237f1c50 | 258 | if(NULL == outStatus){ |
Osamu Nakamura |
0:813a237f1c50 | 259 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 260 | } |
Osamu Nakamura |
0:813a237f1c50 | 261 | |
Osamu Nakamura |
0:813a237f1c50 | 262 | sendData[0] = (UINT8)(inAngleNo&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 263 | /* Send SetCameraAngle command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 264 | ret = HVC_SendCommand(HVC_COM_SET_CAMERA_ANGLE, sizeof(UINT8), sendData); |
Osamu Nakamura |
0:813a237f1c50 | 265 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 266 | |
Osamu Nakamura |
0:813a237f1c50 | 267 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 268 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 269 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 270 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 271 | } |
Osamu Nakamura |
0:813a237f1c50 | 272 | |
Osamu Nakamura |
0:813a237f1c50 | 273 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 274 | /* HVC_GetCameraAngle */ |
Osamu Nakamura |
0:813a237f1c50 | 275 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 276 | /* : INT32 *outAngleNo camera angle number */ |
Osamu Nakamura |
0:813a237f1c50 | 277 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 278 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 279 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 280 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 281 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 282 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 283 | INT32 HVC_GetCameraAngle(INT32 inTimeOutTime, INT32 *outAngleNo, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 284 | { |
Osamu Nakamura |
0:813a237f1c50 | 285 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 286 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 287 | UINT8 recvData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 288 | |
Osamu Nakamura |
0:813a237f1c50 | 289 | if((NULL == outAngleNo) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 290 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 291 | } |
Osamu Nakamura |
0:813a237f1c50 | 292 | |
Osamu Nakamura |
0:813a237f1c50 | 293 | /* Send GetCameraAngle command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 294 | ret = HVC_SendCommand(HVC_COM_GET_CAMERA_ANGLE, 0, NULL); |
Osamu Nakamura |
0:813a237f1c50 | 295 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 296 | |
Osamu Nakamura |
0:813a237f1c50 | 297 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 298 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 299 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 300 | |
Osamu Nakamura |
0:813a237f1c50 | 301 | if ( size > (INT32)sizeof(UINT8) ) { |
Osamu Nakamura |
0:813a237f1c50 | 302 | size = sizeof(UINT8); |
Osamu Nakamura |
0:813a237f1c50 | 303 | } |
Osamu Nakamura |
0:813a237f1c50 | 304 | |
Osamu Nakamura |
0:813a237f1c50 | 305 | /* Receive data */ |
Osamu Nakamura |
0:813a237f1c50 | 306 | ret = HVC_ReceiveData(inTimeOutTime, size, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 307 | *outAngleNo = recvData[0]; |
Osamu Nakamura |
0:813a237f1c50 | 308 | return ret; |
Osamu Nakamura |
0:813a237f1c50 | 309 | } |
Osamu Nakamura |
0:813a237f1c50 | 310 | |
Osamu Nakamura |
0:813a237f1c50 | 311 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 312 | /* HVC_Execute */ |
Osamu Nakamura |
0:813a237f1c50 | 313 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 314 | /* : INT32 inExec executable function */ |
Osamu Nakamura |
0:813a237f1c50 | 315 | /* : INT32 inImage image info */ |
Osamu Nakamura |
0:813a237f1c50 | 316 | /* : HVC_RESULT *outHVCResult result data */ |
Osamu Nakamura |
0:813a237f1c50 | 317 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 318 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 319 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 320 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 321 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 322 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 323 | INT32 HVC_Execute(INT32 inTimeOutTime, INT32 inExec, INT32 inImage, HVC_RESULT *outHVCResult, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 324 | { |
Osamu Nakamura |
0:813a237f1c50 | 325 | int i; |
Osamu Nakamura |
0:813a237f1c50 | 326 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 327 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 328 | UINT8 sendData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 329 | UINT8 recvData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 330 | |
Osamu Nakamura |
0:813a237f1c50 | 331 | if((NULL == outHVCResult) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 332 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 333 | } |
Osamu Nakamura |
0:813a237f1c50 | 334 | |
Osamu Nakamura |
0:813a237f1c50 | 335 | /* Send Execute command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 336 | sendData[0] = (UINT8)(inExec&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 337 | sendData[1] = (UINT8)((inExec>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 338 | sendData[2] = (UINT8)(inImage&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 339 | ret = HVC_SendCommand(HVC_COM_EXECUTE, sizeof(UINT8)*3, sendData); |
Osamu Nakamura |
0:813a237f1c50 | 340 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 341 | |
Osamu Nakamura |
0:813a237f1c50 | 342 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 343 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 344 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 345 | |
Osamu Nakamura |
0:813a237f1c50 | 346 | /* Receive result data */ |
Osamu Nakamura |
0:813a237f1c50 | 347 | if ( size >= (INT32)sizeof(UINT8)*4 ) { |
Osamu Nakamura |
0:813a237f1c50 | 348 | outHVCResult->executedFunc = inExec; |
Osamu Nakamura |
0:813a237f1c50 | 349 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 350 | outHVCResult->bdResult.num = recvData[0]; |
Osamu Nakamura |
0:813a237f1c50 | 351 | outHVCResult->hdResult.num = recvData[1]; |
Osamu Nakamura |
0:813a237f1c50 | 352 | outHVCResult->fdResult.num = recvData[2]; |
Osamu Nakamura |
0:813a237f1c50 | 353 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 354 | size -= sizeof(UINT8)*4; |
Osamu Nakamura |
0:813a237f1c50 | 355 | } |
Osamu Nakamura |
0:813a237f1c50 | 356 | |
Osamu Nakamura |
0:813a237f1c50 | 357 | /* Get Human Body Detection result */ |
Osamu Nakamura |
0:813a237f1c50 | 358 | for(i = 0; i < outHVCResult->bdResult.num; i++){ |
Osamu Nakamura |
0:813a237f1c50 | 359 | if ( size >= (INT32)sizeof(UINT8)*8 ) { |
Osamu Nakamura |
0:813a237f1c50 | 360 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 361 | outHVCResult->bdResult.bdResult[i].posX = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 362 | outHVCResult->bdResult.bdResult[i].posY = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 363 | outHVCResult->bdResult.bdResult[i].size = (short)(recvData[4] + (recvData[5]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 364 | outHVCResult->bdResult.bdResult[i].confidence = (short)(recvData[6] + (recvData[7]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 365 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 366 | size -= sizeof(UINT8)*8; |
Osamu Nakamura |
0:813a237f1c50 | 367 | } |
Osamu Nakamura |
0:813a237f1c50 | 368 | } |
Osamu Nakamura |
0:813a237f1c50 | 369 | |
Osamu Nakamura |
0:813a237f1c50 | 370 | /* Get Hand Detection result */ |
Osamu Nakamura |
0:813a237f1c50 | 371 | for(i = 0; i < outHVCResult->hdResult.num; i++){ |
Osamu Nakamura |
0:813a237f1c50 | 372 | if ( size >= (INT32)sizeof(UINT8)*8 ) { |
Osamu Nakamura |
0:813a237f1c50 | 373 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 374 | outHVCResult->hdResult.hdResult[i].posX = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 375 | outHVCResult->hdResult.hdResult[i].posY = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 376 | outHVCResult->hdResult.hdResult[i].size = (short)(recvData[4] + (recvData[5]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 377 | outHVCResult->hdResult.hdResult[i].confidence = (short)(recvData[6] + (recvData[7]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 378 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 379 | size -= sizeof(UINT8)*8; |
Osamu Nakamura |
0:813a237f1c50 | 380 | } |
Osamu Nakamura |
0:813a237f1c50 | 381 | } |
Osamu Nakamura |
0:813a237f1c50 | 382 | |
Osamu Nakamura |
0:813a237f1c50 | 383 | /* Face-related results */ |
Osamu Nakamura |
0:813a237f1c50 | 384 | for(i = 0; i < outHVCResult->fdResult.num; i++){ |
Osamu Nakamura |
0:813a237f1c50 | 385 | /* Face Detection result */ |
Osamu Nakamura |
0:813a237f1c50 | 386 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_DETECTION)){ |
Osamu Nakamura |
0:813a237f1c50 | 387 | if ( size >= (INT32)sizeof(UINT8)*8 ) { |
Osamu Nakamura |
0:813a237f1c50 | 388 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 389 | outHVCResult->fdResult.fcResult[i].dtResult.posX = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 390 | outHVCResult->fdResult.fcResult[i].dtResult.posY = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 391 | outHVCResult->fdResult.fcResult[i].dtResult.size = (short)(recvData[4] + (recvData[5]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 392 | outHVCResult->fdResult.fcResult[i].dtResult.confidence = (short)(recvData[6] + (recvData[7]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 393 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 394 | size -= sizeof(UINT8)*8; |
Osamu Nakamura |
0:813a237f1c50 | 395 | } |
Osamu Nakamura |
0:813a237f1c50 | 396 | } |
Osamu Nakamura |
0:813a237f1c50 | 397 | |
Osamu Nakamura |
0:813a237f1c50 | 398 | /* Face direction */ |
Osamu Nakamura |
0:813a237f1c50 | 399 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_DIRECTION)){ |
Osamu Nakamura |
0:813a237f1c50 | 400 | if ( size >= (INT32)sizeof(UINT8)*8 ) { |
Osamu Nakamura |
0:813a237f1c50 | 401 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 402 | outHVCResult->fdResult.fcResult[i].dirResult.yaw = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 403 | outHVCResult->fdResult.fcResult[i].dirResult.pitch = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 404 | outHVCResult->fdResult.fcResult[i].dirResult.roll = (short)(recvData[4] + (recvData[5]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 405 | outHVCResult->fdResult.fcResult[i].dirResult.confidence = (short)(recvData[6] + (recvData[7]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 406 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 407 | size -= sizeof(UINT8)*8; |
Osamu Nakamura |
0:813a237f1c50 | 408 | } |
Osamu Nakamura |
0:813a237f1c50 | 409 | } |
Osamu Nakamura |
0:813a237f1c50 | 410 | |
Osamu Nakamura |
0:813a237f1c50 | 411 | /* Age */ |
Osamu Nakamura |
0:813a237f1c50 | 412 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_AGE_ESTIMATION)){ |
Osamu Nakamura |
0:813a237f1c50 | 413 | if ( size >= (INT32)sizeof(UINT8)*3 ) { |
Osamu Nakamura |
0:813a237f1c50 | 414 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*3, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 415 | outHVCResult->fdResult.fcResult[i].ageResult.age = (char)(recvData[0]); |
Osamu Nakamura |
0:813a237f1c50 | 416 | outHVCResult->fdResult.fcResult[i].ageResult.confidence = (short)(recvData[1] + (recvData[2]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 417 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 418 | size -= sizeof(UINT8)*3; |
Osamu Nakamura |
0:813a237f1c50 | 419 | } |
Osamu Nakamura |
0:813a237f1c50 | 420 | } |
Osamu Nakamura |
0:813a237f1c50 | 421 | |
Osamu Nakamura |
0:813a237f1c50 | 422 | /* Gender */ |
Osamu Nakamura |
0:813a237f1c50 | 423 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_GENDER_ESTIMATION)){ |
Osamu Nakamura |
0:813a237f1c50 | 424 | if ( size >= (INT32)sizeof(UINT8)*3 ) { |
Osamu Nakamura |
0:813a237f1c50 | 425 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*3, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 426 | outHVCResult->fdResult.fcResult[i].genderResult.gender = (char)(recvData[0]); |
Osamu Nakamura |
0:813a237f1c50 | 427 | outHVCResult->fdResult.fcResult[i].genderResult.confidence = (short)(recvData[1] + (recvData[2]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 428 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 429 | size -= sizeof(UINT8)*3; |
Osamu Nakamura |
0:813a237f1c50 | 430 | } |
Osamu Nakamura |
0:813a237f1c50 | 431 | } |
Osamu Nakamura |
0:813a237f1c50 | 432 | |
Osamu Nakamura |
0:813a237f1c50 | 433 | /* Gaze */ |
Osamu Nakamura |
0:813a237f1c50 | 434 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_GAZE_ESTIMATION)){ |
Osamu Nakamura |
0:813a237f1c50 | 435 | if ( size >= (INT32)sizeof(UINT8)*2 ) { |
Osamu Nakamura |
0:813a237f1c50 | 436 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*2, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 437 | outHVCResult->fdResult.fcResult[i].gazeResult.gazeLR = (char)(recvData[0]); |
Osamu Nakamura |
0:813a237f1c50 | 438 | outHVCResult->fdResult.fcResult[i].gazeResult.gazeUD = (char)(recvData[1]); |
Osamu Nakamura |
0:813a237f1c50 | 439 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 440 | size -= sizeof(UINT8)*2; |
Osamu Nakamura |
0:813a237f1c50 | 441 | } |
Osamu Nakamura |
0:813a237f1c50 | 442 | } |
Osamu Nakamura |
0:813a237f1c50 | 443 | |
Osamu Nakamura |
0:813a237f1c50 | 444 | /* Blink */ |
Osamu Nakamura |
0:813a237f1c50 | 445 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_BLINK_ESTIMATION)){ |
Osamu Nakamura |
0:813a237f1c50 | 446 | if ( size >= (INT32)sizeof(UINT8)*4 ) { |
Osamu Nakamura |
0:813a237f1c50 | 447 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 448 | outHVCResult->fdResult.fcResult[i].blinkResult.ratioL = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 449 | outHVCResult->fdResult.fcResult[i].blinkResult.ratioR = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 450 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 451 | size -= sizeof(UINT8)*4; |
Osamu Nakamura |
0:813a237f1c50 | 452 | } |
Osamu Nakamura |
0:813a237f1c50 | 453 | } |
Osamu Nakamura |
0:813a237f1c50 | 454 | |
Osamu Nakamura |
0:813a237f1c50 | 455 | /* Expression */ |
Osamu Nakamura |
0:813a237f1c50 | 456 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_EXPRESSION_ESTIMATION)){ |
Osamu Nakamura |
0:813a237f1c50 | 457 | if ( size >= (INT32)sizeof(UINT8)*3 ) { |
Osamu Nakamura |
0:813a237f1c50 | 458 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*3, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 459 | outHVCResult->fdResult.fcResult[i].expressionResult.topExpression = (char)(recvData[0]); |
Osamu Nakamura |
0:813a237f1c50 | 460 | outHVCResult->fdResult.fcResult[i].expressionResult.topScore = (char)(recvData[1]); |
Osamu Nakamura |
0:813a237f1c50 | 461 | outHVCResult->fdResult.fcResult[i].expressionResult.degree = (char)(recvData[2]); |
Osamu Nakamura |
0:813a237f1c50 | 462 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 463 | size -= sizeof(UINT8)*3; |
Osamu Nakamura |
0:813a237f1c50 | 464 | } |
Osamu Nakamura |
0:813a237f1c50 | 465 | } |
Osamu Nakamura |
0:813a237f1c50 | 466 | |
Osamu Nakamura |
0:813a237f1c50 | 467 | /* Face Recognition */ |
Osamu Nakamura |
0:813a237f1c50 | 468 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_RECOGNITION)){ |
Osamu Nakamura |
0:813a237f1c50 | 469 | if ( size >= (INT32)sizeof(UINT8)*4 ) { |
Osamu Nakamura |
0:813a237f1c50 | 470 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 471 | outHVCResult->fdResult.fcResult[i].recognitionResult.uid = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 472 | outHVCResult->fdResult.fcResult[i].recognitionResult.confidence = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 473 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 474 | size -= sizeof(UINT8)*4; |
Osamu Nakamura |
0:813a237f1c50 | 475 | } |
Osamu Nakamura |
0:813a237f1c50 | 476 | } |
Osamu Nakamura |
0:813a237f1c50 | 477 | } |
Osamu Nakamura |
0:813a237f1c50 | 478 | |
Osamu Nakamura |
0:813a237f1c50 | 479 | if(HVC_EXECUTE_IMAGE_NONE != inImage){ |
Osamu Nakamura |
0:813a237f1c50 | 480 | /* Image data */ |
Osamu Nakamura |
0:813a237f1c50 | 481 | if ( size >= (INT32)sizeof(UINT8)*4 ) { |
Osamu Nakamura |
0:813a237f1c50 | 482 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 483 | outHVCResult->image.width = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 484 | outHVCResult->image.height = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 485 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 486 | size -= sizeof(UINT8)*4; |
Osamu Nakamura |
0:813a237f1c50 | 487 | } |
Osamu Nakamura |
0:813a237f1c50 | 488 | |
Osamu Nakamura |
0:813a237f1c50 | 489 | if ( size >= (INT32)sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height ) { |
Osamu Nakamura |
0:813a237f1c50 | 490 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height, outHVCResult->image.image); |
Osamu Nakamura |
0:813a237f1c50 | 491 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 492 | size -= sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height; |
Osamu Nakamura |
0:813a237f1c50 | 493 | } |
Osamu Nakamura |
0:813a237f1c50 | 494 | } |
Osamu Nakamura |
0:813a237f1c50 | 495 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 496 | } |
Osamu Nakamura |
0:813a237f1c50 | 497 | |
Osamu Nakamura |
0:813a237f1c50 | 498 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 499 | /* HVC_ExecuteEx */ |
Osamu Nakamura |
0:813a237f1c50 | 500 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 501 | /* : INT32 inExec executable function */ |
Osamu Nakamura |
0:813a237f1c50 | 502 | /* : INT32 inImage image info */ |
Osamu Nakamura |
0:813a237f1c50 | 503 | /* : HVC_RESULT *outHVCResult result data */ |
Osamu Nakamura |
0:813a237f1c50 | 504 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 505 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 506 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 507 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 508 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 509 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 510 | INT32 HVC_ExecuteEx(INT32 inTimeOutTime, INT32 inExec, INT32 inImage, HVC_RESULT *outHVCResult, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 511 | { |
Osamu Nakamura |
0:813a237f1c50 | 512 | int i, j; |
Osamu Nakamura |
0:813a237f1c50 | 513 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 514 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 515 | UINT8 sendData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 516 | UINT8 recvData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 517 | |
Osamu Nakamura |
0:813a237f1c50 | 518 | if((NULL == outHVCResult) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 519 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 520 | } |
Osamu Nakamura |
0:813a237f1c50 | 521 | |
Osamu Nakamura |
0:813a237f1c50 | 522 | /* Send Execute command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 523 | sendData[0] = (UINT8)(inExec&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 524 | sendData[1] = (UINT8)((inExec>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 525 | sendData[2] = (UINT8)(inImage&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 526 | ret = HVC_SendCommand(HVC_COM_EXECUTEEX, sizeof(UINT8)*3, sendData); |
Osamu Nakamura |
0:813a237f1c50 | 527 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 528 | |
Osamu Nakamura |
0:813a237f1c50 | 529 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 530 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 531 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 532 | |
Osamu Nakamura |
0:813a237f1c50 | 533 | /* Receive result data */ |
Osamu Nakamura |
0:813a237f1c50 | 534 | if ( size >= (INT32)sizeof(UINT8)*4 ) { |
Osamu Nakamura |
0:813a237f1c50 | 535 | outHVCResult->executedFunc = inExec; |
Osamu Nakamura |
0:813a237f1c50 | 536 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 537 | outHVCResult->bdResult.num = recvData[0]; |
Osamu Nakamura |
0:813a237f1c50 | 538 | outHVCResult->hdResult.num = recvData[1]; |
Osamu Nakamura |
0:813a237f1c50 | 539 | outHVCResult->fdResult.num = recvData[2]; |
Osamu Nakamura |
0:813a237f1c50 | 540 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 541 | size -= sizeof(UINT8)*4; |
Osamu Nakamura |
0:813a237f1c50 | 542 | } |
Osamu Nakamura |
0:813a237f1c50 | 543 | |
Osamu Nakamura |
0:813a237f1c50 | 544 | /* Get Human Body Detection result */ |
Osamu Nakamura |
0:813a237f1c50 | 545 | for(i = 0; i < outHVCResult->bdResult.num; i++){ |
Osamu Nakamura |
0:813a237f1c50 | 546 | if ( size >= (INT32)sizeof(UINT8)*8 ) { |
Osamu Nakamura |
0:813a237f1c50 | 547 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 548 | outHVCResult->bdResult.bdResult[i].posX = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 549 | outHVCResult->bdResult.bdResult[i].posY = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 550 | outHVCResult->bdResult.bdResult[i].size = (short)(recvData[4] + (recvData[5]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 551 | outHVCResult->bdResult.bdResult[i].confidence = (short)(recvData[6] + (recvData[7]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 552 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 553 | size -= sizeof(UINT8)*8; |
Osamu Nakamura |
0:813a237f1c50 | 554 | } |
Osamu Nakamura |
0:813a237f1c50 | 555 | } |
Osamu Nakamura |
0:813a237f1c50 | 556 | |
Osamu Nakamura |
0:813a237f1c50 | 557 | /* Get Hand Detection result */ |
Osamu Nakamura |
0:813a237f1c50 | 558 | for(i = 0; i < outHVCResult->hdResult.num; i++){ |
Osamu Nakamura |
0:813a237f1c50 | 559 | if ( size >= (INT32)sizeof(UINT8)*8 ) { |
Osamu Nakamura |
0:813a237f1c50 | 560 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 561 | outHVCResult->hdResult.hdResult[i].posX = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 562 | outHVCResult->hdResult.hdResult[i].posY = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 563 | outHVCResult->hdResult.hdResult[i].size = (short)(recvData[4] + (recvData[5]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 564 | outHVCResult->hdResult.hdResult[i].confidence = (short)(recvData[6] + (recvData[7]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 565 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 566 | size -= sizeof(UINT8)*8; |
Osamu Nakamura |
0:813a237f1c50 | 567 | } |
Osamu Nakamura |
0:813a237f1c50 | 568 | } |
Osamu Nakamura |
0:813a237f1c50 | 569 | |
Osamu Nakamura |
0:813a237f1c50 | 570 | /* Face-related results */ |
Osamu Nakamura |
0:813a237f1c50 | 571 | for(i = 0; i < outHVCResult->fdResult.num; i++){ |
Osamu Nakamura |
0:813a237f1c50 | 572 | /* Face Detection result */ |
Osamu Nakamura |
0:813a237f1c50 | 573 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_DETECTION)){ |
Osamu Nakamura |
0:813a237f1c50 | 574 | if ( size >= (INT32)sizeof(UINT8)*8 ) { |
Osamu Nakamura |
0:813a237f1c50 | 575 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 576 | outHVCResult->fdResult.fcResult[i].dtResult.posX = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 577 | outHVCResult->fdResult.fcResult[i].dtResult.posY = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 578 | outHVCResult->fdResult.fcResult[i].dtResult.size = (short)(recvData[4] + (recvData[5]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 579 | outHVCResult->fdResult.fcResult[i].dtResult.confidence = (short)(recvData[6] + (recvData[7]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 580 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 581 | size -= sizeof(UINT8)*8; |
Osamu Nakamura |
0:813a237f1c50 | 582 | } |
Osamu Nakamura |
0:813a237f1c50 | 583 | } |
Osamu Nakamura |
0:813a237f1c50 | 584 | |
Osamu Nakamura |
0:813a237f1c50 | 585 | /* Face direction */ |
Osamu Nakamura |
0:813a237f1c50 | 586 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_DIRECTION)){ |
Osamu Nakamura |
0:813a237f1c50 | 587 | if ( size >= (INT32)sizeof(UINT8)*8 ) { |
Osamu Nakamura |
0:813a237f1c50 | 588 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*8, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 589 | outHVCResult->fdResult.fcResult[i].dirResult.yaw = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 590 | outHVCResult->fdResult.fcResult[i].dirResult.pitch = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 591 | outHVCResult->fdResult.fcResult[i].dirResult.roll = (short)(recvData[4] + (recvData[5]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 592 | outHVCResult->fdResult.fcResult[i].dirResult.confidence = (short)(recvData[6] + (recvData[7]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 593 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 594 | size -= sizeof(UINT8)*8; |
Osamu Nakamura |
0:813a237f1c50 | 595 | } |
Osamu Nakamura |
0:813a237f1c50 | 596 | } |
Osamu Nakamura |
0:813a237f1c50 | 597 | |
Osamu Nakamura |
0:813a237f1c50 | 598 | /* Age */ |
Osamu Nakamura |
0:813a237f1c50 | 599 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_AGE_ESTIMATION)){ |
Osamu Nakamura |
0:813a237f1c50 | 600 | if ( size >= (INT32)sizeof(UINT8)*3 ) { |
Osamu Nakamura |
0:813a237f1c50 | 601 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*3, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 602 | outHVCResult->fdResult.fcResult[i].ageResult.age = (char)(recvData[0]); |
Osamu Nakamura |
0:813a237f1c50 | 603 | outHVCResult->fdResult.fcResult[i].ageResult.confidence = (short)(recvData[1] + (recvData[2]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 604 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 605 | size -= sizeof(UINT8)*3; |
Osamu Nakamura |
0:813a237f1c50 | 606 | } |
Osamu Nakamura |
0:813a237f1c50 | 607 | } |
Osamu Nakamura |
0:813a237f1c50 | 608 | |
Osamu Nakamura |
0:813a237f1c50 | 609 | /* Gender */ |
Osamu Nakamura |
0:813a237f1c50 | 610 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_GENDER_ESTIMATION)){ |
Osamu Nakamura |
0:813a237f1c50 | 611 | if ( size >= (INT32)sizeof(UINT8)*3 ) { |
Osamu Nakamura |
0:813a237f1c50 | 612 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*3, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 613 | outHVCResult->fdResult.fcResult[i].genderResult.gender = (char)(recvData[0]); |
Osamu Nakamura |
0:813a237f1c50 | 614 | outHVCResult->fdResult.fcResult[i].genderResult.confidence = (short)(recvData[1] + (recvData[2]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 615 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 616 | size -= sizeof(UINT8)*3; |
Osamu Nakamura |
0:813a237f1c50 | 617 | } |
Osamu Nakamura |
0:813a237f1c50 | 618 | } |
Osamu Nakamura |
0:813a237f1c50 | 619 | |
Osamu Nakamura |
0:813a237f1c50 | 620 | /* Gaze */ |
Osamu Nakamura |
0:813a237f1c50 | 621 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_GAZE_ESTIMATION)){ |
Osamu Nakamura |
0:813a237f1c50 | 622 | if ( size >= (INT32)sizeof(UINT8)*2 ) { |
Osamu Nakamura |
0:813a237f1c50 | 623 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*2, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 624 | outHVCResult->fdResult.fcResult[i].gazeResult.gazeLR = (char)(recvData[0]); |
Osamu Nakamura |
0:813a237f1c50 | 625 | outHVCResult->fdResult.fcResult[i].gazeResult.gazeUD = (char)(recvData[1]); |
Osamu Nakamura |
0:813a237f1c50 | 626 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 627 | size -= sizeof(UINT8)*2; |
Osamu Nakamura |
0:813a237f1c50 | 628 | } |
Osamu Nakamura |
0:813a237f1c50 | 629 | } |
Osamu Nakamura |
0:813a237f1c50 | 630 | |
Osamu Nakamura |
0:813a237f1c50 | 631 | /* Blink */ |
Osamu Nakamura |
0:813a237f1c50 | 632 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_BLINK_ESTIMATION)){ |
Osamu Nakamura |
0:813a237f1c50 | 633 | if ( size >= (INT32)sizeof(UINT8)*4 ) { |
Osamu Nakamura |
0:813a237f1c50 | 634 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 635 | outHVCResult->fdResult.fcResult[i].blinkResult.ratioL = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 636 | outHVCResult->fdResult.fcResult[i].blinkResult.ratioR = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 637 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 638 | size -= sizeof(UINT8)*4; |
Osamu Nakamura |
0:813a237f1c50 | 639 | } |
Osamu Nakamura |
0:813a237f1c50 | 640 | } |
Osamu Nakamura |
0:813a237f1c50 | 641 | |
Osamu Nakamura |
0:813a237f1c50 | 642 | /* Expression */ |
Osamu Nakamura |
0:813a237f1c50 | 643 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_EXPRESSION_ESTIMATION)){ |
Osamu Nakamura |
0:813a237f1c50 | 644 | if ( size >= (INT32)sizeof(UINT8)*6 ) { |
Osamu Nakamura |
0:813a237f1c50 | 645 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*6, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 646 | outHVCResult->fdResult.fcResult[i].expressionResult.topExpression = -128; |
Osamu Nakamura |
0:813a237f1c50 | 647 | outHVCResult->fdResult.fcResult[i].expressionResult.topScore = -128; |
Osamu Nakamura |
0:813a237f1c50 | 648 | for(j = 0; j < 5; j++){ |
Osamu Nakamura |
0:813a237f1c50 | 649 | outHVCResult->fdResult.fcResult[i].expressionResult.score[j] = (char)(recvData[j]); |
Osamu Nakamura |
0:813a237f1c50 | 650 | if(outHVCResult->fdResult.fcResult[i].expressionResult.topScore < outHVCResult->fdResult.fcResult[i].expressionResult.score[j]){ |
Osamu Nakamura |
0:813a237f1c50 | 651 | outHVCResult->fdResult.fcResult[i].expressionResult.topScore = outHVCResult->fdResult.fcResult[i].expressionResult.score[j]; |
Osamu Nakamura |
0:813a237f1c50 | 652 | outHVCResult->fdResult.fcResult[i].expressionResult.topExpression = j + 1; |
Osamu Nakamura |
0:813a237f1c50 | 653 | } |
Osamu Nakamura |
0:813a237f1c50 | 654 | } |
Osamu Nakamura |
0:813a237f1c50 | 655 | outHVCResult->fdResult.fcResult[i].expressionResult.degree = (char)(recvData[5]); |
Osamu Nakamura |
0:813a237f1c50 | 656 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 657 | size -= sizeof(UINT8)*6; |
Osamu Nakamura |
0:813a237f1c50 | 658 | } |
Osamu Nakamura |
0:813a237f1c50 | 659 | } |
Osamu Nakamura |
0:813a237f1c50 | 660 | |
Osamu Nakamura |
0:813a237f1c50 | 661 | /* Face Recognition */ |
Osamu Nakamura |
0:813a237f1c50 | 662 | if(0 != (outHVCResult->executedFunc & HVC_ACTIV_FACE_RECOGNITION)){ |
Osamu Nakamura |
0:813a237f1c50 | 663 | if ( size >= (INT32)sizeof(UINT8)*4 ) { |
Osamu Nakamura |
0:813a237f1c50 | 664 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 665 | outHVCResult->fdResult.fcResult[i].recognitionResult.uid = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 666 | outHVCResult->fdResult.fcResult[i].recognitionResult.confidence = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 667 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 668 | size -= sizeof(UINT8)*4; |
Osamu Nakamura |
0:813a237f1c50 | 669 | } |
Osamu Nakamura |
0:813a237f1c50 | 670 | } |
Osamu Nakamura |
0:813a237f1c50 | 671 | } |
Osamu Nakamura |
0:813a237f1c50 | 672 | |
Osamu Nakamura |
0:813a237f1c50 | 673 | if(HVC_EXECUTE_IMAGE_NONE != inImage){ |
Osamu Nakamura |
0:813a237f1c50 | 674 | /* Image data */ |
Osamu Nakamura |
0:813a237f1c50 | 675 | if ( size >= (INT32)sizeof(UINT8)*4 ) { |
Osamu Nakamura |
0:813a237f1c50 | 676 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 677 | outHVCResult->image.width = (short)(recvData[0] + (recvData[1]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 678 | outHVCResult->image.height = (short)(recvData[2] + (recvData[3]<<8)); |
Osamu Nakamura |
0:813a237f1c50 | 679 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 680 | size -= sizeof(UINT8)*4; |
Osamu Nakamura |
0:813a237f1c50 | 681 | } |
Osamu Nakamura |
0:813a237f1c50 | 682 | |
Osamu Nakamura |
0:813a237f1c50 | 683 | if ( size >= (INT32)sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height ) { |
Osamu Nakamura |
0:813a237f1c50 | 684 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height, outHVCResult->image.image); |
Osamu Nakamura |
0:813a237f1c50 | 685 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 686 | size -= sizeof(UINT8)*outHVCResult->image.width*outHVCResult->image.height; |
Osamu Nakamura |
0:813a237f1c50 | 687 | } |
Osamu Nakamura |
0:813a237f1c50 | 688 | } |
Osamu Nakamura |
0:813a237f1c50 | 689 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 690 | } |
Osamu Nakamura |
0:813a237f1c50 | 691 | |
Osamu Nakamura |
0:813a237f1c50 | 692 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 693 | /* HVC_SetThreshold */ |
Osamu Nakamura |
0:813a237f1c50 | 694 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 695 | /* : HVC_THRESHOLD *inThreshold threshold values */ |
Osamu Nakamura |
0:813a237f1c50 | 696 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 697 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 698 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 699 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 700 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 701 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 702 | INT32 HVC_SetThreshold(INT32 inTimeOutTime, HVC_THRESHOLD *inThreshold, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 703 | { |
Osamu Nakamura |
0:813a237f1c50 | 704 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 705 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 706 | UINT8 sendData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 707 | |
Osamu Nakamura |
0:813a237f1c50 | 708 | if((NULL == inThreshold) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 709 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 710 | } |
Osamu Nakamura |
0:813a237f1c50 | 711 | |
Osamu Nakamura |
0:813a237f1c50 | 712 | sendData[0] = (UINT8)(inThreshold->bdThreshold&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 713 | sendData[1] = (UINT8)((inThreshold->bdThreshold>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 714 | sendData[2] = (UINT8)(inThreshold->hdThreshold&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 715 | sendData[3] = (UINT8)((inThreshold->hdThreshold>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 716 | sendData[4] = (UINT8)(inThreshold->dtThreshold&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 717 | sendData[5] = (UINT8)((inThreshold->dtThreshold>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 718 | sendData[6] = (UINT8)(inThreshold->rsThreshold&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 719 | sendData[7] = (UINT8)((inThreshold->rsThreshold>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 720 | /* Send SetThreshold command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 721 | ret = HVC_SendCommand(HVC_COM_SET_THRESHOLD, sizeof(UINT8)*8, sendData); |
Osamu Nakamura |
0:813a237f1c50 | 722 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 723 | |
Osamu Nakamura |
0:813a237f1c50 | 724 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 725 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 726 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 727 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 728 | } |
Osamu Nakamura |
0:813a237f1c50 | 729 | |
Osamu Nakamura |
0:813a237f1c50 | 730 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 731 | /* HVC_GetThreshold */ |
Osamu Nakamura |
0:813a237f1c50 | 732 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 733 | /* : HVC_THRESHOLD *outThreshold threshold values */ |
Osamu Nakamura |
0:813a237f1c50 | 734 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 735 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 736 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 737 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 738 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 739 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 740 | INT32 HVC_GetThreshold(INT32 inTimeOutTime, HVC_THRESHOLD *outThreshold, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 741 | { |
Osamu Nakamura |
0:813a237f1c50 | 742 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 743 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 744 | UINT8 recvData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 745 | |
Osamu Nakamura |
0:813a237f1c50 | 746 | if((NULL == outThreshold) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 747 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 748 | } |
Osamu Nakamura |
0:813a237f1c50 | 749 | |
Osamu Nakamura |
0:813a237f1c50 | 750 | /* Send GetThreshold command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 751 | ret = HVC_SendCommand(HVC_COM_GET_THRESHOLD, 0, NULL); |
Osamu Nakamura |
0:813a237f1c50 | 752 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 753 | |
Osamu Nakamura |
0:813a237f1c50 | 754 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 755 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 756 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 757 | |
Osamu Nakamura |
0:813a237f1c50 | 758 | if ( size > (INT32)sizeof(UINT8)*8 ) { |
Osamu Nakamura |
0:813a237f1c50 | 759 | size = sizeof(UINT8)*8; |
Osamu Nakamura |
0:813a237f1c50 | 760 | } |
Osamu Nakamura |
0:813a237f1c50 | 761 | |
Osamu Nakamura |
0:813a237f1c50 | 762 | /* Receive data */ |
Osamu Nakamura |
0:813a237f1c50 | 763 | ret = HVC_ReceiveData(inTimeOutTime, size, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 764 | outThreshold->bdThreshold = recvData[0] + (recvData[1]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 765 | outThreshold->hdThreshold = recvData[2] + (recvData[3]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 766 | outThreshold->dtThreshold = recvData[4] + (recvData[5]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 767 | outThreshold->rsThreshold = recvData[6] + (recvData[7]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 768 | return ret; |
Osamu Nakamura |
0:813a237f1c50 | 769 | } |
Osamu Nakamura |
0:813a237f1c50 | 770 | |
Osamu Nakamura |
0:813a237f1c50 | 771 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 772 | /* HVC_SetSizeRange */ |
Osamu Nakamura |
0:813a237f1c50 | 773 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 774 | /* : HVC_SIZERANGE *inSizeRange detection sizes */ |
Osamu Nakamura |
0:813a237f1c50 | 775 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 776 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 777 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 778 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 779 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 780 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 781 | INT32 HVC_SetSizeRange(INT32 inTimeOutTime, HVC_SIZERANGE *inSizeRange, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 782 | { |
Osamu Nakamura |
0:813a237f1c50 | 783 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 784 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 785 | UINT8 sendData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 786 | |
Osamu Nakamura |
0:813a237f1c50 | 787 | if((NULL == inSizeRange) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 788 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 789 | } |
Osamu Nakamura |
0:813a237f1c50 | 790 | |
Osamu Nakamura |
0:813a237f1c50 | 791 | sendData[0] = (UINT8)(inSizeRange->bdMinSize&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 792 | sendData[1] = (UINT8)((inSizeRange->bdMinSize>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 793 | sendData[2] = (UINT8)(inSizeRange->bdMaxSize&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 794 | sendData[3] = (UINT8)((inSizeRange->bdMaxSize>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 795 | sendData[4] = (UINT8)(inSizeRange->hdMinSize&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 796 | sendData[5] = (UINT8)((inSizeRange->hdMinSize>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 797 | sendData[6] = (UINT8)(inSizeRange->hdMaxSize&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 798 | sendData[7] = (UINT8)((inSizeRange->hdMaxSize>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 799 | sendData[8] = (UINT8)(inSizeRange->dtMinSize&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 800 | sendData[9] = (UINT8)((inSizeRange->dtMinSize>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 801 | sendData[10] = (UINT8)(inSizeRange->dtMaxSize&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 802 | sendData[11] = (UINT8)((inSizeRange->dtMaxSize>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 803 | /* Send SetSizeRange command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 804 | ret = HVC_SendCommand(HVC_COM_SET_SIZE_RANGE, sizeof(UINT8)*12, sendData); |
Osamu Nakamura |
0:813a237f1c50 | 805 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 806 | |
Osamu Nakamura |
0:813a237f1c50 | 807 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 808 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 809 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 810 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 811 | } |
Osamu Nakamura |
0:813a237f1c50 | 812 | |
Osamu Nakamura |
0:813a237f1c50 | 813 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 814 | /* HVC_GetSizeRange */ |
Osamu Nakamura |
0:813a237f1c50 | 815 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 816 | /* : HVC_SIZERANGE *outSizeRange detection sizes */ |
Osamu Nakamura |
0:813a237f1c50 | 817 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 818 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 819 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 820 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 821 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 822 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 823 | INT32 HVC_GetSizeRange(INT32 inTimeOutTime, HVC_SIZERANGE *outSizeRange, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 824 | { |
Osamu Nakamura |
0:813a237f1c50 | 825 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 826 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 827 | UINT8 recvData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 828 | |
Osamu Nakamura |
0:813a237f1c50 | 829 | if((NULL == outSizeRange) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 830 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 831 | } |
Osamu Nakamura |
0:813a237f1c50 | 832 | |
Osamu Nakamura |
0:813a237f1c50 | 833 | /* Send GetSizeRange command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 834 | ret = HVC_SendCommand(HVC_COM_GET_SIZE_RANGE, 0, NULL); |
Osamu Nakamura |
0:813a237f1c50 | 835 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 836 | |
Osamu Nakamura |
0:813a237f1c50 | 837 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 838 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 839 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 840 | |
Osamu Nakamura |
0:813a237f1c50 | 841 | if ( size > (INT32)sizeof(UINT8)*12 ) { |
Osamu Nakamura |
0:813a237f1c50 | 842 | size = sizeof(UINT8)*12; |
Osamu Nakamura |
0:813a237f1c50 | 843 | } |
Osamu Nakamura |
0:813a237f1c50 | 844 | |
Osamu Nakamura |
0:813a237f1c50 | 845 | /* Receive data */ |
Osamu Nakamura |
0:813a237f1c50 | 846 | ret = HVC_ReceiveData(inTimeOutTime, size, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 847 | outSizeRange->bdMinSize = recvData[0] + (recvData[1]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 848 | outSizeRange->bdMaxSize = recvData[2] + (recvData[3]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 849 | outSizeRange->hdMinSize = recvData[4] + (recvData[5]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 850 | outSizeRange->hdMaxSize = recvData[6] + (recvData[7]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 851 | outSizeRange->dtMinSize = recvData[8] + (recvData[9]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 852 | outSizeRange->dtMaxSize = recvData[10] + (recvData[11]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 853 | return ret; |
Osamu Nakamura |
0:813a237f1c50 | 854 | } |
Osamu Nakamura |
0:813a237f1c50 | 855 | |
Osamu Nakamura |
0:813a237f1c50 | 856 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 857 | /* HVC_SetFaceDetectionAngle */ |
Osamu Nakamura |
0:813a237f1c50 | 858 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 859 | /* : INT32 inPose Yaw angle range */ |
Osamu Nakamura |
0:813a237f1c50 | 860 | /* : INT32 inAngle Roll angle range */ |
Osamu Nakamura |
0:813a237f1c50 | 861 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 862 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 863 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 864 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 865 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 866 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 867 | INT32 HVC_SetFaceDetectionAngle(INT32 inTimeOutTime, INT32 inPose, INT32 inAngle, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 868 | { |
Osamu Nakamura |
0:813a237f1c50 | 869 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 870 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 871 | UINT8 sendData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 872 | |
Osamu Nakamura |
0:813a237f1c50 | 873 | if(NULL == outStatus){ |
Osamu Nakamura |
0:813a237f1c50 | 874 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 875 | } |
Osamu Nakamura |
0:813a237f1c50 | 876 | |
Osamu Nakamura |
0:813a237f1c50 | 877 | sendData[0] = (UINT8)(inPose&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 878 | sendData[1] = (UINT8)(inAngle&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 879 | /* Send SetFaceDetectionAngle command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 880 | ret = HVC_SendCommand(HVC_COM_SET_DETECTION_ANGLE, sizeof(UINT8)*2, sendData); |
Osamu Nakamura |
0:813a237f1c50 | 881 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 882 | |
Osamu Nakamura |
0:813a237f1c50 | 883 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 884 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 885 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 886 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 887 | } |
Osamu Nakamura |
0:813a237f1c50 | 888 | |
Osamu Nakamura |
0:813a237f1c50 | 889 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 890 | /* HVC_GetFaceDetectionAngle */ |
Osamu Nakamura |
0:813a237f1c50 | 891 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 892 | /* : INT32 *outPose Yaw angle range */ |
Osamu Nakamura |
0:813a237f1c50 | 893 | /* : INT32 *outAngle Roll angle range */ |
Osamu Nakamura |
0:813a237f1c50 | 894 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 895 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 896 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 897 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 898 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 899 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 900 | INT32 HVC_GetFaceDetectionAngle(INT32 inTimeOutTime, INT32 *outPose, INT32 *outAngle, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 901 | { |
Osamu Nakamura |
0:813a237f1c50 | 902 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 903 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 904 | UINT8 recvData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 905 | |
Osamu Nakamura |
0:813a237f1c50 | 906 | if((NULL == outPose) || (NULL == outAngle) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 907 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 908 | } |
Osamu Nakamura |
0:813a237f1c50 | 909 | |
Osamu Nakamura |
0:813a237f1c50 | 910 | /* Send GetFaceDetectionAngle signal command */ |
Osamu Nakamura |
0:813a237f1c50 | 911 | ret = HVC_SendCommand(HVC_COM_GET_DETECTION_ANGLE, 0, NULL); |
Osamu Nakamura |
0:813a237f1c50 | 912 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 913 | |
Osamu Nakamura |
0:813a237f1c50 | 914 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 915 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 916 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 917 | |
Osamu Nakamura |
0:813a237f1c50 | 918 | if ( size > (INT32)sizeof(UINT8)*2 ) { |
Osamu Nakamura |
0:813a237f1c50 | 919 | size = sizeof(UINT8)*2; |
Osamu Nakamura |
0:813a237f1c50 | 920 | } |
Osamu Nakamura |
0:813a237f1c50 | 921 | |
Osamu Nakamura |
0:813a237f1c50 | 922 | /* Receive data */ |
Osamu Nakamura |
0:813a237f1c50 | 923 | ret = HVC_ReceiveData(inTimeOutTime, size, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 924 | *outPose = recvData[0]; |
Osamu Nakamura |
0:813a237f1c50 | 925 | *outAngle = recvData[1]; |
Osamu Nakamura |
0:813a237f1c50 | 926 | return ret; |
Osamu Nakamura |
0:813a237f1c50 | 927 | } |
Osamu Nakamura |
0:813a237f1c50 | 928 | |
Osamu Nakamura |
0:813a237f1c50 | 929 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 930 | /* HVC_SetBaudRate */ |
Osamu Nakamura |
0:813a237f1c50 | 931 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 932 | /* : INT32 inRate Baudrate */ |
Osamu Nakamura |
0:813a237f1c50 | 933 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 934 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 935 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 936 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 937 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 938 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 939 | INT32 HVC_SetBaudRate(INT32 inTimeOutTime, INT32 inRate, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 940 | { |
Osamu Nakamura |
0:813a237f1c50 | 941 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 942 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 943 | UINT8 sendData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 944 | |
Osamu Nakamura |
0:813a237f1c50 | 945 | if(NULL == outStatus){ |
Osamu Nakamura |
0:813a237f1c50 | 946 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 947 | } |
Osamu Nakamura |
0:813a237f1c50 | 948 | |
Osamu Nakamura |
0:813a237f1c50 | 949 | sendData[0] = (UINT8)(inRate&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 950 | /* Send SetBaudRate command signal */ |
Osamu Nakamura |
0:813a237f1c50 | 951 | ret = HVC_SendCommand(HVC_COM_SET_BAUDRATE, sizeof(UINT8), sendData); |
Osamu Nakamura |
0:813a237f1c50 | 952 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 953 | |
Osamu Nakamura |
0:813a237f1c50 | 954 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 955 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 956 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 957 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 958 | } |
Osamu Nakamura |
0:813a237f1c50 | 959 | |
Osamu Nakamura |
0:813a237f1c50 | 960 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 961 | /* HVC_Registration */ |
Osamu Nakamura |
0:813a237f1c50 | 962 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 963 | /* : INT32 inUserID User ID (0-499) */ |
Osamu Nakamura |
0:813a237f1c50 | 964 | /* : INT32 inDataID Data ID (0-9) */ |
Osamu Nakamura |
0:813a237f1c50 | 965 | /* : HVC_IMAGE *outImage image info */ |
Osamu Nakamura |
0:813a237f1c50 | 966 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 967 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 968 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 969 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 970 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 971 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 972 | INT32 HVC_Registration(INT32 inTimeOutTime, INT32 inUserID, INT32 inDataID, HVC_IMAGE *outImage, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 973 | { |
Osamu Nakamura |
0:813a237f1c50 | 974 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 975 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 976 | UINT8 sendData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 977 | UINT8 recvData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 978 | |
Osamu Nakamura |
0:813a237f1c50 | 979 | if((NULL == outImage) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 980 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 981 | } |
Osamu Nakamura |
0:813a237f1c50 | 982 | |
Osamu Nakamura |
0:813a237f1c50 | 983 | /* Send Registration signal command */ |
Osamu Nakamura |
0:813a237f1c50 | 984 | sendData[0] = (UINT8)(inUserID&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 985 | sendData[1] = (UINT8)((inUserID>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 986 | sendData[2] = (UINT8)(inDataID&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 987 | ret = HVC_SendCommand(HVC_COM_REGISTRATION, sizeof(UINT8)*3, sendData); |
Osamu Nakamura |
0:813a237f1c50 | 988 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 989 | |
Osamu Nakamura |
0:813a237f1c50 | 990 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 991 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 992 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 993 | |
Osamu Nakamura |
0:813a237f1c50 | 994 | /* Receive data */ |
Osamu Nakamura |
0:813a237f1c50 | 995 | if ( size >= (INT32)sizeof(UINT8)*4 ) { |
Osamu Nakamura |
0:813a237f1c50 | 996 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 997 | outImage->width = recvData[0] + (recvData[1]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 998 | outImage->height = recvData[2] + (recvData[3]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 999 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1000 | size -= sizeof(UINT8)*4; |
Osamu Nakamura |
0:813a237f1c50 | 1001 | } |
Osamu Nakamura |
0:813a237f1c50 | 1002 | |
Osamu Nakamura |
0:813a237f1c50 | 1003 | /* Image data */ |
Osamu Nakamura |
0:813a237f1c50 | 1004 | if ( size >= (INT32)sizeof(UINT8)*64*64 ) { |
Osamu Nakamura |
0:813a237f1c50 | 1005 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*64*64, outImage->image); |
Osamu Nakamura |
0:813a237f1c50 | 1006 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1007 | size -= sizeof(UINT8)*64*64; |
Osamu Nakamura |
0:813a237f1c50 | 1008 | } |
Osamu Nakamura |
0:813a237f1c50 | 1009 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 1010 | } |
Osamu Nakamura |
0:813a237f1c50 | 1011 | |
Osamu Nakamura |
0:813a237f1c50 | 1012 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1013 | /* HVC_DeleteData */ |
Osamu Nakamura |
0:813a237f1c50 | 1014 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 1015 | /* : INT32 inUserID User ID (0-499) */ |
Osamu Nakamura |
0:813a237f1c50 | 1016 | /* : INT32 inDataID Data ID (0-9) */ |
Osamu Nakamura |
0:813a237f1c50 | 1017 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 1018 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 1019 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 1020 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 1021 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 1022 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1023 | INT32 HVC_DeleteData(INT32 inTimeOutTime, INT32 inUserID, INT32 inDataID, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 1024 | { |
Osamu Nakamura |
0:813a237f1c50 | 1025 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1026 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1027 | UINT8 sendData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 1028 | |
Osamu Nakamura |
0:813a237f1c50 | 1029 | if(NULL == outStatus){ |
Osamu Nakamura |
0:813a237f1c50 | 1030 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 1031 | } |
Osamu Nakamura |
0:813a237f1c50 | 1032 | |
Osamu Nakamura |
0:813a237f1c50 | 1033 | /* Send Delete Data signal command */ |
Osamu Nakamura |
0:813a237f1c50 | 1034 | sendData[0] = (UINT8)(inUserID&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 1035 | sendData[1] = (UINT8)((inUserID>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 1036 | sendData[2] = (UINT8)(inDataID&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 1037 | ret = HVC_SendCommand(HVC_COM_DELETE_DATA, sizeof(UINT8)*3, sendData); |
Osamu Nakamura |
0:813a237f1c50 | 1038 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1039 | |
Osamu Nakamura |
0:813a237f1c50 | 1040 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 1041 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 1042 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1043 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 1044 | } |
Osamu Nakamura |
0:813a237f1c50 | 1045 | |
Osamu Nakamura |
0:813a237f1c50 | 1046 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1047 | /* HVC_DeleteUser */ |
Osamu Nakamura |
0:813a237f1c50 | 1048 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 1049 | /* : INT32 inUserID User ID (0-499) */ |
Osamu Nakamura |
0:813a237f1c50 | 1050 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 1051 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 1052 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 1053 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 1054 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 1055 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1056 | INT32 HVC_DeleteUser(INT32 inTimeOutTime, INT32 inUserID, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 1057 | { |
Osamu Nakamura |
0:813a237f1c50 | 1058 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1059 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1060 | UINT8 sendData[32]; |
Osamu Nakamura |
0:813a237f1c50 | 1061 | |
Osamu Nakamura |
0:813a237f1c50 | 1062 | if(NULL == outStatus){ |
Osamu Nakamura |
0:813a237f1c50 | 1063 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 1064 | } |
Osamu Nakamura |
0:813a237f1c50 | 1065 | |
Osamu Nakamura |
0:813a237f1c50 | 1066 | /* Send Delete User signal command */ |
Osamu Nakamura |
0:813a237f1c50 | 1067 | sendData[0] = (UINT8)(inUserID&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 1068 | sendData[1] = (UINT8)((inUserID>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 1069 | ret = HVC_SendCommand(HVC_COM_DELETE_USER, sizeof(UINT8)*2, sendData); |
Osamu Nakamura |
0:813a237f1c50 | 1070 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1071 | |
Osamu Nakamura |
0:813a237f1c50 | 1072 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 1073 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 1074 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1075 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 1076 | } |
Osamu Nakamura |
0:813a237f1c50 | 1077 | |
Osamu Nakamura |
0:813a237f1c50 | 1078 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1079 | /* HVC_DeleteAll */ |
Osamu Nakamura |
0:813a237f1c50 | 1080 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 1081 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 1082 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 1083 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 1084 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 1085 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 1086 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1087 | INT32 HVC_DeleteAll(INT32 inTimeOutTime, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 1088 | { |
Osamu Nakamura |
0:813a237f1c50 | 1089 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1090 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1091 | |
Osamu Nakamura |
0:813a237f1c50 | 1092 | if(NULL == outStatus){ |
Osamu Nakamura |
0:813a237f1c50 | 1093 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 1094 | } |
Osamu Nakamura |
0:813a237f1c50 | 1095 | |
Osamu Nakamura |
0:813a237f1c50 | 1096 | /* Send Delete All signal command */ |
Osamu Nakamura |
0:813a237f1c50 | 1097 | ret = HVC_SendCommand(HVC_COM_DELETE_ALL, 0, NULL); |
Osamu Nakamura |
0:813a237f1c50 | 1098 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1099 | |
Osamu Nakamura |
0:813a237f1c50 | 1100 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 1101 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 1102 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1103 | return 0; |
Osamu Nakamura |
0:813a237f1c50 | 1104 | } |
Osamu Nakamura |
0:813a237f1c50 | 1105 | |
Osamu Nakamura |
0:813a237f1c50 | 1106 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1107 | /* HVC_GetUserData */ |
Osamu Nakamura |
0:813a237f1c50 | 1108 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 1109 | /* : INT32 inUserID User ID (0-499) */ |
Osamu Nakamura |
0:813a237f1c50 | 1110 | /* : INT32 *outDataNo Registration Info */ |
Osamu Nakamura |
0:813a237f1c50 | 1111 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 1112 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 1113 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 1114 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 1115 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 1116 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1117 | INT32 HVC_GetUserData(INT32 inTimeOutTime, INT32 inUserID, INT32 *outDataNo, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 1118 | { |
Osamu Nakamura |
0:813a237f1c50 | 1119 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1120 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1121 | UINT8 sendData[8]; |
Osamu Nakamura |
0:813a237f1c50 | 1122 | UINT8 recvData[8]; |
Osamu Nakamura |
0:813a237f1c50 | 1123 | |
Osamu Nakamura |
0:813a237f1c50 | 1124 | if((NULL == outDataNo) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 1125 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 1126 | } |
Osamu Nakamura |
0:813a237f1c50 | 1127 | |
Osamu Nakamura |
0:813a237f1c50 | 1128 | /* Send Get Registration Info signal command */ |
Osamu Nakamura |
0:813a237f1c50 | 1129 | sendData[0] = (UINT8)(inUserID&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 1130 | sendData[1] = (UINT8)((inUserID>>8)&0xff); |
Osamu Nakamura |
0:813a237f1c50 | 1131 | ret = HVC_SendCommand(HVC_COM_GET_PERSON_DATA, sizeof(UINT8)*2, sendData); |
Osamu Nakamura |
0:813a237f1c50 | 1132 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1133 | |
Osamu Nakamura |
0:813a237f1c50 | 1134 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 1135 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 1136 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1137 | |
Osamu Nakamura |
0:813a237f1c50 | 1138 | if ( size > (INT32)sizeof(UINT8)*2 ) { |
Osamu Nakamura |
0:813a237f1c50 | 1139 | size = sizeof(UINT8)*2; |
Osamu Nakamura |
0:813a237f1c50 | 1140 | } |
Osamu Nakamura |
0:813a237f1c50 | 1141 | |
Osamu Nakamura |
0:813a237f1c50 | 1142 | /* Receive data */ |
Osamu Nakamura |
0:813a237f1c50 | 1143 | ret = HVC_ReceiveData(inTimeOutTime, size, recvData); |
Osamu Nakamura |
0:813a237f1c50 | 1144 | *outDataNo = recvData[0] + (recvData[1]<<8); |
Osamu Nakamura |
0:813a237f1c50 | 1145 | return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1146 | } |
Osamu Nakamura |
0:813a237f1c50 | 1147 | |
Osamu Nakamura |
0:813a237f1c50 | 1148 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1149 | /* HVC_SaveAlbum */ |
Osamu Nakamura |
0:813a237f1c50 | 1150 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 1151 | /* : UINT8 *outAlbumData Album data */ |
Osamu Nakamura |
0:813a237f1c50 | 1152 | /* : INT32 *outAlbumDataSize Album data size */ |
Osamu Nakamura |
0:813a237f1c50 | 1153 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 1154 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 1155 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 1156 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 1157 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 1158 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1159 | INT32 HVC_SaveAlbum(INT32 inTimeOutTime, UINT8 *outAlbumData, INT32 *outAlbumDataSize, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 1160 | { |
Osamu Nakamura |
0:813a237f1c50 | 1161 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1162 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1163 | |
Osamu Nakamura |
0:813a237f1c50 | 1164 | UINT8 *tmpAlbumData = NULL;; |
Osamu Nakamura |
0:813a237f1c50 | 1165 | |
Osamu Nakamura |
0:813a237f1c50 | 1166 | if((NULL == outAlbumData) || (NULL == outAlbumDataSize) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 1167 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 1168 | } |
Osamu Nakamura |
0:813a237f1c50 | 1169 | |
Osamu Nakamura |
0:813a237f1c50 | 1170 | /* Send Save Album signal command */ |
Osamu Nakamura |
0:813a237f1c50 | 1171 | ret = HVC_SendCommand(HVC_COM_SAVE_ALBUM, 0, NULL); |
Osamu Nakamura |
0:813a237f1c50 | 1172 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1173 | |
Osamu Nakamura |
0:813a237f1c50 | 1174 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 1175 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1176 | |
Osamu Nakamura |
0:813a237f1c50 | 1177 | if ( size >= (INT32)sizeof(UINT8)*8 + HVC_ALBUM_SIZE_MIN ) { |
Osamu Nakamura |
0:813a237f1c50 | 1178 | *outAlbumDataSize = size; |
Osamu Nakamura |
0:813a237f1c50 | 1179 | tmpAlbumData = outAlbumData; |
Osamu Nakamura |
0:813a237f1c50 | 1180 | |
Osamu Nakamura |
0:813a237f1c50 | 1181 | do{ |
Osamu Nakamura |
0:813a237f1c50 | 1182 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, tmpAlbumData); |
Osamu Nakamura |
0:813a237f1c50 | 1183 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1184 | tmpAlbumData += sizeof(UINT8)*4; |
Osamu Nakamura |
0:813a237f1c50 | 1185 | |
Osamu Nakamura |
0:813a237f1c50 | 1186 | ret = HVC_ReceiveData(inTimeOutTime, sizeof(UINT8)*4, tmpAlbumData); |
Osamu Nakamura |
0:813a237f1c50 | 1187 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1188 | tmpAlbumData += sizeof(UINT8)*4; |
Osamu Nakamura |
0:813a237f1c50 | 1189 | |
Osamu Nakamura |
0:813a237f1c50 | 1190 | ret = HVC_ReceiveData(inTimeOutTime, size - sizeof(UINT8)*8, tmpAlbumData); |
Osamu Nakamura |
0:813a237f1c50 | 1191 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1192 | }while(0); |
Osamu Nakamura |
0:813a237f1c50 | 1193 | } |
Osamu Nakamura |
0:813a237f1c50 | 1194 | return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1195 | } |
Osamu Nakamura |
0:813a237f1c50 | 1196 | |
Osamu Nakamura |
0:813a237f1c50 | 1197 | |
Osamu Nakamura |
0:813a237f1c50 | 1198 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1199 | /* HVC_LoadAlbum */ |
Osamu Nakamura |
0:813a237f1c50 | 1200 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 1201 | /* : UINT8 *inAlbumData Album data */ |
Osamu Nakamura |
0:813a237f1c50 | 1202 | /* : INT32 inAlbumDataSize Album data size */ |
Osamu Nakamura |
0:813a237f1c50 | 1203 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 1204 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 1205 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 1206 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 1207 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 1208 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1209 | INT32 HVC_LoadAlbum(INT32 inTimeOutTime, UINT8 *inAlbumData, INT32 inAlbumDataSize, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 1210 | { |
Osamu Nakamura |
0:813a237f1c50 | 1211 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1212 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1213 | |
Osamu Nakamura |
0:813a237f1c50 | 1214 | if((NULL == inAlbumData) || (NULL == outStatus)){ |
Osamu Nakamura |
0:813a237f1c50 | 1215 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 1216 | } |
Osamu Nakamura |
0:813a237f1c50 | 1217 | |
Osamu Nakamura |
0:813a237f1c50 | 1218 | /* Send Save Album signal command */ |
Osamu Nakamura |
0:813a237f1c50 | 1219 | ret = HVC_SendCommandOfLoadAlbum(HVC_COM_LOAD_ALBUM, inAlbumDataSize, inAlbumData); |
Osamu Nakamura |
0:813a237f1c50 | 1220 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1221 | |
Osamu Nakamura |
0:813a237f1c50 | 1222 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 1223 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 1224 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1225 | |
Osamu Nakamura |
0:813a237f1c50 | 1226 | return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1227 | } |
Osamu Nakamura |
0:813a237f1c50 | 1228 | |
Osamu Nakamura |
0:813a237f1c50 | 1229 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1230 | /* HVC_WriteAlbum */ |
Osamu Nakamura |
0:813a237f1c50 | 1231 | /* param : INT32 inTimeOutTime timeout time (ms) */ |
Osamu Nakamura |
0:813a237f1c50 | 1232 | /* : UINT8 *outStatus response code */ |
Osamu Nakamura |
0:813a237f1c50 | 1233 | /* return : INT32 execution result error code */ |
Osamu Nakamura |
0:813a237f1c50 | 1234 | /* : 0...normal */ |
Osamu Nakamura |
0:813a237f1c50 | 1235 | /* : -1...parameter error */ |
Osamu Nakamura |
0:813a237f1c50 | 1236 | /* : other...signal error */ |
Osamu Nakamura |
0:813a237f1c50 | 1237 | /*----------------------------------------------------------------------------*/ |
Osamu Nakamura |
0:813a237f1c50 | 1238 | INT32 HVC_WriteAlbum(INT32 inTimeOutTime, UINT8 *outStatus) |
Osamu Nakamura |
0:813a237f1c50 | 1239 | { |
Osamu Nakamura |
0:813a237f1c50 | 1240 | INT32 ret = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1241 | INT32 size = 0; |
Osamu Nakamura |
0:813a237f1c50 | 1242 | |
Osamu Nakamura |
0:813a237f1c50 | 1243 | if(NULL == outStatus){ |
Osamu Nakamura |
0:813a237f1c50 | 1244 | return HVC_ERROR_PARAMETER; |
Osamu Nakamura |
0:813a237f1c50 | 1245 | } |
Osamu Nakamura |
0:813a237f1c50 | 1246 | |
Osamu Nakamura |
0:813a237f1c50 | 1247 | /* Send Write Album signal command */ |
Osamu Nakamura |
0:813a237f1c50 | 1248 | ret = HVC_SendCommand(HVC_COM_WRITE_ALBUM, 0, NULL); |
Osamu Nakamura |
0:813a237f1c50 | 1249 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1250 | |
Osamu Nakamura |
0:813a237f1c50 | 1251 | /* Receive header */ |
Osamu Nakamura |
0:813a237f1c50 | 1252 | ret = HVC_ReceiveHeader(inTimeOutTime, &size, outStatus); |
Osamu Nakamura |
0:813a237f1c50 | 1253 | if ( ret != 0 ) return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1254 | |
Osamu Nakamura |
0:813a237f1c50 | 1255 | return ret; |
Osamu Nakamura |
0:813a237f1c50 | 1256 | } |
Osamu Nakamura |
0:813a237f1c50 | 1257 | |
Osamu Nakamura |
0:813a237f1c50 | 1258 |