zoukankan      html  css  js  c++  java
  • 嵌入式 hi3518平台多路码流添加osd

    [html] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. <span style="font-family:Courier New;">  
    2.   
    3. /******************************************************************************  
    4. function : overlay process  
    5. 1) create some overlay regions  
    6. 2) display overlay regions ( One Region -- Multi-VencGroup )  
    7. 3) change all vencGroups Regions' positio  
    8. 4) change all vencGroups Regions' Layern  
    9. 5) change all vencGroups Regions' color  
    10. 6) load bmp form bmp-file to Region-0  
    11. 7) change all vencGroups Regions' front alpha  
    12. 8) change all vencGroups Regions' backgroud alpha  
    13. 9) update bitmap(not support now)  
    14. 10) show or hide overlay regions  
    15. 11) Detach overlay regions from chn  
    16. 12) Detroy overlay regions  
    17.  ******************************************************************************/  
    18. HI_S32 JOSEPH_SAMPLE_RGN_OverlayProcess(void)  
    19. {  
    20.     HI_S32 s32Ret = HI_FAILURE;  
    21.     RGN_HANDLE RgnHandle;  
    22.     RGN_ATTR_S stRgnAttr;  
    23.     MPP_CHN_S stChn;  
    24.     VENC_GRP VencGrp;  
    25.     RGN_CHN_ATTR_S stChnAttr;  
    26.     HI_U32 Joseph_u32Layer = 7;  
    27.     HI_U32 Joseph_bind_DevId = 0;   
    28.     int last_sec = 0;  
    29.       
    30.     /****************************************  
    31.       step 1: create overlay regions  
    32.      ****************************************/  
    33.     stRgnAttr.enType = OVERLAY_RGN;  
    34.     stRgnAttr.unAttr.stOverlay.enPixelFmt = PIXEL_FORMAT_RGB_1555;//PIXEL_FORMAT_RGB_565   
    35.     stRgnAttr.unAttr.stOverlay.stSize.u32Width  = 288;  
    36.     stRgnAttr.unAttr.stOverlay.stSize.u32Height = 128;  
    37.     stRgnAttr.unAttr.stOverlay.u32BgColor = 0xffffff;  
    38.   
    39.     RgnHandle = 0;  
    40.   
    41.     s32Ret = HI_MPI_RGN_Create(RgnHandle, &stRgnAttr);  
    42.     if(HI_SUCCESS != s32Ret)  
    43.     {  
    44.         SAMPLE_PRT("HI_MPI_RGN_Create (%d) failed with %#x! ",   
    45.             RgnHandle, s32Ret);  
    46.         return HI_FAILURE;  
    47.     }  
    48.     SAMPLE_PRT("the handle:%d,creat success! ",RgnHandle);  
    49.   
    50.   
    51.     /*********************************************  
    52.       step 2: display overlay regions to venc groups  
    53.      *********************************************/  
    54.       
    55.     for(Joseph_bind_DevId = 0; Joseph_bind_DevId joseph_ipnc_param.joseph_s32ChnNum; Joseph_bind_DevId++)  
    56.     {  
    57.           
    58.         VencGrp = 0;  
    59.         stChn.enModId = HI_ID_GROUP;  
    60.         stChn.s32DevId = Joseph_bind_DevId;  
    61.         stChn.s32ChnId = VencGrp;  
    62.         RgnHandle = 0;  
    63.           
    64.         printf("%s:[%d] stChn.s32ChnId is %d , ",__FUNCTION__,__LINE__,stChn.s32ChnId);  
    65.           
    66.         memset(&stChnAttr,0,sizeof(stChnAttr));  
    67.         stChnAttr.bShow = HI_TRUE;  
    68.         stChnAttr.enType = OVERLAY_RGN;  
    69.   
    70.         stChnAttr.unChnAttr.stOverlayChn.stPoint.s32X = 16;  
    71.         stChnAttr.unChnAttr.stOverlayChn.stPoint.s32Y = 32;  
    72.         stChnAttr.unChnAttr.stOverlayChn.u32BgAlpha = 128;  
    73.         stChnAttr.unChnAttr.stOverlayChn.u32FgAlpha = 0;  
    74.         stChnAttr.unChnAttr.stOverlayChn.u32Layer = Joseph_u32Layer--;  
    75.           
    76.         stChnAttr.unChnAttr.stOverlayChn.stQpInfo.bAbsQp = HI_FALSE;  
    77.         stChnAttr.unChnAttr.stOverlayChn.stQpInfo.s32Qp  = 0;  
    78.   
    79.         stChnAttr.unChnAttr.stOverlayChn.stInvertColor.stInvColArea.u32Height = 32;  
    80.         stChnAttr.unChnAttr.stOverlayChn.stInvertColor.stInvColArea.u32Width = 16;  
    81.         stChnAttr.unChnAttr.stOverlayChn.stInvertColor.u32LumThresh = 64;  
    82.         stChnAttr.unChnAttr.stOverlayChn.stInvertColor.bInvColEn = HI_TRUE;  
    83.         stChnAttr.unChnAttr.stOverlayChn.stInvertColor.enChgMod = LESSTHAN_LUM_THRESH;  
    84.   
    85.         s32Ret = HI_MPI_RGN_AttachToChn(RgnHandle, &stChn, &stChnAttr);  
    86.         if(HI_SUCCESS != s32Ret)  
    87.         {  
    88.             SAMPLE_PRT("HI_MPI_RGN_AttachToChn (%d) failed with %#x! ",  
    89.                 RgnHandle, s32Ret);  
    90.             return HI_FAILURE;  
    91.         }  
    92.         printf("display region to s32DevId %d chn success! ",stChn.s32DevId);  
    93.     }  
    94.           
    95.   
    96.     /*********************************************  
    97.       step 3: show bitmap  
    98.      *********************************************/  
    99.     struct tm *tmnow;  
    100.     struct timeval tv;  
    101.     BITMAP_S Joseph_Osd_Bmp;  
    102.     gettimeofday(&tv,NULL);  
    103.   
    104.     setlocale(LC_ALL,"zh_CN.UTF-8");  
    105.     char osd_content[256] = {0};  
    106.     char week_chinese[16] = {0};  
    107.       
    108.     tmnow = localtime(&tv.tv_sec);  
    109.   
    110.     TTF_Font *font;   
    111.     /* Initialize the TTF library */    
    112.     if ( TTF_Init() 0 ) {    
    113.         return -1;    
    114.     }  
    115.       
    116.     font = TTF_OpenFont(JOSEPH_FONT_FILE, JOSEPH_FONT_SIZE);    
    117.     if ( font == NULL ) {    
    118.         printf("%s %d The fonts is NULL ! ",__FUNCTION__,__LINE__);  
    119.         return -1;  
    120.     }  
    121.       
    122.     /*TTF_SetFontStyle(font,  TTF_STYLE_ITALIC);*/   
    123.       
    124.     while(1)  
    125.     {  
    126.         memset(osd_content,0,sizeof(osd_content));  
    127.         memset(week_chinese,0,sizeof(week_chinese));  
    128.   
    129.         while(1)  
    130.         {  
    131.             gettimeofday(&tv,NULL);  
    132.             if(tv.tv_sec != last_sec)  
    133.             {  
    134.                 last_sec = tv.tv_sec;  
    135.                 break;  
    136.             }  
    137.             usleep(20000);  
    138.         }  
    139.   
    140.         tmnow = localtime(&tv.tv_sec);  
    141.           
    142.         #if 0  
    143.           
    144.         sprintf(osd_content,"%04d-%02d-%02d %02d:%02d:%02d %s ",  
    145.             tmnow->tm_year+1900, tmnow->tm_mon+1, tmnow->tm_mday,tmnow->tm_hour,  
    146.             tmnow->tm_min, tmnow->tm_sec,Joseph_utf_weeky_show(tmnow->tm_wday,week_chinese));  
    147.         #else  
    148.           
    149.         sprintf(osd_content,"%04d-%02d-%02d %s %02d:%02d:%02d",  
    150.             tmnow->tm_year+1900, tmnow->tm_mon+1, tmnow->tm_mday, Joseph_utf_weeky_show(tmnow->tm_wday,week_chinese),  
    151.             tmnow->tm_hour,tmnow->tm_min, tmnow->tm_sec);  
    152. #if 0  
    153.         printf("%s:[%d] The time stamp is %s ...  ",__FUNCTION__,__LINE__,osd_content);  
    154. #endif  
    155.         joseph_get_luminance_from_sensor_test();  
    156.         #endif  
    157.   
    158.         #if 0  
    159.           
    160.         joseph_creat_bmp_data(font,osd_content);  
    161.         #else  
    162.   
    163.         joseph_creat_bmp_data_show(font,osd_content,&Joseph_Osd_Bmp);  
    164.         #endif  
    165.         for(RgnHandle = 0;RgnHandle 1;RgnHandle++)  
    166.         {  
    167.             #if 0  
    168.             s32Ret = HI_MPI_RGN_SetBitMap(RgnHandle,&stBitmap);  
    169.             #else  
    170.             s32Ret = HI_MPI_RGN_SetBitMap(RgnHandle,&Joseph_Osd_Bmp);  
    171.             #endif  
    172.             if(s32Ret != HI_SUCCESS)  
    173.             {  
    174.                 SAMPLE_PRT("HI_MPI_RGN_SetBitMap failed with %#x! ", s32Ret);  
    175.                 exit(0);  
    176.                 return HI_FAILURE;  
    177.             }  
    178.           
    179.             free(Joseph_Osd_Bmp.pData);               
    180.             Joseph_Osd_Bmp.pData = NULL;  
    181.                   
    182.         }  
    183.   
    184.     }  
    185.      
    186.     TTF_CloseFont(font);  
    187.     font = NULL;  
    188.     TTF_Quit();   
    189.       
    190. #if 1  
    191.     /*********************************************  
    192.       step 4: destory region  
    193.      *********************************************/  
    194.   
    195.     for(Joseph_bind_DevId = 0; Joseph_bind_DevId joseph_ipnc_param.joseph_s32ChnNum; Joseph_bind_DevId++)  
    196.     {  
    197.         RgnHandle = 0;  
    198.         VencGrp = 0;  
    199.         stChn.enModId = HI_ID_GROUP;  
    200.         stChn.s32DevId = Joseph_bind_DevId;  
    201.         stChn.s32ChnId = VencGrp;  
    202.         RgnHandle = 0;  
    203.           
    204.   
    205.         s32Ret = HI_MPI_RGN_DetachFrmChn(RgnHandle, &stChn);  
    206.         if(HI_SUCCESS != s32Ret)  
    207.         {  
    208.             SAMPLE_PRT("HI_MPI_RGN_DetachFrmChn (%d) failed with %#x! ",  
    209.                    RgnHandle, s32Ret);  
    210.             return HI_FAILURE;  
    211.         }  
    212.     }  
    213.   
    214.     RgnHandle = 0;  
    215.     s32Ret = HI_MPI_RGN_Destroy(RgnHandle);  
    216.     if (HI_SUCCESS != s32Ret)  
    217.     {  
    218.         SAMPLE_PRT("HI_MPI_RGN_Destroy [%d] failed with %#x ",  
    219.             RgnHandle, s32Ret);  
    220.     }  
    221.     SAMPLE_PRT("destory all region success! ");  
    222. #endif  
    223.   
    224.     return HI_SUCCESS;  
    225. }  
    226. </span>  

    具体Demo代码可以下载:http://download.csdn.net/detail/skdkjxy/8838309 仅供参考,谢谢~

  • 相关阅读:
    JAVA_SE基础——47.接口
    抽象类和接口的区别[精华版]
    JAVA_SE基础——46.引用数据类型变量.值交换[独家深入解析]
    JAVA_SE基础——45.基本类型变量.值交换[独家深入解析]
    第一个Spring程序
    三层架构和MVC的区别
    Spring 概述及IOC理论推导
    Mybatis之缓存
    Mybatis之动态SQL
    Mybatis之一对多和多对一处理
  • 原文地址:https://www.cnblogs.com/lidabo/p/5383946.html
Copyright © 2011-2022 走看看