I'm working on a Kinect Application wich need to send the Real Coordenates of the face to another program, Matlab, now I've a Console Application acting as a Client (who receive the data). I test the code apart from the Kinect program and works fine (the message is sent) but when I implement it to the Kinect code the send of the message fails in the SUCCESFUL line (SUCCESFUL = -1 don't know why)
Any ideas of what I have to change in the kinect code?
KINECT FUNCTION
void SingleFace::FTHelperCallingBack(PVOID pVoid)
{
SingleFace* pApp = reinterpret_cast<SingleFace*>(pVoid);
if (pApp)
{
char *sendbuf = new char[buffsize];
long SUCCESFUL;
WSAData WinSockData;
WORD DLLVERSION;
DLLVERSION = MAKEWORD(2, 1);
SUCCESFUL = WSAStartup(DLLVERSION, &WinSockData);
SOCKADDR_IN ADDRESS;
int AddressSize = sizeof(ADDRESS);
SOCKET sock_LISTEN;
SOCKET sock_CONNECTION;
sock_CONNECTION = socket(AF_INET, SOCK_STREAM, NULL);
listen(sock_LISTEN, SOMAXCONN);
IFTResult* pResult = pApp->m_FTHelper.GetResult();
if (pResult && SUCCEEDED(pResult->GetStatus()))
{
fstream outputFile("TrackingResults.txt");
outputFile << "Resultados del Tracking \n";
outputFile.close();
FLOAT* pAU = NULL;
UINT numAU;
pResult->GetAUCoefficients(&pAU, &numAU);
pApp->m_eggavatar.SetCandideAU(pAU, numAU);
FLOAT scale;
FLOAT rotationXYZ[3];
FLOAT translationXYZ[3];
pResult->Get3DPose(&scale, rotationXYZ, translationXYZ);
pApp->m_eggavatar.SetTranslations(translationXYZ[0], translationXYZ[1], translationXYZ[2]);
pApp->m_eggavatar.SetRotations(rotationXYZ[0], rotationXYZ[1], rotationXYZ[2]);
// MOSTRANDO RESULTADOS EN LA VENTANDA OUTPUT
std::string resultados = "T = [" + to_string(translationXYZ[0]) + "," + to_string(translationXYZ[1]) + "," + to_string(translationXYZ[2]) + ", ], R=[" + to_string(rotationXYZ[0]) + "," + to_string(rotationXYZ[0]) + "," + to_string(rotationXYZ[1]) + "," + to_string(rotationXYZ[2]) + "], sc=" + to_string(scale) + "/n";
std::wstring stemp = s2ws(resultados);
LPCWSTR results = stemp.c_str();
OutputDebugStringW(results);
/*Matrix to calculate the real coordenates
A1 = 98.1987 4.8642
-6.3882 79.6357
9.9648 20.0521*/
double xr = 98.1987*translationXYZ[0] - 6.3882*translationXYZ[2] + 9.9648;
double yr = 4.8642*translationXYZ[0] + 79.6357*translationXYZ[2] + 20.0521;
sprintf(sendbuf, "%+07.2f %+07.2f\n", xr, yr);
if (sock_CONNECTION = accept(sock_LISTEN, (SOCKADDR*)&ADDRESS, &AddressSize));
{
cout << " \n\tA connection was found! " << endl;
send(sock_CONNECTION, sendbuf, 17, NULL);
cout << "Sent: (" << sendbuf << ")\n";
}
}
}
}
//Main Code
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow)
{
AllocConsole();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
//SERVER
long SUCCESFUL;
WSAData WinSockData;
WORD DLLVERSION;
DLLVERSION = MAKEWORD(2, 1);
SUCCESFUL = WSAStartup(DLLVERSION, &WinSockData);
SOCKADDR_IN ADDRESS;
int AddressSize = sizeof(ADDRESS);
SOCKET sock_LISTEN;
SOCKET sock_CONNECTION;
sock_CONNECTION = socket(AF_INET, SOCK_STREAM, NULL);
ADDRESS.sin_addr.s_addr = inet_addr("127.0.0.1");
ADDRESS.sin_family = AF_INET;
ADDRESS.sin_port = htons(444);
sock_LISTEN = socket(AF_INET, SOCK_STREAM, NULL);
bind(sock_LISTEN, (SOCKADDR*)&ADDRESS, sizeof(ADDRESS));
listen(sock_LISTEN, SOMAXCONN);
for (;;)
{
cout << "\n\tSERVER: Waiting for incomming connetion...";
if (sock_CONNECTION = accept(sock_LISTEN, (SOCKADDR*)&ADDRESS, &AddressSize));
{
cout << " \n\tA connection was found! " << endl;
UNREFERENCED_PARAMETER(hPrevInstance);
SingleFace app;
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
return app.Run(hInstance, lpCmdLine, nCmdShow);
}
} }
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire