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

不退出程序第二次推理的时候CV里对结果转置发生了异常 #4

Open
Alex1911-Jiang opened this issue Jun 8, 2023 · 2 comments

Comments

@Alex1911-Jiang
Copy link

推理设备:ONNX runtime
推理模型:Yolov8-pose
异常代码:

        /// <summary>
        /// 结果处理
        /// </summary>
        /// <param name="result">模型预测输出</param>
        /// <returns>模型识别结果</returns>
        public Result process_result(float[] result)
        {
            Mat result_data = new Mat(56, 8400, MatType.CV_32F, result);
------> result_data = result_data.T();
            // 存放结果list
            List<Rect> position_boxes = new List<Rect>();
            List<float> confidences = new List<float>();
            List<PoseData> pose_datas = new List<PoseData>();
            ...

异常信息:

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
   at OpenCvSharp.Internal.NativeMethods.core_MatExpr_toMat(IntPtr, IntPtr)
--------------------------------
   at OpenCvSharp.MatExpr.ToMat()
   at ResultSharp.PoseResult.process_result(Single[])
   at ModelDeployPlatform.FormModelDeployPlat.btn_model_deploy_Click(System.Object, System.EventArgs)
   at System.Windows.Forms.Control.OnClick(System.EventArgs)
   at System.Windows.Forms.Button.OnClick(System.EventArgs)
   at System.Windows.Forms.Button.OnMouseUp(System.Windows.Forms.MouseEventArgs)
   at System.Windows.Forms.Control.WmMouseUp(System.Windows.Forms.Message ByRef, System.Windows.Forms.MouseButtons, Int32)
   at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.ButtonBase.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Button.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr, WM, IntPtr, IntPtr)
   at Interop+User32.DispatchMessageW(MSG ByRef)
   at Interop+User32.DispatchMessageW(MSG ByRef)
   at System.Windows.Forms.Application+ComponentManager.Interop.Mso.IMsoComponentManager.FPushMessageLoop(UIntPtr, msoloop, Void*)
   at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(msoloop, System.Windows.Forms.ApplicationContext)
   at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(msoloop, System.Windows.Forms.ApplicationContext)
   at System.Windows.Forms.Application.Run(System.Windows.Forms.Form)
   at ModelDeployPlatform.Program.Main()

似乎是CV的问题?我尝试了克隆新的Mat并将旧的dispose掉(当次的或上次的都试过),或者使用单独的一个对象而不使用转置后的对象替换转置前的对象都依旧会出现这个异常。

我想请教一下大佬,result传进来的长度只有50400,和这个8400*56的矩阵是个什么关系,只有前6行有数据后面50行全是0吗?如果我希望不使用CV,自己通过二维数组实现,数据该怎么填充?

谢谢大佬

@Asssssert
Copy link

我也遇到和你一样的问题,你怎么解决了 方便告诉我吗

@guojin-yan
Copy link
Owner

对不起哈,因为我的原因没有及时进行回复,数据形状是跟你的模型输出大小一致,你可以查看一下你的模型节点信息,再进行调整。

如果问题无法解决,可以添加QQ群进行交流:945057948

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

3 participants