ImageThread_S *pFaceThread;
	PF_Rect_S viRect;
	Uapi_ExpWin_t expWin;
	HNY_AiFaceRectInfo_S *pAiFaceRectInfo = NULL;
	char threadName[64];
	char *pBuf = NULL;
	int i, id, faceRect, width, height, ret, cnt = 0;
	PF_Rect_S stRect = {0};

	sprintf(threadName, "FaceFnc");
	prctl(PR_SET_NAME, (unsigned long)threadName, 0, 0, 0);
	pBuf = (char *)malloc(sizeof(HNY_FrameHeader_S) + sizeof(HNY_AiFaceRectInfo_S));
	if(pBuf == NULL)
	{
		DEBUG_ERROR(MODULE_CODEC, "Call malloc func err!");
		return NULL;
	}

	memset(&viRect, 0x0, sizeof(PF_Rect_S));
	VC_GetViRect(0, &viRect);

	pFaceThread = (ImageThread_S *)param;
	while(pFaceThread->threadRun)
	{
		memset(pBuf, 0x00, sizeof(HNY_FrameHeader_S) + sizeof(HNY_AiFaceRectInfo_S));
		ret = SHB_ShareBufGetOneFrame(g_imageManager.metaDataBuf, sizeof(HNY_FrameHeader_S) + sizeof(HNY_AiFaceRectInfo_S), pBuf);
		if(ret <= 0)
		{
			usleep(50*1000);
			cnt ++;
			if(cnt < 3)
				continue;
		}

		if(cnt >= 3)
		{
			cnt = 0;
			expWin.h_offs = 0;
			expWin.v_offs = 0;
			expWin.h_size = 1920;
			expWin.v_size = 1080;
		}
		else
		{
			pAiFaceRectInfo = (HNY_AiFaceRectInfo_S *)(pBuf + sizeof(HNY_FrameHeader_S));

			if(pAiFaceRectInfo->faceCnt <= 0)
			{
				usleep(50*1000);
				continue;
			}

			//查找最大人脸
			id = -1;
			faceRect = 0;
			for(i=0; i<pAiFaceRectInfo->faceCnt; i++)
			{
				width = pAiFaceRectInfo->faceRect[i].faceRect.right - pAiFaceRectInfo->faceRect[i].faceRect.left;
				height = pAiFaceRectInfo->faceRect[i].faceRect.bottom - pAiFaceRectInfo->faceRect[i].faceRect.top;
				if(faceRect < width*height)
				{
					id = i;
					faceRect = width*height;
				}
			}
			
			if(id >= 0)
           {
            HNY_Rect_S curFaceRect = pAiFaceRectInfo->faceRect[id].faceRect;
           if(stRect.x == 0 && stRect.width == 0 && stRect.y == 0 && stRect.height == 0)
           {
           stRect.x = curFaceRect.left,stRect.y = curFaceRect.bottom,stRect.width =curFaceRect.right-curFaceRect.left,height =curFaceRect.bottom-curFaceRect.top;
            }
            else
            {
            int curWidth = curFaceRect.right - curFaceRect.left;;
            int curHeight =  curFaceRect.bottom - curFaceRect.top;
            int maxWidth = stRect.width;
            int maxHeight = stRect.height;
            if(curWidth < maxWidth * 0.4|| curHeight < maxHeight * 0.4) //新检测到人脸大小太小
            {
            if(cnt == 0)
            {
            cnt = 3; //直接使用上一次稳定的人脸框
            }
            continue;
            }
            else
            {
            stRect.x = (stRect.x + curFaceRect.left) / 2;
            stRect.width = (stRect.width + curFaceRect.right-curFaceRect.left)/ 2;
            stRect.y = (stRect.y + curFaceRect.bottom) / 2;
            stRect.height = (stRect.height + curFaceRect.bottom-curFaceRect.top) / 2;
            //限制人脸框的范围
            if(stRect.x < 0) 
				{stRect.x = 0;}
            if(stRect.y < 0) {stRect.y = 0;}
            if(stRect.width > viRect.width) {stRect.width = viRect.width;}
            if(stRect.height > viRect.height) {stRect.height = viRect.height;}
            }
            }
            //更新当前使用的人脸框
            id = -1;
            for(i=0; i<pAiFaceRectInfo->faceCnt; i++)
            {
            if(stRect.x >= pAiFaceRectInfo->faceRect[i].faceRect.left
            && (stRect.x + stRect.width) <= pAiFaceRectInfo->faceRect[i].faceRect.right
            && stRect.y >= pAiFaceRectInfo->faceRect[i].faceRect.top
            && (stRect.y+stRect.height) <= pAiFaceRectInfo->faceRect[i].faceRect.bottom)
            {
            id = i;
            break;
            }
            }
            if(id >= 0)
            {
            pAiFaceRectInfo->faceCnt = 1;
            pAiFaceRectInfo->faceRect[0] = pAiFaceRectInfo->faceRect[id];
            }
            else
            {
            continue;
            }
            }
            
/*            //获取人脸框

            if(pAiFaceRectInfo->faceCnt > 0)
            {
            HNY_Rect_S faceRect2 = pAiFaceRectInfo->faceRect[0].faceRect;
            }
            else
            {
            usleep(50*1000);
            continue;
            }
            
            //根据人脸框位置计算VGRect
            PF_Rect_S vgRect = {0};
            float vgXRatio = 1.0 * viRect.width / VC_GetVGInfo()->VGWidth;
            float vgYRatio = 1.0 * viRect.height / VC_GetVGInfo()->VGHeight;
            vgRect.left = faceRect.x / vgXRatio;
            vgRect.top = faceRect.y / vgYRatio;
            vgRect.right = (faceRect.x + faceRect.width) / vgXRatio;
            vgRect.bottom = (faceRect.y + faceRect.height)/ vgYRatio;
            
            //根据VGRect计算ExpWin
            expWin.h_offs = vgRect.left - VC_GetVGInfo()->VGLeft;
            expWin.v_offs = vgRect.top - VC_GetVGInfo()->VGTop;
            expWin.h_size = vgRect.right - vgRect.left;
            expWin.v_size = vgRect.bottom - vgRect.top;
            
            //限制ExpWin位置和大小
            if(expWin.h_offs < 0)
            {
            expWin.h_offs = 0;
            expWin.h_size = vgRect.right - VC_GetVGInfo()->VGLeft;
            }
            if(expWin.v_offs < 0)
            {
            expWin.v_offs = 0;
            expWin.v_size = vgRect.bottom - VC_GetVGInfo()->VGTop;
            }
            if(expWin.h_offs + expWin.h_size > viRect.width)
            {
            expWin.h_size = viRect.width - expWin.h_offs;
            }
            if(expWin.v_offs + expWin.v_size > viRect.height)
            {
            expWin.v_size = viRect.height - expWin.v_offs;
            }
            		
*/


				   
					expWin.h_offs      = pAiFaceRectInfo->faceRect[id].faceRect.left * viRect.width / 10000;
					expWin.v_offs     = pAiFaceRectInfo->faceRect[id].faceRect.top * viRect.height / 10000;
					expWin.h_size  = (pAiFaceRectInfo->faceRect[id].faceRect.right - pAiFaceRectInfo->faceRect[id].faceRect.left) * viRect.width / 10000;
					expWin.v_size = (pAiFaceRectInfo->faceRect[id].faceRect.bottom - pAiFaceRectInfo->faceRect[id].faceRect.top) * viRect.height / 10000;
					stRect.x	  = expWin.h_offs;
				    stRect.y	  = expWin.v_offs;
				    stRect.width  = expWin.h_size;
				    stRect.height = expWin.v_size;
					
					 ret = VC_SetFaceExp(stRect);


             

		}
		
		printf("id[%d] set face[%d,%d--%d,%d]\n", id, expWin.h_offs, expWin.v_offs, expWin.h_size, expWin.v_size);
//		ret = SAMPLE_COMM_ISP_SET_ExpWinAttr(0, expWin);
		if(ret < 0)
		{
			DEBUG_ERROR(MODULE_CODEC, "SAMPLE_COMM_ISP_SET_ExpWinAttr failed[%d]!", ret);
		}
	}

	DEBUG_ERROR(MODULE_CODEC, "thread[%s] exit!", threadName);
	free(pBuf);

	return NULL;打印出来的人脸框为什么是1920 1080