多脚本语言混合编程整体解决方案

公共语言扩展 参考链接:http://www.srplab.com/cn/index.html
C#调用python3.0及以上:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Star_csharp;
namespace cshape_tensorflow
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime beforDT = System.DateTime.Now;
            StarCoreFactory starcore = StarCoreFactory.GetFactory();
            StarServiceClass Service = starcore._InitSimple("test", "123", 0, 0);
            StarSrvGroupClass SrvGroup = (StarSrvGroupClass)Service._Get("_ServiceGroup");
            SrvGroup._InitRaw("python35", Service);
            //--load python module  
            SrvGroup._LoadRawModule("python35","","test.py", false);
            StarObjectClass python = Service._ImportRawContext("python35", "", false, "");
            //--call python function tt, the return contains two integer, which will be packed into parapkg  
            int ParaPkg = (int)python._Call("tt", "hello", "world");
            DateTime afterDT = System.DateTime.Now;
            TimeSpan ts = afterDT.Subtract(beforDT);
            Console.WriteLine("DateTime总共花费{0}ms.", ts.TotalMilliseconds);
            Console.WriteLine(ParaPkg);
            SrvGroup._ClearService();
            starcore._ModuleExit();
        }
    }
}


Python调用C++ dll
cytes参考链接:https://docs.python.org/3.5/library/ctypes.html

import numpy as np
import ctypes
from ctypes import *
import cv2

# TemFun = cdll.LoadLibrary('test0717.dll')
TemFun=ctypes.CDLL("test0717.dll")
TemFun.DetectionBox.restype = ctypes.c_char_p
print(TemFun)
flage=TemFun.DetectionBox("D:/Image/1116/20181116pic_1_merge/1076278A1B7CBC9.TIF".encode("utf-8"))
print(str(flage))
if flage==b'success':
    print("hihihi")
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值