Пример #1
0
    void Start()
    {
        featureMapCreator = new FeatureMapCreator();
        sceneLoader       = GameObject.Find("SceneLoader").GetComponent <SceneLoader>();
        socketConnector   = new Connector();
        socketConnector.establishConnection(60000);                                    // 60000

        model               = getModelNameAndSize(sceneLoader.modelPicker.ToString()); // get model type
        visualisationMode   = sceneLoader.mode;
        inputImageSizeValue = sceneLoader.inputImageSizeValue;

        if (model.Equals("17"))
        {
            modelPath = sceneLoader.pathModel;
        }
        else
        {
            modelPath = "None";
        }

        if (inputImageSizeValue != 0)
        {
            model += " " + inputImageSizeValue.ToString();
        }

        if (visualisationMode == 1)
        {
            videoPath = sceneLoader.pathVideo;
        }
        else
        {
            videoPath = "None";
        }

        recordTime = sceneLoader.loadingTime;                                          /// get loading time
        frameRate  = 1 / sceneLoader.framesPerSecond;                                  // get framerate update
        numThreads = sceneLoader.threads;                                              // get number of threads

        HashSet <string> .Enumerator layers = sceneLoader.layersToGet.GetEnumerator(); /// get layers to see
        while (layers.MoveNext())
        {
            layersToSee = layersToSee + " " + layers.Current;
        }
        byte[] start_server = Encoding.ASCII.GetBytes("start " + numThreads + " " + model + " " + modelPath + " " + visualisationMode + " " + videoPath + " " + sceneLoader.framesPerSecond + " " + layersToSee + "\n");

        var z = socketConnector.SendAndReceive(start_server);

        Debug.Log("I started deserialization");
        feature = MessagePackSerializer.Deserialize <Dictionary <string, Dictionary <string, ushort[][]> > >(z);
        Debug.Log("I finished deserialization");
        featureMapsObjects = featureMapCreator.makeFeature(featuresTemplate, featuresPredictionsTemplate, feature);

        for (int x = 1; x <= numThreads; x++)
        {
            new ThreadComponent(x, this, featureMapCreator).init();
            Thread.Sleep(1000);
        }
    }
 public ThreadComponent(int index, Main main, FeatureMapCreator featureMapCreator)
 {
     this.featureMapCreator = featureMapCreator;
     this.index = index;
     this.main = main;
 }