コード例 #1
0
    // Checks if currentCamera is publishing any image data and destroys image subsciber afterwards (improves runtime).
    // i = index of currentCamera in diconary.
    IEnumerator CheckCamera(int i, ImageSubscriberMod currentImageSubscriber, GameObject currentCamera, int amountOfCameras)
    {
        yield return(new WaitForSecondsRealtime(5));

        Debug.Log("CameraCreator.cs: Loading Camera image of: " + topics[i]);

        if (!currentImageSubscriber.oneMessageReceived)
        {
            Debug.Log("CameraCreator.cs: Topic: " + topics[i] + " not published");
            Destroy(currentCamera);
        }
        else
        {
            string topic     = topics[i];
            byte[] imageData = currentImageSubscriber.imageData;

            try
            {
                dict.Add(topic, imageData);
            }
            catch (ArgumentException)
            {
                Debug.LogError("CameraCreator.cs: An element with Key = \"txt\" already exists. Duplicate of camera exists");
            }
        }
        // If currentCamera == last camera all cameras that are not publishing any data are sorted out.
        if (i == (amountOfCameras - 1))
        {
            topicsSorted = !topicsSorted;
        }

        Destroy(currentImageSubscriber);
    }
コード例 #2
0
    // Waits 5 seconds, gets current camera image and stores name and corresponding imaga data in a dictonary.
    // last = true, if currentCamera is the last one to be updated.
    IEnumerator UpdateCameraImages(ImageSubscriberMod currentImageSubscriber, string currentCamera, bool last)
    {
        yield return(new WaitForSeconds(5));

        if (!currentImageSubscriber.oneMessageReceived)
        {
            Debug.Log("CameraCreator.cs: Topic: " + currentImageSubscriber.Topic + " not published");
        }
        else
        {
            byte[] imageData = currentImageSubscriber.imageData;
            update.Add(currentCamera, imageData);
        }

        Destroy(currentImageSubscriber);

        if (last)
        {
            dict = update;
            Debug.Log("CameraCreator.cs: Camera Images Updated");
            finishedUpdating = true;
        }
    }