Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

想给vin_ivps_engine_venc_rtsp在通道1增加抓图功能,失败了 #8

Open
zlyadvocate opened this issue Oct 10, 2024 · 2 comments

Comments

@zlyadvocate
Copy link

static AX_VOID* IVPS_GetFramesnapThread(AX_VOID* pArg)
{
AX_S32 ret = 0;
SAMPLE_IVPS_GRP_T* pThis = (SAMPLE_IVPS_GRP_T*)pArg;
AX_VIDEO_FRAME_T engine_input_frame;
IVPS_GRP nGrp = pThis->nIvpsGrp;
AX_IVPS_PIPELINE_ATTR_T stPipelineAttr;
ret = AX_IVPS_GetPipelineAttr(nGrp, &stPipelineAttr);
printf("IVPS_GetFramesnapThread");
if (ret != 0)
{
printf("AX_IVPS_GetPipelineAttr failed. ret=0x%x\n", ret);
return (AX_VOID*)0;
}

const int snap_chn = 1;
const char* device_name = "yemao";
const char* suffix = ".jpg";
char snapcnt = 0;

picsnaptag = true;

while (!ThreadLoopStateGet())
{
    if (picsnaptag == true)
    {
        // Get snap_chn frame

        memset(&engine_input_frame, 0, sizeof(AX_VIDEO_FRAME_T));
        printf("AX_IVPS_GetChnFrame");
        ret = AX_IVPS_GetChnFrame(nGrp, snap_chn, &engine_input_frame, -1);
        if (ret != 0)
        {
            printf("AX_IVPS_GetChnFrame(Grp:%d Chn:%d) failed, ret=0x%x.\n", nGrp, snap_chn, ret);
            continue;
        }

        // inference
        engine_input_frame.u64VirAddr[0] = (AX_U64)AX_POOL_GetBlockVirAddr(engine_input_frame.u32BlkId[0]);
        engine_input_frame.u64PhyAddr[0] = AX_POOL_Handle2PhysAddr(engine_input_frame.u32BlkId[0]);
        char snapfilename[256];

        // 生成文件名
        generate_filename(device_name, suffix, snapfilename, sizeof(snapfilename));

        EncodeOneFrameToJpeg("123.jpg", engine_input_frame.u32PicStride, engine_input_frame.u32Width, engine_input_frame.u32Height, engine_input_frame.u64PhyAddr,
            engine_input_frame.u64VirAddr, engine_input_frame.u32FrameSize);



        ret = AX_IVPS_ReleaseChnFrame(nGrp, snap_chn, &engine_input_frame);
        if (ret != 0)
        {
            printf("AX_IVPS_ReleaseChnFrame(Grp:%d Chn:%d) failed, ret=0x%x.\n", nGrp, snap_chn, ret);
        }
        picsnaptag = false;

    }
    else
    {
        usleep(40000);
        printf("IVPS_GetFramesnapThread(Grp:%d Chn:%d) , ret=0x%x.\n", nGrp, snap_chn, ret);
        snapcnt++;
        if (snapcnt > 30)
        {
            picsnaptag = true;
            snapcnt = 0;
        }



    }

}

return (AX_VOID*)0;

}

@zlyadvocate
Copy link
Author

AD))KN )0C$O$~1(5D4K2$L

@zlyadvocate
Copy link
Author

【潜水】yyyhnk(2082738645) 2024/10/9 9:23:38
@小圈圈-axera-打杂 卡在红色句子了。想抓通道1山的图片进行JPEG编码。

【潜水】yyyhnk(2082738645) 2024/10/9 9:25:35
@小圈圈-axera-打杂 改到通道3上可以抓到数据,JPEG编码后的数据是错的。 EncodeOneFrameToJpeg怎么调用?

【潜水】yyyhnk(2082738645) 2024/10/9 9:30:45
@小圈圈-axera-打杂 要抓通道1上的图片数据进行JPG编码该怎么实现?还需要修改哪些配置。线程已经是可以运行,其他通道一直ret为错误值。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant