日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

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

發布時間:2023/12/20 python 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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,实现小冰颜值鉴定的全部內容,希望文章能夠幫你解決所遇到的問題。

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