예제 #1
0
    public void OnTangoImageAvailableEventHandler(Tango.TangoEnums.TangoCameraId cameraId,
                                                  Tango.TangoUnityImageData imageBuffer)
    {
        TangoSupport.DetectMarkers(imageBuffer, cameraId,
                                   TangoSupport.MarkerType.QRCODE, MARKER_SIZE, markerList);

        if (markerList.Count > 0)
        {
            TangoSupport.Marker marker = markerList[0];

            qrcodePlane.transform.position = marker.m_translation;
            qrcodePlane.transform.rotation = marker.m_orientation;

            var bottomToTop = marker.m_corner3DP3 - marker.m_corner3DP0;
            var leftToRight = marker.m_corner3DP1 - marker.m_corner3DP0;
            plane.transform.localScale = new Vector3(leftToRight.magnitude, 1, bottomToTop.magnitude) * 0.1f;
        }
    }
예제 #2
0
    /// <summary>
    /// Detect one or more markers in the input image.
    /// </summary>
    /// <param name="cameraId">
    /// Returned camera ID.
    /// </param>
    /// <param name="imageBuffer">
    /// Color camera image buffer.
    /// </param>
    public void OnTangoImageAvailableEventHandler(TangoEnums.TangoCameraId cameraId,
                                                  TangoUnityImageData imageBuffer)
    {
        TangoSupport.DetectMarkers(imageBuffer, cameraId,
                                   TangoSupport.MarkerType.ARTAG, MARKER_SIZE, m_markerList);

        for (int i = 0; i < m_markerList.Count; ++i)
        {
            TangoSupport.Marker marker = m_markerList[i];
            int markerId    = Convert.ToInt32(marker.m_content);
            int planetIndex = (markerId - 1) % m_planets.Length;

            if (m_planets[planetIndex] == null)
            {
                m_planets[planetIndex] = Instantiate <GameObject>(m_planetsPrefabs[planetIndex]);
            }

            m_planets[planetIndex].transform.position = marker.m_translation;
            m_planets[planetIndex].transform.rotation = marker.m_orientation;
        }
    }
    /// <summary>
    /// Detect one or more markers in the input image.
    /// </summary>
    /// <param name="cameraId">
    /// Returned camera ID.
    /// </param>
    /// <param name="imageBuffer">
    /// Color camera image buffer.
    /// </param>
    public void OnTangoImageAvailableEventHandler(TangoEnums.TangoCameraId cameraId,
                                                  TangoUnityImageData imageBuffer)
    {
        TangoSupport.DetectMarkers(imageBuffer, cameraId,
                                   TangoSupport.MarkerType.ARTAG, MARKER_SIZE, m_markerList);

        for (int i = 0; i < m_markerList.Count; ++i)
        {
            TangoSupport.Marker marker = m_markerList[i];

            if (m_markerObjects.ContainsKey(marker.m_content))
            {
                GameObject markerObject = m_markerObjects[marker.m_content];
                markerObject.GetComponent <MarkerVisualizationObject>().SetMarker(marker);
            }
            else
            {
                GameObject markerObject = Instantiate <GameObject>(m_markerPrefab);
                m_markerObjects.Add(marker.m_content, markerObject);
                markerObject.GetComponent <MarkerVisualizationObject_Custom>().SetMarker(marker);
            }
        }
    }