ret |= RK_MPI_VI_EnableChn(ViPipe, ViChn);
if (ret) {
printf("Create vi[%d] failed! ret=%d\n",ViPipe, ret);
- return -1;
+ return;
}
ret = RK_MPI_VI_StartStream(ViPipe, ViChn);
if (ret) {
printf("RK_MPI_VI_StartStream [ViChn] failed! ret=%d\n", ret);
- return -1;
+ return;
}
}
if(!gr_info){
printf( "malloc als_info failed \n");
- return -1;
+ return;
}
mg_als_read(gr_ctrl->als_ctrl,gr_info);
//算法识别
static int32_t gr_read_gesture(void)
{
- int32_t ret;
+ int32_t ret = -1;
if(!mg_detectResult)
goto error;
ret = GR_PALM;
break;
default:
+ ret = -1;
break;
}
mg_detectResult = NULL; //清空是为了避免下次读取的是上一次的值
sleep(1);
if(gr_read_gesture() == ev){
if(ev != GR_PALM){
- dp_gesture_event_report(ev);
+ dp_gesture_event_report(ev);
+ printf("上报dp ===================== %d\n",ev);
}
return 0;
}
gr_ctrl_t *p_gr = ( gr_ctrl_t*)param;
+ gr_time = time(NULL);
+
while(!stop){
usleep(1000);
dp_timeout = cfg_recognition_duration_read( p_gr->dev);
-
if(init)
gr_als_t(p_gr);
gr_ring_enable(p_gr->light_ctrl);
sleep(1);
while(!stop){
- usleep(1000);
+ usleep(100*000);
if(time_flasg){
- gr_time = time(NULL) + dp_timeout;
+ gr_time = time(NULL);
time_flasg = 0;
}
- if(time(NULL) >= gr_time){
+
+ dp_timeout = cfg_recognition_duration_read( p_gr->dev);
+ if(time(NULL) - gr_time > dp_timeout){
printf("超时退出\n");
reportdp_and_close_ring_gr(p_gr->light_ctrl);
sleep(1);
gr_als_t(p_gr);
ret = gr_read_gesture();
- if((ret == -1) || (ret == GS_GUN)){
+ if( ret == -1 ){
continue;
}else if(ret == GR_PALM){
if(gr_ai_detect_palm() == 0){
struct timespec ts;
MEDIA_BUFFER mb = NULL;
int ret;
+#if 0
+ time_t now = 0;
+ time_t time_2023 = 0;
+ struct tm tm_2023;
+
+ tm_2023.tm_sec = 0;
+ tm_2023.tm_min = 0;
+ tm_2023.tm_hour = 0;
+ tm_2023.tm_mday = 1;
+ tm_2023.tm_mon = 6;
+ tm_2023.tm_year = 123;
+ tm_2023.tm_wday = 0;
+ tm_2023.tm_yday = 1;
+ tm_2023.tm_isdst= 0;
+
+ time_2023 = mktime( &tm_2023 );
+ while( 1 ){
+ //等待网络时间获取,避免license报错
+ now = time( NULL );
+ if( now > time_2023 ){
+ printf( "------------------wait ntp update, to now [%ld] > [%ld] ......\n",now, time_2023 );
+ break;
+ }
+ sleep(1);
+ printf( "wait ntp update, to now [%ld] > [%ld] ......\n",now, time_2023 );
+ }
+#endif
+retry_for_wait_ntp:
ret=sentime_ai_init();
+ if(ret==-15){
+ printf( "sentime_ai_init fail -15, retry...\n" );
+ sleep(2);
+ goto retry_for_wait_ntp;
+ }
+
if(ret!=0)
{
printf("sentime_ai_init fail! ret=%d\n", ret);
unsigned char *image_data = (unsigned char *)malloc(nv12_buffer_size);
if(image_data==NULL)
- return;
+ return NULL;
STImage detectImage = {0};
//mb = RK_MPI_SYS_GetMediaBuffer(RK_ID_VI, camera_id, -1);
mb = RK_MPI_SYS_GetMediaBuffer(RK_ID_VI, 0, -1);
if (!mb) {
+ usleep(100*1000);
continue;
}
else
mg_als_cfg(gr_ctrl->als_ctrl,threshold_high,threshold_low);
-printf("1 \n");
rk_isp_init(0,"/etc/iqfiles/");
//rk_isp_init(1,"/etc/iqfiles/");
-printf("2 \n");
RK_MPI_SYS_Init();
-printf("3 \n");
rk_vi_init(0,0,ST_AI_IMAGE_W,ST_AI_IMAGE_H);
-printf("4 \n");
//rk_vi_init(1,1,ST_AI_IMAGE_W,ST_AI_IMAGE_H);
rk_vi_setfps(0,15);
//rk_vi_setfps(1,15);
-printf("5 \n");
usleep(100*1000);
if (pthread_create(&th2, NULL, ai_detect, NULL)) {
-#if 0
+
//测试程序
-int main_x(int argc, char *argv[])
+// int main(int argc, char *argv[])
+// {
+// int ret;
+
+// gr_ctrl_t *test = (gr_ctrl_t *)malloc(sizeof(gr_ctrl_t));
+
+// light_ctrl_t ctrl = mg_led_open();
+// if (!ctrl)
+// {
+// printf("led test..., open led failed\n");
+// goto app_ext1;
+// }
+// printf("led test..., open led, ret:%p\n", ctrl);
+// test->light_ctrl = ctrl;
+
+// printf("zzzzz\n");
+
+// signal(SIGINT, sigterm_handler);
+// usleep(100 * 1000);
+
+// ret = gr_register(test, 1000, 400);
+
+// if (ret)
+// {
+// printf("gr_register falied === \n");
+// }
+
+// // sleep(15);
+// // gr_close(test);
+
+// while (!quit)
+// {
+// usleep(100 * 1000);
+// }
+
+// app_ext1:
+// free(test);
+// test = NULL;
+// return -1;
+// }
+
+#if 0
+static gr_ctrl_t gr_ctrl;
+
+extern light_ctrl_t g_led_ctrl;
+extern mg_dev_t g_mg_dev;
+
+int32_t main( void )
{
- int ret;
+ int32_t ret = 0;
+ uint32_t als_th_high = 1000;
+ uint32_t als_th_low = 400;
- gr_ctrl_t *test = (gr_ctrl_t *)malloc(sizeof(gr_ctrl_t));
+ memset( &gr_ctrl, 0, sizeof( gr_ctrl ) );
- light_ctrl_t ctrl = mg_led_open();
- if (!ctrl)
+ g_led_ctrl = mg_led_open();
+ if (!g_led_ctrl)
{
printf("led test..., open led failed\n");
- goto app_ext1;
+ return -1;
}
- printf("led test..., open led, ret:%p\n", ctrl);
- test->light_ctrl = ctrl;
-
- printf("zzzzz\n");
- signal(SIGINT, sigterm_handler);
- usleep(100 * 1000);
+ gr_ctrl.light_ctrl = g_led_ctrl;
+ gr_ctrl.dev = &g_mg_dev;
+ load_als_threshold( &als_th_high, &als_th_low );
- ret = gr_register(test, 1000, 400);
+ signal(SIGINT, sigterm_handler);
+ usleep(100 * 1000);
- if (ret)
- {
- printf("gr_register falied === \n");
- }
+ printf("als_th_high = %d als_th_low = %d\n",als_th_high,als_th_low);
+ ret = gr_register( &gr_ctrl, als_th_high, als_th_low );
- // sleep(15);
- // gr_close(test);
+ if (ret){
+ MG_LOGE("gr_register falied === \n");
+ ret = -1;
+ }
while (!quit)
{
usleep(100 * 1000);
}
-app_ext1:
- free(test);
- test = NULL;
- return -1;
+ return ret;
}
-#else
+#endif
static gr_ctrl_t gr_ctrl;
-static light_ctrl_t als_ctrl;
extern light_ctrl_t g_led_ctrl;
extern mg_dev_t g_mg_dev;
int32_t gesture_recognition_start( void )
{
int32_t ret = 0;
- uint32_t als_th_high;
- uint32_t als_th_low;
+ uint32_t als_th_high = 1000;
+ uint32_t als_th_low = 400;
+
memset( &gr_ctrl, 0, sizeof( gr_ctrl ) );
+ //zf
+ // g_led_ctrl = mg_led_open();
+ // if (!g_led_ctrl)
+ // {
+ // printf("led test..., open led failed\n");
+ // return -1;
+ // }
+ //zf_end
gr_ctrl.light_ctrl = g_led_ctrl;
gr_ctrl.dev = &g_mg_dev;
load_als_threshold( &als_th_high, &als_th_low );
// signal(SIGINT, sigterm_handler);
- // usleep(100 * 1000);
- ret = gr_register( &g_led_ctrl, als_th_high, als_th_low );
+ usleep(100 * 1000);
+
+ //printf("als_th_high = %d als_th_low = %d\n",als_th_high,als_th_low);
+ ret = gr_register( &gr_ctrl, als_th_high, als_th_low );
if (ret){
MG_LOGE("gr_register falied === \n");
return ret;
}
-#endif
-
dur_sec = cfg_led_atmos_off_duration_read( &g_mg_dev );
key_led_on( g_led_ctrl, LED_ID_KEY_ALL&key_mask, 0, 100, dur_sec*1000 );
atmos_led_off( g_led_ctrl, LED_ID_ATMOS_ALL, 100, 0, dur_sec*1000 );
- ring_led_breath( g_led_ctrl, 4000, 10*1000 );
+ //ring_led_breath( g_led_ctrl, 4000, 10*1000 );
break;
case LIGHT_MODE_TOF_DEACTIVE: //
key_led_off( g_led_ctrl, LED_ID_KEY_ALL, 100, 0, dur_sec*1000 );
//atmos_led_on( g_led_ctrl, LED_ID_ATMOS_ALL, 0, 100, 3*1000 );
atmos_led_on( g_led_ctrl, LED_ID_ATMOS_ALL, 0, 100, dur_sec*1000 );
- ring_led_breath( g_led_ctrl, 2000, 0 );
+ //ring_led_breath( g_led_ctrl, 2000, 0 );
break;
}