1
我在MATLAB中生成C++共享庫,並將其集成到C++中的Win32控制檯應用程序中。我必須從PHP調用這個控制檯應用程序。它有5個輸入,應該從PHP傳遞。當我運行應用程序給出它運行的輸入參數。其正常運行的代碼是如下:在C++ Win32控制檯應用程序中採用輸入參數
#include "stdafx.h"
#include "shoes_sharedlibrary.h"
#include <iostream>
#include <string.h>
#include "mex.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
/* Call the MCR and library initialization functions */
if(!mclInitializeApplication(NULL,0))
{
exit(1);
}
if (!shoes_sharedlibraryInitialize())
{
exit(1);
}
mwArray img= "C:/Users/aadbi.a/Desktop/dressimages/T1k5aHXjNqXXc4MOI3_050416.jpg";
double wt1 = 0;
mwArray C(wt1);
double wt2=0;
mwArray F(wt2);
double wt3=0;
mwArray T(wt3);
double wt4=1;
mwArray S(wt4);
test_shoes(img,C,F,T,S);
shoes_sharedlibraryTerminate();
mclTerminateApplication();
return 0;
}
的C,F,T,S是值0和1之間如何傳遞的輸入參數,因爲它是在_TCHAR *我怎樣才能轉換? _TCHAR *轉換爲十進制或雙精度,再次將其轉換爲mwArray傳遞給test_shoes。 test_shoes只將mwArray作爲輸入。
的test_shoes函數的定義是:
void MW_CALL_CONV test_shoes(const mwArray& img_path, const mwArray& Wcoarse_colors,
const mwArray& Wfine_colors, const mwArray& Wtexture, const
mwArray& Wshape)
{
mclcppMlfFeval(_mcr_inst, "test_shoes", 0, 0, 5, &img_path, &Wcoarse_colors, &Wfine_colors, &Wtexture, &Wshape);
}
謝謝。我怎樣才能把它轉換成字符串?因爲我也必須發送img路徑作爲參數。 – user1583647 2013-05-08 01:33:37
@ user1583647 - 它已經是一個字符串了,所以'std:string szt1 = argv [1]'對於ANSI或對於UNICODE是'std :: wstring szt1 = argv [1]'。 – 2013-05-08 04:38:07