技术专栏
RV1126 屏幕demo
RV1126 屏幕demo
1.RK_MPI_SYS_Bind绑定VI-VO
#include <assert.h>
#include <fcntl.h>
#include <getopt.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <getopt.h>
#include "common/sample_common.h"
#include "librtsp/rtsp_demo.h"
#include "rkmedia_api.h"
#include "rkmedia_venc.h"
static bool quit = false;
static void sigterm_handler(int sig){
fprintf(stderr, "signal %d\n", sig);
quit = true;
}
static const struct option long_options[] = {
{"s32CamId",required_argument,NULL,'I'},
{"iqfiles",required_argument,NULL,'a'},
{NULL,0,NULL,0}
};
int main(int argc,char *argv[]) {
int ret=0;
RK_S32 s32CamId = 0;
char *iq_dir = NULL;
int c=0;
// 使用getopt_long解析命令行获取配置文件和初始化ispp1还是ispp0
while((c=getopt_long(argc,argv,"I:a:",long_options,NULL))!=-1){
switch(c){
case 'a':
iq_dir=(char *)optarg;
break;
case 'I':
s32CamId=atoi(optarg);
break;
default:
printf("no argument\n");
return 0;
}
}
// 初始化ispp
ret = SAMPLE_COMM_ISP_Init(s32CamId, RK_AIQ_WORKING_MODE_NORMAL, RK_FALSE,
iq_dir);
if (ret != 0) {
printf("isp init failed");
return -1;
}
ret = SAMPLE_COMM_ISP_Run(s32CamId);
if (ret != 0) {
printf("isp_run failed");
return -1;
}
SAMPLE_COMM_ISP_SetFrameRate(s32CamId, 30);
RK_MPI_SYS_Init();
// vi_init
VI_CHN_ATTR_S vi_chn_attr;
memset(&vi_chn_attr, 0, sizeof(vi_chn_attr));
vi_chn_attr.pcVideoNode = "rkispp_scale0";// 摄像头节点
vi_chn_attr.u32BufCnt = 3;
vi_chn_attr.u32Width = 1024;
vi_chn_attr.u32Height = 600;
vi_chn_attr.enPixFmt = IMAGE_TYPE_NV12;
vi_chn_attr.enBufType = VI_CHN_BUF_TYPE_MMAP;
vi_chn_attr.enWorkMode = VI_WORK_MODE_NORMAL;
ret = RK_MPI_VI_SetChnAttr(s32CamId, 0, &vi_chn_attr);
ret |= RK_MPI_VI_EnableChn(s32CamId, 0);
if (ret) {
printf("Create vi[0] failed! ret=%d\n", ret);
return -1;
}
printf("-----------enable vi channel success\n");
// vo_init
VO_CHN_ATTR_S stVoAttr = {0};
memset(&stVoAttr, 0, sizeof(stVoAttr));
stVoAttr.pcDevNode = "/dev/dri/card0"; // 屏幕节点
stVoAttr.emPlaneType = VO_PLANE_OVERLAY;
stVoAttr.enImgType = IMAGE_TYPE_NV12;
stVoAttr.u16Zpos = 1;
stVoAttr.u32Width = 1024;
stVoAttr.u32Height = 600;
stVoAttr.stImgRect.s32X = 0;
stVoAttr.stImgRect.s32Y = 0;
stVoAttr.stImgRect.u32Width = 1024;
stVoAttr.stImgRect.u32Height = 600;
stVoAttr.stDispRect.s32X = 0;
stVoAttr.stDispRect.s32Y = 0;
stVoAttr.stDispRect.u32Width = 1024;
stVoAttr.stDispRect.u32Height = 600;
ret = RK_MPI_VO_CreateChn(0, &stVoAttr);
if (ret) {
printf("Create vo[0] failed! ret=%d\n", ret);
return -1;
}
printf("-----------enable vo channel success\n");
MPP_CHN_S stSrcChn = {0};
MPP_CHN_S stDestChn = {0};
// 绑定VI-VO
printf("#Bind VI[0] to VO[0]....\n");
stSrcChn.enModId = RK_ID_VI;
stSrcChn.s32DevId = s32CamId;
stSrcChn.s32ChnId = 0;
stDestChn.enModId = RK_ID_VO;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = 0;
ret = RK_MPI_SYS_Bind(&stSrcChn, &stDestChn);
if (ret) {
printf("Bind vi[0] to vo[0] failed! ret=%d\n", ret);
return -1;
}
// 捕捉信号(ctrl+c)
signal(SIGINT, sigterm_handler);
while (!quit) {
usleep(500000);
}
// 解绑VI-VO
printf("%s exit!\n", __func__);
stSrcChn.enModId = RK_ID_VI;
stSrcChn.s32DevId = s32CamId;
stSrcChn.s32ChnId = 0;
stDestChn.enModId = RK_ID_VO;
stDestChn.s32DevId = 0;
stDestChn.s32ChnId = 0;
ret = RK_MPI_SYS_UnBind(&stSrcChn, &stDestChn);
if (ret) {
printf("UnBind vi[0] to vo[0] failed! ret=%d\n", ret);
return -1;
}
RK_MPI_VO_DestroyChn(0);
RK_MPI_VI_DisableChn(s32CamId, 0);
SAMPLE_COMM_ISP_Stop(s32CamId);
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
<
2.RK_MPI_SYS_GetMediaBuffer获取VI数据帧
#include <assert.h>
#include <fcntl.h>
#include <getopt.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <getopt.h>
#include "common/sample_common.h"
#include "librtsp/rtsp_demo.h"
#include "rkmedia_api.h"
#include "rkmedia_venc.h"
static const struct option long_options[] = {
{"s32CamId",required_argument,NULL,'I'},
{"iqfiles",required_argument,NULL,'a'},
{NULL,0,NULL,0}
};
int main(int argc,char *argv[]) {
MEDIA_BUFFER buffer;
int ret=0;
RK_S32 s32CamId = 0;
char *iq_dir = NULL;
int c=0;
// 使用getopt_long解析命令行获取配置文件和初始化ispp1还是ispp0
while((c=getopt_long(argc,argv,"I:a:",long_options,NULL))!=-1){
switch(c){
case 'a':
iq_dir=(char *)optarg;
break;
case 'I':
s32CamId=atoi(optarg);
break;
default:
printf("no argument\n");
return 0;
}
}
// 初始化ispp
ret = SAMPLE_COMM_ISP_Init(s32CamId, RK_AIQ_WORKING_MODE_NORMAL, RK_FALSE,
iq_dir);
if (ret != 0) {
printf("isp init failed");
return -1;
}
ret = SAMPLE_COMM_ISP_Run(s32CamId);
if (ret != 0) {
printf("isp_run failed");
return -1;
}
SAMPLE_COMM_ISP_SetFrameRate(s32CamId, 30);
RK_MPI_SYS_Init();
// vi_init
VI_CHN_ATTR_S vi_chn_attr;
memset(&vi_chn_attr, 0, sizeof(vi_chn_attr));
vi_chn_attr.pcVideoNode = "rkispp_scale0"; // 摄像头节点
vi_chn_attr.u32BufCnt = 3;
vi_chn_attr.u32Width = 1024;
vi_chn_attr.u32Height = 600;
vi_chn_attr.enPixFmt = IMAGE_TYPE_NV12;
vi_chn_attr.enBufType = VI_CHN_BUF_TYPE_MMAP;
vi_chn_attr.enWorkMode = VI_WORK_MODE_NORMAL;
ret = RK_MPI_VI_SetChnAttr(s32CamId, 0, &vi_chn_attr);
ret |= RK_MPI_VI_EnableChn(s32CamId, 0);
if (ret) {
printf("Create vi[0] failed! ret=%d\n", ret);
return -1;
}
printf("-----------enable vi channel success\n");
// vo_init
VO_CHN_ATTR_S stVoAttr = {0};
memset(&stVoAttr, 0, sizeof(stVoAttr));
stVoAttr.pcDevNode = "/dev/dri/card0"; // 屏幕节点
stVoAttr.emPlaneType = VO_PLANE_OVERLAY;
stVoAttr.enImgType = IMAGE_TYPE_NV12;
stVoAttr.u16Zpos = 1;
stVoAttr.u32Width = 1024;
stVoAttr.u32Height = 600;
stVoAttr.stImgRect.s32X = 0;
stVoAttr.stImgRect.s32Y = 0;
stVoAttr.stImgRect.u32Width = 1024;
stVoAttr.stImgRect.u32Height = 600;
stVoAttr.stDispRect.s32X = 0;
stVoAttr.stDispRect.s32Y = 0;
stVoAttr.stDispRect.u32Width = 1024;
stVoAttr.stDispRect.u32Height = 600;
ret = RK_MPI_VO_CreateChn(0, &stVoAttr);
if (ret) {
printf("Create vo[0] failed! ret=%d\n", ret);
return -1;
}
printf("-----------enable vo channel success\n");
// 启动视频流
ret = RK_MPI_VI_StartStream(s32CamId, 0);
if (ret) {
printf("Start VI[0] failed! ret=%d\n", ret);
return -1;
}
// 镜像
SAMPLE_COMM_ISP_SET_mirror(0, 0);
// 阻塞等待获取数据帧,然后发送
while (1) {
buffer = RK_MPI_SYS_GetMediaBuffer(RK_ID_VI, 0, -1);
if (!buffer) {
continue;
}
RK_MPI_SYS_SendMediaBuffer(RK_ID_VO, 0, buffer);
RK_MPI_MB_ReleaseBuffer(buffer);
}
RK_MPI_VO_DestroyChn(0);
RK_MPI_VI_DisableChn(s32CamId, 0);
SAMPLE_COMM_ISP_Stop(s32CamId);
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
<
声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
红包
点赞
收藏
评论
打赏
- 分享
- 举报
评论
0个
手气红包

相关专栏
-
浏览量:1827次2023-05-05 14:55:59
-
浏览量:2043次2023-12-29 17:51:55
-
浏览量:1262次2023-08-30 18:37:06
-
浏览量:4370次2021-06-18 16:05:42
-
浏览量:2910次2023-11-29 08:59:50
-
浏览量:1632次2023-12-07 00:53:19
-
浏览量:1564次2023-08-31 16:23:55
-
浏览量:879次2023-12-21 16:28:56
-
浏览量:995次2023-12-25 14:23:01
-
浏览量:2033次2024-02-27 17:03:43
-
浏览量:1820次2024-01-27 16:28:20
-
浏览量:783次2024-02-29 16:42:40
-
浏览量:2808次2023-11-17 09:00:06
-
浏览量:1286次2023-11-10 15:08:11
-
浏览量:2260次2024-01-04 17:26:55
-
浏览量:802次2023-11-28 14:16:24
-
浏览量:1247次2023-10-26 10:43:59
-
浏览量:1561次2023-12-21 18:26:41
-
浏览量:1442次2024-02-29 16:04:02
切换马甲
上一页
下一页
打赏用户
共 0 位
我要创作
分享技术经验,可获取创作收益
热门专栏
- 训练自己的yolov5样本, 并部署到rv1126 <一>
- 关于开发rv1126遇到的问题以及解决办法
- 如何添加APP到Buildroot里(以瑞芯微rv1126为例)
- rv1126 crond定时任务
- rkmedia一个头两个流, 即同一个vi通道, 接两个不同的下游通道,比如rga
- rv1126_rv1109移植opencv with ffmpeg for rtsp
- 关于EB-RV1126-DC-201开发板快速入门手册V2.2.E中遇到的问题-第三部分(已解决)。
- ADB工具打开闪退解决办法
- rv1126/1109平台下的lt8912显示驱动的调试
- 训练自己的yolov5样本, 并部署到rv1126 <三>
置顶时间设置
结束时间
删除原因
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
打赏作者
杰杰
您的支持将鼓励我继续创作!
打赏金额:
¥1

¥5

¥10

¥50

¥100

支付方式:

举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
审核成功
发布时间设置
发布时间:
请选择发布时间设置
是否关联周任务-专栏模块
审核失败
失败原因
请选择失败原因
备注
请输入备注