示例#1
0
 public virtual void OnTargetLost(RecoResult recoResult)
 {
     for (var i = 0; i < transform.childCount; i++)
     {
         transform.GetChild(i).gameObject.SetActive(false);
     }
 }
示例#2
0
 public virtual void OnTargetTracked(RecoResult recoResult, Matrix4x4 pose)
 {
     if (isRelativeMove)
     {
         Movement.setTransform(pose, 1.0f / unityPixelRatio);
         Movement.applyTransform();
     }
 }
示例#3
0
 public virtual void OnTargetLost(RecoResult recoResult)
 {
     //Destroy(m_RelatedObject);   //销毁关联对象
     for (var i = 0; i < transform.childCount; i++)
     {
         transform.GetChild(i).gameObject.SetActive(false);
         //transform.GetChild(i).gameObject.GetComponent<GetRelatedObject>().OnTargetLost();
     }
 }
示例#4
0
    public override GameObject createGameObject(RecoResult recoResult)
    {
        GameObject gameObject = new GameObject();

        if (recoResult.keyType == KeyType.IMAGE)
        {
            gameObject.AddComponent <ImageTargetBehaviour>();
        }
        gameObject.transform.parent = transform.parent;
        return(gameObject);
    }
示例#5
0
    public override void OnCloudReco(RecoResult recoResult)
    {
        GameObject gameObject = null;

        gameObject = createGameObject(recoResult);

        if (gameObject != null)
        {
            bindingGameObject(gameObject, recoResult.KeyId);
        }
    }
示例#6
0
 public virtual void OnTargetFound(RecoResult recoResult)
 {
     if (recoResult.IsCloudReco)
     {
         downloadBundleFromHiAR(recoResult);
     }
     for (var i = 0; i < transform.childCount; i++)
     {
         transform.GetChild(i).gameObject.SetActive(true);
     }
 }
示例#7
0
 public virtual void OnTargetFound(RecoResult recoResult)
 {
     //Instantiate(m_RelatedObject);   //创建关联对象
     if (recoResult.IsCloudReco)
     {
         downloadBundleFromHiAR(recoResult);
     }
     for (var i = 0; i < transform.childCount; i++)
     {
         transform.GetChild(i).gameObject.SetActive(true);
         //transform.GetChild(i).gameObject.GetComponent<GetRelatedObject>().OnTargetFound();
     }
 }
示例#8
0
    public override void OnDynamicReco(RecoResult recoResult)
    {
        GameObject gameObject = null;

        gameObject = new GameObject();
        if (recoResult.keyType == KeyType.IMAGE)
        {
            gameObject.AddComponent <ImageTargetBehaviour>();
        }

        Target target = gameObject.GetComponent <Target>();

        target.PixelWidth           = recoResult.Width * 0.01f;
        target.PixelHeight          = recoResult.Height * 0.01f;
        gameObject.transform.parent = transform.parent;
        gameObject.SetActive(true);

        GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

        cube.transform.parent     = gameObject.transform;
        cube.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
        bindingGameObject(gameObject, recoResult.KeyId);
    }
示例#9
0
 public void handleResult(RecoResult result)
 {
     String res = result.getUterrance();
     res = res.Remove(0, 5);
     res = res.Remove(res.Length - 5, 5);
     res = res.Replace('_', ' ');
     if (result.getConfidence() > 0.99999 && lapsamOn == true)
     {
         if (res.ToUpper().Equals("QUERO ABRIR UM PROGRAMA"))
         {
             Talking(1);
             recognitionMode(1);
             microsftEngine.RecognizeAsync();
         }
         else if (res.ToUpper().Equals("QUERO FECHAR UM PROGRAMA"))
         {
             Talking(2);
             recognitionMode(2);
             microsftEngine.RecognizeAsync();
         }
         else if(res.ToUpper().Equals("QUERO ABRIR UM SITE"))
         {
             Talking(4);
             recognitionMode(3);
             microsftEngine.RecognizeAsync(); 
         }
     }
 }
示例#10
0
 public virtual void OnTargetTracked(RecoResult recoResult, Matrix4x4 pose)
 {
 }
        /// <summary>Creates a RecoResult array representation of the results passed in to be returned to the front end</summary>
        /// <param name="results">Recognition result data</param>
        private RecoResult[] getResultArray(Recognition results)
        {
            RecoResult[] resultArray = null;

            int resultCount = results.getResultCount();
            if (resultCount > 0)
            {
            resultArray = new RecoResult[resultCount];
            System.Diagnostics.Debug.WriteLine("Recognizer.Listener.onResults: Result count: " + resultCount);

            for (int i = 0; i < resultCount; i++)
            {
                resultArray[i] = new RecoResult();
                resultArray[i].value = results.getResult(i).getText();
                resultArray[i].confidence = results.getResult(i).getScore();
            }
            }
            return resultArray;
        }
示例#12
0
        /// <summary>
        /// Recognize a shape as if it had the given type
        /// </summary>
        /// <param name="symbol"></param>
        /// <param name="types"></param>
        /// <returns></returns>
        public Dictionary <ShapeType, RecognitionInterfaces.RecognitionResult> RecognitionResults(BitmapSymbol symbol, IEnumerable <ShapeType> types)
        {
            if (_templates.Count == 0)
            {
                throw new Exception("Cannot recognize a symbol when there are no available templates");
            }

            var recResults = new Dictionary <ShapeType, RecognitionInterfaces.RecognitionResult>();

            RecoResult        allResults = symbol.Recognize(_templates);
            List <SymbolRank> results    = allResults.SortedResults(ResultType.FUSION);

            if (results.Count == 0)
            {
                throw new Exception("Image recognition failed on bitmap symbol " + symbol);
            }

            Dictionary <ShapeType, double> alternateTypes = new Dictionary <ShapeType, double>();

            // Loop through them from most-likely to least-likely.
            foreach (SymbolRank result in results)
            {
                if (!recResults.ContainsKey(result.SymbolType))
                {
                    double partialHausdorff = allResults.getSR(ResultType.PARTIAL_HAUSDORFF, result.Symbol).Distance;
                    double modHausdorff     = allResults.getSR(ResultType.MOD_HAUSDORFF, result.Symbol).Distance;
                    double yule             = allResults.getSR(ResultType.YULE, result.Symbol).Distance;
                    double tanimoto         = allResults.getSR(ResultType.TANIMOTO, result.Symbol).Distance;

                    ImageRecognitionResult r = new ImageRecognitionResult(
                        result.SymbolType,
                        partialHausdorff,
                        modHausdorff,
                        yule,
                        tanimoto,
                        getProbabilityFromTotalDistance(result),
                        result.BestOrientation,
                        alternateTypes,
                        result.SymbolName,
                        result.Symbol.toBitmap());

                    recResults.Add(result.SymbolType, r);
                }
                if (!alternateTypes.ContainsKey(result.SymbolType))
                {
                    alternateTypes.Add(result.SymbolType, getProbabilityFromTotalDistance(result));
                }
            }

            foreach (ShapeType type in types)
            {
                if (!recResults.ContainsKey(type))
                {
                    recResults.Add(type, new ImageRecognitionResult(
                                       type,
                                       0, 0, 0, 0, 0, 0, new Dictionary <ShapeType, double>(), "", null));
                }
            }

            return(recResults);
        }
示例#13
0
        /// <summary>
        /// Recognize a shape.
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="featureSketch"></param>
        /// <returns>An ImageRecognitionResult. If you know you are dealing with an ImageRecognizer, you can cast the returned
        /// RecognitionResult to an ImageRecognitionResult safely.</returns>
        public override RecognitionInterfaces.RecognitionResult recognize(Sketch.Shape shape, Featurefy.FeatureSketch featureSketch)
        {
            // Gaaghaghagahga
            // C# has one flaw, and I found it:
            // http://www.simple-talk.com/community/blogs/simonc/archive/2010/07/14/93495.aspx
            // In short, this method must return a generic "RecognitionResult" and cannot return
            // the better "ImageRecognitionResult," even though doing so would be perfectly
            // type-safe. =(

            BitmapSymbol      unknown    = _shapesToSymbols[shape];
            RecoResult        allResults = unknown.Recognize(_templates);
            List <SymbolRank> results    = allResults.SortedResults(ResultType.FUSION);

            if (results.Count > 0)
            {
                // Populate the dictionary of alterateTypes with all of the ShapeTypes in results
                var alternateTypes = new Dictionary <ShapeType, double>();

#if JESSI
                Console.WriteLine();
                Console.WriteLine("\nRecognition results: ");
#endif

                foreach (SymbolRank result in results)
                {
                    if (!alternateTypes.ContainsKey(result.SymbolType))
                    {
                        alternateTypes.Add(result.SymbolType, getProbabilityFromTotalDistance(result));
                    }
#if JESSI
                    if (debug)
                    {
                        Console.WriteLine(result.SymbolType + " with template " + result.SymbolName);
                    }
#endif
                }

                ShapeType type = results[0].SymbolType;          // the most likely type

                float probability = (float)alternateTypes[type]; // grab the probability of our most likely type

                alternateTypes.Remove(type);                     // the most likely type is NOT an alternate

                double confidence   = getProbabilityFromTotalDistance(results[0]);
                double orientation  = results[0].BestOrientation;
                string templateName = results[0].SymbolName;
                System.Drawing.Bitmap templateBitmap = results[0].Symbol.toBitmap();

                double partialHausdorff = allResults.getSR(ResultType.PARTIAL_HAUSDORFF, results[0].Symbol).Distance;
                double modHausdorff     = allResults.getSR(ResultType.MOD_HAUSDORFF, results[0].Symbol).Distance;
                double yule             = allResults.getSR(ResultType.YULE, results[0].Symbol).Distance;
                double tanimoto         = allResults.getSR(ResultType.TANIMOTO, results[0].Symbol).Distance;

                return(new ImageRecognitionResult(
                           type,
                           partialHausdorff,
                           modHausdorff,
                           yule,
                           tanimoto,
                           confidence,
                           orientation,
                           alternateTypes,
                           templateName,
                           templateBitmap));
            }

            throw new Exception("Image recognition failed on shape " + shape);
        }