示例#1
0
 //for game play
 void LategamePlay()
 {
     LoadingRotation.gameplay();
 }
示例#2
0
    /// <summary>
    /// Set the Tags as Text of the last label created.
    /// </summary>
    public void FinaliseLabel(AnalysisRootObject analysisObject)
    {
        if (analysisObject != null && analysisObject.predictions != null)
        {
            lastLabelPlacedText = lastLabelPlaced.GetComponent <TextMesh>();
            // Sort the predictions to locate the highest one
            List <Prediction> sortedPredictions = new List <Prediction>();
            sortedPredictions = analysisObject.predictions.OrderBy(p => p.probability).ToList();

            //TOO remove below

            /*            quadRenderer = quad.GetComponent<Renderer>() as Renderer;
             *          Bounds quadBounds = quadRenderer.bounds;
             *          lastLabelPlaced.transform.parent = quad.transform;
             *          // Vector3 labelPosition = new Vector3((float)-quadBounds.size.normalized.x/2, (float)-quadBounds.size.normalized.y/2, 0);
             *          Vector3 labelPosition = new Vector3(0, 0, 0);
             *          lastLabelPlaced.transform.localPosition = labelPosition;
             *          lastLabelPlacedText.text = "";//bestPrediction.tagName;
             *          Debug.Log("Repositioning Label");
             *          Vector3 headPosition = Camera.main.transform.position;
             *          RaycastHit objHitInfo;
             *          Vector3 objDirection = lastLabelPlaced.position;
             *
             *          if (Physics.Raycast(captureTimeHeadPosition, objDirection, out objHitInfo, 30.0f, captureTimeRaycastMask))
             *          {
             *              lastLabelPlaced.position = objHitInfo.point;
             *              latestDataPanelPosition = objHitInfo.point;
             *          }
             *          ObjectData data = envData.getObjectData("water bottle");
             *          data.probability = 0.90;
             *          StartCoroutine(makeDataPanel(data, latestDataPanelPosition, latestDataPanelRotation));
             *          IEnumerator coroutine = ResetLoadingUI(lastLabelPlacedText, lastLoadingIcon, 5.0f);
             *          StartCoroutine(coroutine); */
            //TODO uncomment below
            Prediction bestPrediction = new Prediction();

            if (sortedPredictions.Count > 0)
            {
                bestPrediction = sortedPredictions[sortedPredictions.Count - 1];
            }
            else
            {
                bestPrediction.probability = 0;
            }

            if (bestPrediction.probability > probabilityThreshold)
            {
                quadRenderer = quad.GetComponent <Renderer>() as Renderer;
                Bounds quadBounds = quadRenderer.bounds;

                // Position the label as close as possible to the Bounding Box of the prediction
                // At this point it will not consider depth
                lastLabelPlaced.transform.parent = quad.transform;
                Vector3 labelPosition = CalculateBoundingBoxPosition(quadBounds, bestPrediction.boundingBox);
                lastLabelPlaced.transform.localPosition = labelPosition;

                // Set the tag text
                lastLabelPlacedText.text = "";//bestPrediction.tagName;


                // Cast a ray from the user's head to the currently placed label, it should hit the object detected by the Service.
                // At that point it will reposition the label where the ray HL sensor collides with the object,
                // (using the HL spatial tracking)
                Debug.Log("Repositioning Label");
                Vector3    headPosition = Camera.main.transform.position;
                RaycastHit objHitInfo;
                Vector3    objDirection = lastLabelPlaced.position;

                if (Physics.Raycast(captureTimeHeadPosition, objDirection, out objHitInfo, 30.0f, captureTimeRaycastMask))
                {
                    lastLabelPlaced.position = objHitInfo.point;
                    latestDataPanelPosition  = objHitInfo.point;
                }
                Debug.Log("Success");

                ObjectData data = envData.getObjectData(bestPrediction.tagName);
                data.probability = bestPrediction.probability;
                StartCoroutine(MakeDataPanel(data, latestDataPanelPosition, latestDataPanelRotation));
            }
            else
            {
                LoadingRotation loadingRotation = lastLoadingIcon.GetComponent <LoadingRotation>();
                loadingRotation.Failed();
            }

            IEnumerator coroutine = ResetLoadingUI(lastLabelPlacedText, lastLoadingIcon, 5.0f);
            StartCoroutine(coroutine);
        }

        // Reset the color of the cursor
        cursor.GetComponent <Renderer>().material.color = Color.yellow;

        // Stop the analysis process
        ImageCapture.Instance.ResetImageCapture();
    }