Exemplo n.º 1
0
        public static string GetSerialNumber()
        {
            string data = null;

            MetaCoreInterop.meta_get_serial_number(ref data);
            return(data);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets a snapshot of the device status.
        /// </summary>
        /// <returns>The device status snapshot</returns>
        public static DeviceStatusSnapshot GetDeviceStatus()
        {
            int deviceStatus, connectionStatus, streamingStatus = 0;

            MetaCoreInterop.meta_get_device_status(out deviceStatus, out connectionStatus, out streamingStatus);
            return(new DeviceStatusSnapshot((DeviceStatusSnapshot.DeviceStatus)deviceStatus,
                                            (DeviceStatusSnapshot.ConnectionStatus)connectionStatus,
                                            streamingStatus));
        }
Exemplo n.º 3
0
        internal static void ToggleDebugDrawing(bool targetState)
        {
            var targetStateString = targetState ? "true" : "false";
            var attribute         = "draw";

            MetaCoreInterop.meta_update_attribute("HandsDataPreprocessingBlock", attribute, targetStateString);
            MetaCoreInterop.meta_update_attribute("HandSegmentationBlock", attribute, targetStateString);
            MetaCoreInterop.meta_update_attribute("HandTrackingBlock", attribute, targetStateString);
            MetaCoreInterop.meta_update_attribute("HandFeatureExtractionBlock", attribute, targetStateString);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Updated a coco attribute.
        /// </summary>
        /// <param name="blockName">Name of block to update.</param>
        /// <param name="attributeName">Name of paramiter to update.</param>
        /// <param name="attributeValue">Target string value for specified attribute.</param>
        /// <returns></returns>
        public static bool SetAttribute(string blockName, string attributeName, string attributeValue)
        {
            if (!MetaCoreInterop.meta_update_attribute(blockName, attributeName, attributeValue))
            {
                Debug.Log("Failed to update attribute: " + blockName + " " + attributeName);
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Initializes the system (sensors, algorithms, etc). Returns false on failure, true on success.
        /// </summary>
        /// <param name="json_config_file">Configuration file with which to initialize coco</param>
        /// <param name="json_config_file">boolean to specify if we are running in development environment or production
        // environment</param>
        /// <param name="initialize_web_server">Specify weather to initialize stats web server.</param>
        public static bool Start()
        {
            InitStatus result = MetaCoreInterop.meta_start();

            if (result != InitStatus.SUCCESS)
            {
                Debug.LogError("Meta initialization failed with result: " + result);
                return(false);
            }
            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Applies latest head pose, if available to referenced transform
        /// </summary>
        /// <param name="transformToApply">Transform to apply head pose to.</param>
        public static void ApplyHeadPose(ref Transform transformToApply)
        {
            var pose = MetaCoreInterop.meta_get_latest_head_pose();

            transformToApply.localPosition = new Vector3(pose.position.x,
                                                         pose.position.y,
                                                         pose.position.z);

            transformToApply.localRotation = new Quaternion(pose.rotation.x,
                                                            pose.rotation.y,
                                                            pose.rotation.z,
                                                            pose.rotation.w);
        }
Exemplo n.º 7
0
        private void OnDisable()
        {
            if (_enableWebcamPlugin)
            {
                StopCoroutine(UpdatePlugin());
                WebcamInterop.Stop();
            }

            MetaCoreInterop.meta_enable_rgb_stream(false);

            _drawRgb.Clear();
            _drawComposite.Clear();
            _textureRequest = false;
        }
Exemplo n.º 8
0
        public static bool GetPose(string source, string target, ref byte[] buffer, out PoseType poseType)
        {
            if (MetaCoreInterop.meta_get_pose(source, target, buffer))
            {
                poseType = new PoseType();

                return(false);
            }

            var byteBuffer = new FlatBuffers.ByteBuffer(buffer);

            poseType = PoseType.GetRootAsPoseType(byteBuffer);
            return(true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Returns latest frame's hands.
        /// </summary>
        /// <param name="buffer">Byte buffer to use for deserialization.</param>
        /// <param name="frameHands">FrameHands datastructure to populate.</param>
        /// <returns></returns>
        public static bool GetFrameHandsFlatbufferObject(ref byte[] buffer, out FrameHands frameHands)
        {
            if (MetaCoreInterop.meta_get_frame_hands(buffer) == 0)
            {
                frameHands = new FrameHands();

                return(false);
            }

            var byteBuffer = new FlatBuffers.ByteBuffer(buffer);

            frameHands = FrameHands.GetRootAsFrameHands(byteBuffer);
            return(true);
        }
Exemplo n.º 10
0
        private void OnEnable()
        {
            if (_enableWebcamPlugin)
            {
                // Start webcam rendering
                WebcamInterop.Initalize(_texturePtr, PluginFps);
                WebcamInterop.Run();
            }

            MetaCoreInterop.meta_enable_rgb_stream(true);

            InitializeMaterial();

            if (_enableWebcamPlugin)
            {
                StartCoroutine(UpdatePlugin());
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes the system (sensors, algorithms, etc). Returns false on failure, true on success.
        /// </summary>
        /// <param name="json_config_file">Configuration file with which to initialize coco</param>
        /// <param name="json_config_file">boolean to specify if we are running in development environment or production
        // environment</param>
        /// <param name="initialize_web_server">Specify weather to initialize stats web server.</param>
        public static bool Start(string json_config_file = "", bool is_development_environment = true, bool initialize_web_server = false)
        {
            // -- Initialize library
            InitStatus result = MetaCoreInterop.meta_init(json_config_file, is_development_environment);

            if (result != InitStatus.NO_ERROR)
            {
                // Debug.LogError("Meta initialization result: " + result);
                return(false);
            }

            // -- Start MetaCore
            MetaCoreInterop.meta_start(initialize_web_server);

            // Note: Disabled; see MET-1833.
            // MetaCoreInterop.meta_wait_start_complete();

            return(true);
        }
        public static bool GetTransform(MetaCoreInterop.MetaCoordinateFrame destination, MetaCoreInterop.MetaCoordinateFrame source, ref Matrix4x4 matrix)
        {
            MetaCoreInterop.MetaMatrix44 mat = new MetaCoreInterop.MetaMatrix44();
            if (!MetaCoreInterop.meta_get_transform(destination, source, ref mat))
            {
                return(false);
            }

            matrix[0, 0] = mat.m00;
            matrix[0, 1] = mat.m01;
            matrix[0, 2] = mat.m02;
            matrix[0, 3] = mat.m03;

            matrix[1, 0] = mat.m10;
            matrix[1, 1] = mat.m11;
            matrix[1, 2] = mat.m12;
            matrix[1, 3] = mat.m13;

            matrix[2, 0] = mat.m20;
            matrix[2, 1] = mat.m21;
            matrix[2, 2] = mat.m22;
            matrix[2, 3] = mat.m23;

            matrix[3, 0] = mat.m30;
            matrix[3, 1] = mat.m31;
            matrix[3, 2] = mat.m32;
            matrix[3, 3] = mat.m33;

            // conver from right to left handed coordinate system
            Matrix4x4 m_right_to_left = Matrix4x4.identity;

            m_right_to_left[1, 1] *= -1;
            matrix = m_right_to_left * matrix * m_right_to_left.inverse;

            return(true);
        }
Exemplo n.º 13
0
 /// <summary>
 /// Stops currently running coco instance.
 /// </summary>
 public static void Stop()
 {
     MetaCoreInterop.meta_stop();
 }
Exemplo n.º 14
0
 /// <summary>
 /// Coroutine which waits for Meta Configuration to complete
 /// then calls an Action
 /// </summary>
 /// <param name="action">Action to call on Meta Ready</param>
 /// <returns></returns>
 public static IEnumerator MetaReady(Action action)
 {
     MetaCoreInterop.meta_wait_start_complete();
     action();
     yield return(null);
 }
Exemplo n.º 15
0
 public static bool GetPath(MetaVariable variable, out string result)
 {
     return(MetaCoreInterop.get_meta_variable(variable, out result));
 }