日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

unity 通过 dll 传递字符串给python,实现小冰颜值鉴定

發布時間:2023/12/20 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 unity 通过 dll 传递字符串给python,实现小冰颜值鉴定 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

傳入一個路徑字符串(C#):

public void PassXiaoIce() {try{string img_path = @"D:\XLS_AI_PRO\FaceTest\photo\11.jpg";Debug.Log(img_path.Length);string str = GetIceJson(img_path,img_path.Length);Debug.Log("result_str:" + str);//返回鑒定結果}catch{Debug.LogError("初始化異常!");} }//圖片路徑,返回顏值鑒定結果。 public String GetIceJson(string img_path, int psize) {IntPtr temp = FaceBind.GetResultIce(img_path, psize);string str = Marshal.PtrToStringAnsi(temp).ToString();temp = IntPtr.Zero;return str; }

DLL接口(C#):

[DllImport("XiaoICE", EntryPoint = "get_result_ice", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)] static extern IntPtr get_result_ice([MarshalAs(UnmanagedType.LPStr)]string g_path,int size);

DLL實現代碼(C++)

static char str_json[2048]; #define _csharp_double extern "C" __declspec(dllexport) const char * _csharp_double get_result_ice(wchar_t * img_byte, int bt_size) {import_array();PyObject * pValue = Py_BuildValue("(s#)", img_byte, bt_size);PyObject * pyResult = PyEval_CallObject(pGetXiaoIce, pValue);memset(str_json, 0, sizeof(str_json)); if (pyResult) {const char * str_js;PyArg_Parse(pyResult,"s",&str_js);strcpy_s(str_json, str_js);}else {strcpy_s(str_json, "error!");}Py_CLEAR(pValue);Py_CLEAR(pyResult);return str_json; }

?調用入口(python)

#傳入圖片路徑,返回顏值鑒定結果 def identification(img_path):score = Score()re_str = score.start(img_path)return re_str

總結

以上是生活随笔為你收集整理的unity 通过 dll 传递字符串给python,实现小冰颜值鉴定的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。