Exemplo n.º 1
0
            bool execute_upload_command(int action, string data)
            {
                UploadCommands c = (UploadCommands)action;

                // server.updateServerMsg("Received data from " + getTypeString(clientType) + clientID + " : " + c.ToString());
                try
                {
                    switch (c)
                    {
                    case UploadCommands.Update_knect_data_in_Base64_format:    //	Update knect data in Base64 String format	Used by Kinect Client
                        if (clientType == (int)clientTypes.KINECT)
                        {
                            KinectData k = new KinectData();
                            k.AssignByAllParameterStringInBase64(data);
                            k.transformTo(GUIComponents.fc.fp.getTranfMatrix()[clientID]);
                            kinectParameter = k;
                            updateKinectInfo(kinectParameter.printKinectParameters());
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }

                    case UploadCommands.Update_fused_knect_data_in_Base64_format:    //	Update fused knect data in Base64 String format	Used by Data Processor Client
                        if (clientType == (int)clientTypes.DATA_PROCESSOR)
                        {
                            //  server.fusedKinectParametersString = data;

                            server.fusedKinectParameter.AssignByAllParameterStringInBase64(data);

                            return(true);
                        }
                        else
                        {
                            return(false);
                        }

                    case UploadCommands.Update_raw_data:
                        if (clientType == (int)clientTypes.KINECT)
                        {
                            parentGUI.kinectCompList[clientID].updateKinectImages(data);    //colorImageWritableBitmap,depthImageWritableBitmap);

                            return(true);
                        }
                        return(false);

                    default:
                        return(false);
                    }
                }
                catch
                {
                    return(false);
                }
            }
Exemplo n.º 2
0
            bool execute_download_command(int action, int kinect_index = -2)
            {
                //kinect_index == -1 means all kinects

                DownloadCommands c = (DownloadCommands)action;

                // server.updateServerMsg("Received data from " + getTypeString(clientType) + clientID + " : " + c.ToString());
                if (action > (int)DownloadCommands.Get_head_joint_information_of_skeleton_array_from_fused_kinect_data &&
                    kinect_index == -2)    //kinect index not specified
                {
                    return(false);
                }
                try {
                    switch (c)
                    {
                    case DownloadCommands.Get_total_number_of_alive_Kinect_Client:      //Get total number of alive Kinect Client
                        int count = 0;
                        foreach (myClient mc in server.clientList.Where(cc => cc.isWorking && cc.clientType == (int)clientTypes.KINECT))
                        {
                            count++;
                        }

                        sendData((int)DownloadCommands.Get_total_number_of_alive_Kinect_Client + "#" + count.ToString());
                        break;

                    case DownloadCommands.Get_kinect_matrices:
                        List <DenseMatrix> list = GUIComponents.fc.fp.getTranfMatrix();

                        string dataToSend = "";
                        for (int i = 0; i < list.Count; ++i)
                        {
                            for (int row = 0; row < 4; ++row)
                            {
                                for (int col = 0; col < 4; ++col)
                                {
                                    dataToSend += list[i][row, col].ToString();    // +" " + list[i][1, 3].ToString() + " " + list[i][2, 3].ToString() + "#";
                                    if (row == 3 && col == 3)
                                    {
                                        dataToSend += "#";
                                    }
                                    else
                                    {
                                        dataToSend += " ";
                                    }
                                }
                            }
                        }
                        dataToSend = list.Count.ToString() + "#" + dataToSend;
                        sendData((int)DownloadCommands.Get_kinect_matrices + "#" + dataToSend);
                        //sendData("ERROR");
                        break;

                    case DownloadCommands.Download_all_kinect_data_in_Base64_string_format:    //	Download all kinect data in Base64 string format
                        dataToSend = "";
                        int clientcount = 0;
                        foreach (myClient mc in server.clientList.Where(cc => cc.isWorking && cc.clientType == (int)clientTypes.KINECT))
                        {
                            dataToSend += mc.kinectParameter.GetAllParameterStringInBase64() + "#";
                            clientcount++;
                        }
                        dataToSend = clientcount.ToString() + "#" + dataToSend;
                        sendData((int)DownloadCommands.Download_all_kinect_data_in_Base64_string_format + "#" + dataToSend);

                        break;

                    case DownloadCommands.Download_fused_kinect_data_in_Base64_string_format:    //	Download fused kinect data in Base64 string format

                        if (clientType == (int)clientTypes.KINECT && MainWindow.getFusedDataToKinect())
                        {
                            KinectData k = server.fusedKinectParameter.Clone();

                            list = GUIComponents.fc.fp.getTranfMatrix();
                            k.transformTo(getInverseTranfMatrix(list[clientID]));
                            sendData((int)DownloadCommands.Download_fused_kinect_data_in_Base64_string_format + "#" + k.GetAllParameterStringInBase64());
                        }
                        else if (clientType != (int)clientTypes.KINECT)
                        {
                            sendData((int)DownloadCommands.Download_fused_kinect_data_in_Base64_string_format + "#" + server.fusedKinectParameter.GetAllParameterStringInBase64());
                        }
                        break;

                    //case DownloadCommands.Get_total_number_of_faces_from_fused_kinect_data://   Get total number of faces from fused kinect data

                    //    if (server.fusedKinectParameter.faceArray != null)
                    //        sendData((int)DownloadCommands.Get_total_number_of_faces_from_fused_kinect_data + "#" + server.fusedKinectParameter.faceArray.Length.ToString());
                    //    else
                    //        sendData((int)DownloadCommands.Get_total_number_of_faces_from_fused_kinect_data + "#" + "0");
                    //    break;

                    case DownloadCommands.Get_total_number_of_skeletons_from_fused_kinect_data:     // Get total number of skeletons from fused kinect data
                        if (server.fusedKinectParameter.skeletonArray != null)
                        {
                            sendData((int)DownloadCommands.Get_total_number_of_skeletons_from_fused_kinect_data + "#" + server.fusedKinectParameter.skeletonArray.Length.ToString());
                        }
                        else
                        {
                            sendData((int)DownloadCommands.Get_total_number_of_skeletons_from_fused_kinect_data + "#" + "0");
                        }
                        break;

                    //case DownloadCommands.Get_full_face_parameters_from_fused_kinect_data_orientation_point://	Get full face parameters from fused kinect data
                    //    sendData((int)DownloadCommands.Get_full_face_parameters_from_fused_kinect_data_orientation_point + "#" + server.fusedKinectParameter.getFaceArrayString(KinectData.FaceArrayType.FULL_ARRAY_POINT));
                    //    break;

                    //case DownloadCommands.Get_full_face_parameters_from_fused_kinect_data_radian://	Get full face parameters from fused kinect data
                    //    sendData((int)DownloadCommands.Get_full_face_parameters_from_fused_kinect_data_radian + "#" + server.fusedKinectParameter.getFaceArrayString(KinectData.FaceArrayType.FULL_ARRAY_RADIAN));
                    //    break;

                    //case DownloadCommands.Get_face_positions_from_fused_kinect_data://	Get face positions from fused kinect data
                    //    sendData((int)DownloadCommands.Get_face_positions_from_fused_kinect_data + "#" + server.fusedKinectParameter.getFaceArrayString(KinectData.FaceArrayType.POSITION_ONLY));
                    //    break;

                    //case DownloadCommands.Get_face_orientation_point_from_fused_kinect_data://	Get face orientation point from fused kinect data
                    //    sendData((int)DownloadCommands.Get_face_orientation_point_from_fused_kinect_data + "#" + server.fusedKinectParameter.getFaceArrayString(KinectData.FaceArrayType.POINT_ONLY));
                    //    break;

                    //case DownloadCommands.Get_face_orientation_angle_from_fused_kinect_data: //	Get face orientation angle from fused kinect data
                    //    sendData((int)DownloadCommands.Get_face_orientation_angle_from_fused_kinect_data + "#" + server.fusedKinectParameter.getFaceArrayString(KinectData.FaceArrayType.RADIAN_ONLY));
                    //    break;

                    case DownloadCommands.Get_skeleton_position_array_from_fused_kinect_data:    //	Get skeleton position array from fused kinect data
                        sendData((int)DownloadCommands.Get_skeleton_position_array_from_fused_kinect_data + "#" + server.fusedKinectParameter.GetSkeletonArrayString(KinectData.SkeletonArrayType.POSITION_ONLY));
                        break;

                    case DownloadCommands.Get_full_skeleton_array_from_fused_kinect_data:    //	Get full skeleton array from fused kinect data
                        sendData((int)DownloadCommands.Get_full_skeleton_array_from_fused_kinect_data + "#" + server.fusedKinectParameter.GetSkeletonArrayString(KinectData.SkeletonArrayType.FULL_ARRAY));
                        break;

                    case DownloadCommands.Get_upper_body_joint_information_of_skeleton_array_from_fused_kinect_data:    //	Get upper body joint information of skeleton array from fused kinect data
                        sendData((int)DownloadCommands.Get_upper_body_joint_information_of_skeleton_array_from_fused_kinect_data + "#" + server.fusedKinectParameter.GetSkeletonArrayString(KinectData.SkeletonArrayType.UPPER_BODY));
                        break;

                    case DownloadCommands.Get_head_joint_information_of_skeleton_array_from_fused_kinect_data:    //	Get head joint information of skeleton array from fused kinect data
                        sendData((int)DownloadCommands.Get_head_joint_information_of_skeleton_array_from_fused_kinect_data + "#" + server.fusedKinectParameter.GetSkeletonArrayString(KinectData.SkeletonArrayType.HEAD_ONLY));
                        break;

                    //case DownloadCommands.Get_sound_parameters_from_a_specified_kinect://	Get sound parameters from a specified kinect
                    //    dataToSend = "";
                    //    clientcount = 0;

                    //    foreach (myClient mc in server.clientList.Where(cc => cc.isWorking && cc.clientType == (int)clientTypes.KINECT))
                    //    {
                    //        if (kinect_index == -1 || kinect_index == mc.clientID)
                    //        {
                    //            dataToSend += mc.kinectParameter.sp.getParameterString() + "#";
                    //            clientcount++;
                    //        }
                    //    }
                    //    dataToSend = clientcount.ToString() + "#" + dataToSend;
                    //    sendData((int)DownloadCommands.Get_sound_parameters_from_a_specified_kinect + "#" + dataToSend);
                    //    break;

                    //case DownloadCommands.Get_full_face_parameters_from_a_specified_kinect_rotation_in_orientation_point://	Get full face parameters from a specified kinect (rotation in orientation point)
                    //    sendData((int)DownloadCommands.Get_full_face_parameters_from_a_specified_kinect_rotation_in_orientation_point + "#" +sendFaceString(kinect_index, KinectData.FaceArrayType.FULL_ARRAY_POINT));
                    //    break;

                    //case DownloadCommands.Get_full_face_parameters_from_a_specified_kinect_rotation_in_radian://	Get full face parameters from a specified kinect (rotation in radian)
                    //    sendData((int)DownloadCommands.Get_full_face_parameters_from_a_specified_kinect_rotation_in_radian + "#" +sendFaceString(kinect_index, KinectData.FaceArrayType.FULL_ARRAY_RADIAN));
                    //    break;

                    //case DownloadCommands.Get_face_positions_from_a_specified_kinect://	Get face positions from a specified kinect
                    //    sendData((int)DownloadCommands.Get_face_positions_from_a_specified_kinect + "#" +sendFaceString(kinect_index, KinectData.FaceArrayType.POSITION_ONLY));
                    //    break;

                    //case DownloadCommands.Get_face_orientation_point_from_a_specified_kinect://	Get face orientation point from a specified kinect
                    //    sendData((int)DownloadCommands.Get_face_orientation_point_from_a_specified_kinect + "#" +sendFaceString(kinect_index, KinectData.FaceArrayType.POINT_ONLY));
                    //    break;

                    //case DownloadCommands.Get_face_orientation_angle_from_a_specified_kinect://	Get face orientation angle from a specified kinect
                    //    sendData((int)DownloadCommands.Get_face_orientation_angle_from_a_specified_kinect + "#" +sendFaceString(kinect_index, KinectData.FaceArrayType.RADIAN_ONLY));
                    //    break;

                    case DownloadCommands.Get_skeleton_position_array_from_a_specified_kinect:    //	Get skeleton position array from a specified kinect
                        sendData((int)DownloadCommands.Get_skeleton_position_array_from_a_specified_kinect + "#" + sendSkeletonString(kinect_index, KinectData.SkeletonArrayType.POSITION_ONLY));
                        break;

                    case DownloadCommands.Get_full_skeleton_array_from_a_specified_kinect:    //	Get full skeleton array from a specified kinect
                        sendData((int)DownloadCommands.Get_full_skeleton_array_from_a_specified_kinect + "#" + sendSkeletonString(kinect_index, KinectData.SkeletonArrayType.FULL_ARRAY));
                        break;

                    case DownloadCommands.Get_upper_body_joint_information_of_skeleton_array_from_a_specified_kinect:    //	Get upper body joint information of skeleton array from a specified kinect
                        sendData((int)DownloadCommands.Get_upper_body_joint_information_of_skeleton_array_from_a_specified_kinect + "#" + sendSkeletonString(kinect_index, KinectData.SkeletonArrayType.UPPER_BODY));
                        break;

                    case DownloadCommands.Get_head_joint_information_of_skeleton_array_from_a_specified_kinect:    //	Get head joint information of skeleton array from a specified kinect
                        sendData((int)DownloadCommands.Get_head_joint_information_of_skeleton_array_from_a_specified_kinect + "#" + sendSkeletonString(kinect_index, KinectData.SkeletonArrayType.HEAD_ONLY));
                        break;

                    case DownloadCommands.Get_object_frame:
                        //dataToSend = GUIComponents.synchyList.Count.ToString()+ "*";
                        dataToSend = "";
                        int synchyCount = 0;
                        for (int i = 0; i < GUIComponents.synchyList.Count; ++i)
                        {
                            if (GUIComponents.synchyList[i].Center.Z != 0 && GUIComponents.synchyList[i].xUnit.Z != Double.NaN)
                            {
                                ++synchyCount;
                                dataToSend += GUIComponents.synchyList[i].getSynchyData() + "#";
                            }
                        }
                        dataToSend = synchyCount.ToString() + "#" + dataToSend;
                        sendData((int)DownloadCommands.Get_object_frame + "#" + dataToSend);
                        break;

                    default:     //unknow command
                        return(false);
                    }
                    return(true);
                }
                catch
                {
                    //command excution error
                    return(false);
                }
            }