コード例 #1
0
        /// <summary>
        /// Process the image to figure out whether a marker has been detected
        /// If it has, it'll notify it
        /// </summary>
        /// <param name="imageData">The captured image</param>
        /// <param name="imageWidth">Width of the image</param>
        /// <param name="imageHeight">Height of the image</param>
        private void ProcessImage(List <byte> imageData, int imageWidth, int imageHeight)
        {
#if WINDOWS_UWP
            detector.Detect(imageData, imageWidth, imageHeight, markerSize);
            Vector3    pos;
            Quaternion rot;
            int[]      detectedMarkerIds;
            detector.GetMarkerIds(out detectedMarkerIds);

            for (int i = 0; i < detectedMarkerIds.Length; i++)
            {
                if (!detector.GetMarkerPose(detectedMarkerIds[i], out pos, out rot))
                {
                    Debug.Log("Can't resolve marker position for marker id: " + detectedMarkerIds[i]);
                    continue;
                }
                else
                {
                    if (OnMarkerDetected != null)
                    {
                        OnMarkerDetected(detectedMarkerIds[i], pos, rot);
                    }
                }
            }
#endif
        }
コード例 #2
0
        /// <summary>
        /// Process the image to figure out whether a marker has been detected
        /// If it has, it'll notify it
        /// </summary>
        /// <param name="imageData">The captured image</param>
        /// <param name="imageWidth">Width of the image</param>
        /// <param name="imageHeight">Height of the image</param>
        private void ProcessImage(List <byte> imageData, int imageWidth, int imageHeight)
        {
#if WINDOWS_UWP
            detector.Detect(imageData, imageWidth, imageHeight, markerSize);
            Vector3      pos;
            Quaternion   rot;
            Vector3[]    pos_group = new Vector3[markerBoard];
            Quaternion[] rot_group = new Quaternion[markerBoard];
            int[]        detectedMarkerIds;
            detector.GetMarkerIds(out detectedMarkerIds);
            Debug.Log("################### ProcessImage detectedMarkerIds.Length " + detectedMarkerIds.Length);
            if (detectedMarkerIds.Length == markerBoard)
            {
                if (!stationaryRefFrameRecenter)
                {
                    UnityEngine.XR.InputTracking.Recenter();
                    stationaryRefFrameRecenter = true;
                }
                else
                {
                    for (int i = 0; i < detectedMarkerIds.Length; i++)
                    {
                        if (!detector.GetMarkerPose(detectedMarkerIds[i], out pos, out rot))
                        {
                            Debug.Log("Can't resolve marker position for marker id: " + detectedMarkerIds[i]);
                            continue;
                        }
                        else
                        {
                            Debug.Log("################### ProcessImage -> detectedMarkerIds " + detectedMarkerIds[i]);
                            Debug.Log("################### ProcessImage -> pos " + pos.ToString());
                            Debug.Log("################### ProcessImage -> rot " + rot.ToString());
                            pos_group[i] = pos;
                            rot_group[i] = rot;
                        }
                    }
                    StopCapture();
                    SuccessSound.Play();
                    HologramOnARuco(detectedMarkerIds, pos_group, rot_group);
                    GetComponent <CameraCaptureHololens>().enabled   = false;
                    GetComponent <MarkerDetectionHololens>().enabled = false;
                }
            }
#endif
        }
コード例 #3
0
        /// <summary>
        /// Process the image to figure out whether a marker has been detected
        /// If it has, it'll notify it
        /// </summary>
        /// <param name="imageData">The captured image</param>
        /// <param name="imageWidth">Width of the image</param>
        /// <param name="imageHeight">Height of the image</param>
        private void ProcessImage(List <byte> imageData, int imageWidth, int imageHeight)
        {
#if WINDOWS_UWP
            //Debug.Log("################### ProcessImage!");
            detector.Detect(imageData, imageWidth, imageHeight, markerSize);
            Vector3    pos;
            Quaternion rot;
            int[]      detectedMarkerIds;
            detector.GetMarkerIds(out detectedMarkerIds);

            for (int i = 0; i < detectedMarkerIds.Length; i++)
            {
                if (!detector.GetMarkerPose(detectedMarkerIds[i], out pos, out rot))
                {
                    Debug.Log("Can't resolve marker position for marker id: " + detectedMarkerIds[i]);
                    continue;
                }
                else
                {
                    //Debug.Log("################### ProcessImage -> if 111!");
                    Debug.Log("################### ProcessImage -> detectedMarkerIds " + detectedMarkerIds[i]);
                    Debug.Log("################### ProcessImage -> pos " + pos.ToString());
                    Debug.Log("################### ProcessImage -> rot " + rot.ToString());
                    SuccessSound.Play();
                    HologramOnARuco(detectedMarkerIds[i], pos, rot);

                    /*
                     * if(OnMarkerDetected != null)
                     * {
                     *  Debug.Log("################### ProcessImage -> if 222!");
                     *  OnMarkerDetected(detectedMarkerIds[i], pos, rot);
                     *  Debug.Log("################### ProcessImage -> OnMarkerDetected -> pos "+pos);
                     *  Debug.Log("################### ProcessImage -> OnMarkerDetected -> rot "+rot);
                     * }
                     */
                    StopCapture();
                }
            }
#endif
        }