非托管C++代码:
class CPLUSALOG_API_20211029 CCTest
{
public:
    CCTest();
    int* Get();
    ~CCTest();
protected:
    Hobject* m_pRegion;
}
  CCTest::CCTest()
{
    m_pRegion = new Hobject();
    Halcon::gen_circle(m_pRegion, 10.0, 10, 10);
}
int* CCTest::Get()
{
    return (int*)m_pRegion->Id();
}

CCTest::~CCTest()
{
    delete m_pRegion;
}
C#代码:
 public class CTest
    {
       public CTest(System.IntPtr ptr)
        {
            m_region = new HObject(ptr);
            HTuple tArea, tRow, tCol;
            HOperatorSet.AreaCenter(m_region, out tArea, out tRow, out tCol);
        }
        HObject m_region;
    }
调用方,托管C++代码:
     CCTest ctest;
             ProjectBaseLib::NGClass::CTest^ test = gcnew ProjectBaseLib::NGClass::CTest((System::IntPtr)ctest.Get());

调用结果:
面积:314

posted on   闻缺陷则喜何志丹  阅读(45)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
历史上的今天:
2020-11-16 WCF服务端调用客户端.
2019-11-16 分配任务的时候,要给出需求而不是解决方案



点击右上角即可分享
微信分享提示