AXERA-TECH / ax650n_bsp_sdk

linux bsp app & sample for axpi pro (ax650n)
Other
19 stars 2 forks source link

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

Open zlyadvocate opened 3 weeks ago

zlyadvocate commented 3 weeks ago

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 commented 3 weeks ago

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

zlyadvocate commented 3 weeks ago

【潜水】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为错误值。