static void Main(string[] args) { PredictRes prst = new PredictRes(); string pythonfile = "D:/fc_example/python"; string modelfile = "D:/fc_example/models"; string weightfile = "D:/fc_example/weights"; string predictfile = "D:/fc_example/test.jpg"; Console.WriteLine("pythonfile is:" + pythonfile + "\n"); Console.WriteLine("modelfile is:" + modelfile + "\n"); Console.WriteLine("weightfile is:" + weightfile + "\n"); Console.WriteLine("predictfile is:" + predictfile + "\n"); int initx = init(pythonfile, modelfile, weightfile); Console.WriteLine("invoke init function return is:" + initx + "\n"); predict(predictfile, ref prst); Console.WriteLine("invoke predict function return size is:" + prst.size + "\n"); if (prst.size == 0) { return; } int[] ist = new int[prst.size]; Marshal.Copy(prst.result, ist, 0, prst.size); for (int i = 0; i < prst.size; i++) { Console.WriteLine("return array item[" + i + "] is:" + ist[i] + "."); } Console.ReadLine(); }
static extern void predict([MarshalAs(UnmanagedType.LPStr)] string filePath, ref PredictRes pr);