// public methods

    /// @brief Initialize the logger
    /// 
    /// This method is responsible for initialization of the logger. 
    /// @note It is assumed that all inheriting objects will have an "Init" method which will call this method.
    /// @param logger the logger object we will enter logs into
    /// @return true on success, false on failure. 
    protected bool InitLogger(NIEventLogger logger)
    {
        if(logger!=null)
            logger.Log("In " + this.GetType() + ":Init(" + logger + ")", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Verbose);
        m_Logger = logger;
        return true;
	}
Example #2
0
    /// editor OnInspectorGUI to control the NIEventLogger properties
    override public void OnInspectorGUI()
    {
        EditorGUI.indentLevel = 0;
        EditorGUIUtility.LookLikeInspector();
        NIEventLogger logger = target as NIEventLogger;

        EditorGUILayout.LabelField("Categories to show", "");
        EditorGUI.indentLevel += 2;
        for (int i = 0; i < logger.m_categoriesToShow.Length; i++)
        {
            logger.m_categoriesToShow[i] = EditorGUILayout.Toggle("" + (NIEventLogger.Categories)i, logger.m_categoriesToShow[i]);
        }
        EditorGUI.indentLevel -= 2;
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Sources to show", "");
        EditorGUI.indentLevel += 2;
        for (int i = 0; i < logger.m_sourcesToShow.Length; i++)
        {
            logger.m_sourcesToShow[i] = EditorGUILayout.Toggle("" + (NIEventLogger.Sources)i, logger.m_sourcesToShow[i]);
        }
        EditorGUI.indentLevel -= 2;
        EditorGUILayout.Space();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Example #3
0
    // public methods

    /// @brief Initialize the logger
    ///
    /// This method is responsible for initialization of the logger.
    /// @note It is assumed that all inheriting objects will have an "Init" method which will call this method.
    /// @param logger the logger object we will enter logs into
    /// @return true on success, false on failure.
    protected bool InitLogger(NIEventLogger logger)
    {
        if (logger != null)
        {
            logger.Log("In " + this.GetType() + ":Init(" + logger + ")", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Verbose);
        }
        m_Logger = logger;
        return(true);
    }
Example #4
0
 /// @brief Initialize the image node.
 /// 
 /// This method initializes the image node. It assumes the context is already valid (otherwise we fail).
 /// @note - Since we use a singleton pattern, multiple initializations will simply delete the old
 /// node and create a new one!
 /// @note - It is the responsibility of the initializer to call @ref Dispose.
 /// @param context the context used
 /// @param logger the logger object we will enter logs into
 /// @return true on success, false on failure. 
 public bool Init(NIEventLogger logger, NIContext context)
 {
     Dispose(); // to make sure we are not initialized
     if (InitWithContext(logger, context) == false)
         return false; 
     m_image = context.CreateNode(NodeType.Image) as ImageGenerator;
     if(m_image==null)
     {
         Dispose();
         return false;
     }
     return true;
 }
Example #5
0
    /// @brief Initialize the hand control
    ///
    /// This method provides the initialization for the hands control initializing all internal objects.
    /// It assumes the context is already valid (otherwise we fail).
    /// @note - Since we use a singleton pattern, multiple initializations will simply delete the old
    /// objects and create new ones!
    /// @note - It is the responsibility of the initializer to call @ref Dispose.
    /// @param context the context to use
    /// @param focusGesture the gesture used for focusing (i.e. this is aimed to set the hand which we will follow)
    /// @param refocusGesture the gesture used for refocus (when we lose focus temporarily)
    /// @param logger the logger object we will enter logs into
    /// @return true on success, false on failure.
    public bool Init(NIEventLogger logger, NIContext context, string focusGesture, string refocusGesture)
    {
        Dispose(); // to make sure we are not initialized
        if (InitWithContext(logger, context) == false)
        {
            return(false);
        }
        // we will create the user gestures and hands which are needed for the session manager
        // but are not needed externally (as we never access them directly).
        ProductionNode node = context.CreateNode(NodeType.Gesture);

        if (node == null)
        {
            Dispose();
            return(false);
        }
        m_internalNodes.Add(node);
        node = context.CreateNode(NodeType.Hands) as HandsGenerator;
        if (node == null)
        {
            Dispose();
            return(false);
        }
        m_internalNodes.Add(node);
        try
        {
            NINITECheckVersion.Instance.ValidatePrerequisite();
            m_sessionManager = new SessionManager(context.BasicContext, focusGesture, refocusGesture);
            if (refocusGesture.CompareTo("") == 0)
            {
                m_sessionManager.QuickRefocusTimeout = 0;
            }
            else
            {
                m_sessionManager.QuickRefocusTimeout = 15000;
            }
            m_sessionManager.SessionStart += new System.EventHandler <PositionEventArgs>(HandsControlSessionStart);
            m_sessionManager.SessionEnd   += new System.EventHandler(HandsControlSessionEnd);
            m_pointControl = new PointControl();
            m_sessionManager.AddListener(m_pointControl);
            m_pointControl.PrimaryPointDestroy += new System.EventHandler <IdEventArgs>(SessionLostFocus);
        }
        catch (System.Exception ex)
        {
            Log("failed to create session manager with error " + ex.Message, NIEventLogger.Categories.Errors, NIEventLogger.Sources.Hands);
            Dispose();
            return(false);
        }

        return(true);
    }
Example #6
0
 /// @brief Initialize the image node.
 ///
 /// This method initializes the image node. It assumes the context is already valid (otherwise we fail).
 /// @note - Since we use a singleton pattern, multiple initializations will simply delete the old
 /// node and create a new one!
 /// @note - It is the responsibility of the initializer to call @ref Dispose.
 /// @param context the context used
 /// @param logger the logger object we will enter logs into
 /// @return true on success, false on failure.
 public bool Init(NIEventLogger logger, NIContext context)
 {
     Dispose(); // to make sure we are not initialized
     if (InitWithContext(logger, context) == false)
     {
         return(false);
     }
     m_image = context.CreateNode(NodeType.Image) as ImageGenerator;
     if (m_image == null)
     {
         Dispose();
         return(false);
     }
     return(true);
 }
     // public methods

    /// @brief Initializer of the logger and context 
    /// 
    /// This method is responsible for initializing the context and logger (it should be used
    /// instead of the InitLogger method as it calls it internally!
    /// @note it will always return false doing nothing if the object is already valid!
    /// @note the context must be valid for this to work! If the context is invalid it will also invalidate this object
    /// @param logger the logger object we will enter logs into
    /// @param context the context this relates to
    /// @return true on success, false on failure. 
    public bool InitWithContext(NIEventLogger logger, NIContext context)
    {
        if(Valid)
            return false;
        if (context.Valid == false)
        {
            Dispose();
            return false;
        }
        if(InitLogger(logger)==false)
        {
            Dispose();
            return false;
        }
        Log("initializing with context", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects,NIEventLogger.VerboseLevel.Verbose);
        m_context = context;
        return true;
	}
    /// editor OnInspectorGUI to control the NIEventLogger properties
    override public void OnInspectorGUI()
    {
        EditorGUI.indentLevel = 0;
        EditorGUIUtility.LookLikeInspector();
        NIEventLogger logger = target as NIEventLogger;

        EditorGUILayout.LabelField("Categories to show", "");
        EditorGUI.indentLevel += 2;

        if (Initialized == false)
        {
            // this is aimed to make sure the categories and sources list will be updated when
            // the enums change. Therefore we use the static variable to make sure the test is done
            // only once and not every frame.
            if (logger.InitCategoriesList() || logger.InitSourcesList())
            {
                EditorUtility.SetDirty(target);
            }
            Initialized = true;
        }
        for (int i = 0; i < logger.m_categoriesToShow.Length; i++)
        {
            logger.m_categoriesToShow[i] = EditorGUILayout.Toggle("" + (NIEventLogger.Categories)i, logger.m_categoriesToShow[i]);
        }
        EditorGUI.indentLevel -= 2;
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Sources to show", "");
        EditorGUI.indentLevel += 2;
        for (int i = 0; i < logger.m_sourcesToShow.Length; i++)
        {
            logger.m_sourcesToShow[i] = EditorGUILayout.Toggle("" + (NIEventLogger.Sources)i, logger.m_sourcesToShow[i]);
        }
        logger.m_minLevelToShow = (NIEventLogger.VerboseLevel)EditorGUILayout.EnumPopup("Minimum log level", (System.Enum)logger.m_minLevelToShow);
        EditorGUI.indentLevel  -= 2;
        EditorGUILayout.Space();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
    /// @brief Method to reload all nodes
    ///
    /// This method is used by inspectors to load and unload the relevant nodes when those are currently
    /// not loaded.
    public static void InspectorReloadAnInstance()
    {
        NIEventLogger         loggerInstance  = FindObjectOfType(typeof(NIEventLogger)) as NIEventLogger;
        bool                  awakenLogger    = false;
        NIQuery               queryInstance   = FindObjectOfType(typeof(NIQuery)) as NIQuery;
        bool                  awakenQuery     = false;
        OpenNISettingsManager managerInstance = FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;

        if (managerInstance == null)
        {
            Debug.LogError("Please Add an OpenNISettingsManager object to the scene");
            return;
        }
        if (managerInstance.Valid)
        {
            return; // it is already up, nothing to do...
        }
        if (loggerInstance != null && loggerInstance.Initialized == false)
        {
            loggerInstance.Awake();
            awakenLogger = true;
        }
        if (queryInstance != null && queryInstance.Initialized == false)
        {
            queryInstance.Awake();
            awakenQuery = true;
        }
        managerInstance.Awake();
        if (managerInstance.UserSkeletonValid == false)
        {
            Debug.LogError("No user generator available. Please make sure the user generator is active");
        }
        managerInstance.OnDestroy();
        if (awakenQuery)
        {
            queryInstance.OnDestroy();
        }
        if (awakenLogger)
        {
            queryInstance.OnDestroy();
        }
    }
Example #10
0
    // public methods

    /// @brief Initializer of the logger and context
    ///
    /// This method is responsible for initializing the context and logger (it should be used
    /// instead of the InitLogger method as it calls it internally!
    /// @note it will always return false doing nothing if the object is already valid!
    /// @note the context must be valid for this to work! If the context is invalid it will also invalidate this object
    /// @param logger the logger object we will enter logs into
    /// @param context the context this relates to
    /// @return true on success, false on failure.
    public bool InitWithContext(NIEventLogger logger, NIContext context)
    {
        if (Valid)
        {
            return(false);
        }
        if (context.Valid == false)
        {
            Dispose();
            return(false);
        }
        if (InitLogger(logger) == false)
        {
            Dispose();
            return(false);
        }
        Log("initializing with context", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Verbose);
        m_context = context;
        return(true);
    }
Example #11
0
    /// @brief Initialize the user and skeleton information
    ///
    /// This method initializes the user and skeleton information. It assumes the
    /// context is already valid (otherwise we fail).
    /// @note - Since we use a singleton pattern, multiple initializations will simply delete
    /// the old information and create new one!
    /// @note - It is the responsibility of the initializer to call @ref Dispose.
    /// @param context the context used
    /// @param logger the logger object we will enter logs into
    /// @return true on success, false on failure.
    public bool Init(NIEventLogger logger, NIContext context)
    {
        NIOpenNICheckVersion.Instance.ValidatePrerequisite();
        Dispose(); // to make sure we are not initialized
        if (InitWithContext(logger, context) == false)
        {
            return(false);
        }

        m_userGenerator = context.CreateNode(NodeType.User) as UserGenerator;
        if (m_userGenerator == null || m_userGenerator.SkeletonCapability == null)
        {
            Log("Failed to create proper user generator.", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.Skeleton, NIEventLogger.VerboseLevel.Errors);
            // we either don't have a user generator or the user generator we received does not have a skeleton
            Dispose();
            return(false);
        }
        // skeleton heuristics tries to handle the skeleton when the confidence is low. It can
        // have two values: 0 (no heuristics) or 255 (use heuristics).
        m_userGenerator.SetIntProperty("SkeletonHeuristics", 255);
        // makes sure we use all joints
        m_userGenerator.SkeletonCapability.SetSkeletonProfile(SkeletonProfile.All);
        PoseDetectionCapability cap = UserNode.PoseDetectionCapability;

        if (cap != null)
        {
            m_legalPoses = cap.GetAllAvailablePoses();
        }
        else
        {
            m_legalPoses = null;
        }
        m_poseDetectionCounter    = new List <poseDetectionReferenceCounter>();
        m_userGenerator.LostUser += new EventHandler <UserLostEventArgs>(LostUserCallback);

        return(true);
    }
Example #12
0
    // public methods

    /// @brief Initialize the context object
    /// 
    /// This method initializes the context. It is assumed that this would be done once on the
    /// beginning of the game. Note that this is called on the singleton so multiple initializations
    /// will simply do nothing (which might cause problems with other objects). If for some reason a new
    /// initialization is needed, the @ref Dispose method should be called first (however ALL
    /// other initializations will be required first such as reinitializing the nodes). Also, it is assumed that
    /// every node created externally using the @ref CreateNode method will be released (using the @ref ReleaseNode
    /// method) BEFORE releasing the context.
    /// @param logger the logger object we will enter logs into
    /// @param query A query limiting the nodes found.
    /// @param xmlFileName this will hold an xml file to initialize from. A null or empty filename
    /// will simply be ignored and the object will be built without it. An illegal filename will cause
    /// an exception!
    /// @param recordingFilename This holds the filename for playing a recording.
    /// @ref OpenNIRecordAndPlayback "Recording and playing back sensor data").
    /// @return true on success, false on failure. 
    /// @note if the context was already initialized this will fail but the context would be valid!
    /// @note This implementation assumes that a depth generator is required for ALL uses including
    /// the creation of the skeleton. In theory, it is possible that some implementations will not 
    /// require a depth generator. This is currently not supported.
    public virtual bool Init(NIEventLogger logger, NIQuery query, string xmlFileName, string recordingFilename)
    {
        if (Valid)
        {
            if(logger!=null)
                logger.Log("trying to initialized a valid context!", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects,NIEventLogger.VerboseLevel.Warning);
            return false; // failed to initialize
        }
        if (InitLogger(logger) == false)
        {
            Dispose();
            return false; // we failed an initialization step.
        }
        Log("In OpenNIContext.InitContext with logger=" + logger + " query=" + query, NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Verbose);
        if(m_context!=null || m_scriptNode!=null || m_depth!=null)
            throw new System.Exception("valid is false but internal structures are not null! m_context=" + m_context + " m_scriptNode=" + m_scriptNode + " m_depth=" + m_depth);
        m_Logger = logger;
        m_query = query;
        if (xmlFileName != null && xmlFileName.CompareTo("")!=0)
        {
            try
            {
                NIOpenNICheckVersion.Instance.ValidatePrerequisite();
                m_context = Context.CreateFromXmlFile(xmlFileName, out m_scriptNode);
                m_recordingPlayer = m_context.FindExistingNode(NodeType.Player) as Player;
            }
            catch (System.Exception ex)
            {
                Debug.Log(ex.Message);
                Log("failed to create from xmlFile!", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects,NIEventLogger.VerboseLevel.Errors);
                Dispose();
                return false;
            }
            if (recordingFilename != null && recordingFilename.CompareTo("") != 0)
            {
                Log("Both xml and recording were defined. Ignoring recording information and using XML only!", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Warning);
            }
         
        }
        else
        {
            try
            {
                NIOpenNICheckVersion.Instance.ValidatePrerequisite();
                m_context = new Context();
                if (recordingFilename != null && recordingFilename.CompareTo("") != 0)
                {
                    try
                    {
                        m_recordingPlayer = m_context.OpenFileRecordingEx(recordingFilename) as Player;
                    }
                    catch (System.Exception ex)
                    {
                        Debug.Log(recordingFilename);
                        Log("Failed to create recorder with message " + ex.Message, NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Errors);
                        Dispose();
                        return false;
                    }
                    
                }
            }
            catch (System.Exception ex)
            {
                if (ex as System.DllNotFoundException != null)
                {
                    throw new System.DllNotFoundException("The dll for OpenNI is not there. Please install OpenNI (using the mega installer");
                }
                else Debug.Log(ex.Message);
            }
            
        }
		if (m_context==null)
		{
            Log("failed to create a context!", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Errors);
            Dispose();
			return false;
		}
        m_depth = CreateNode(NodeType.Depth) as DepthGenerator;
        return true;
	}
Example #13
0
    // public methods

    /// @brief Initialize the context object
    ///
    /// This method initializes the context. It is assumed that this would be done once on the
    /// beginning of the game. Note that this is called on the singleton so multiple initializations
    /// will simply do nothing (which might cause problems with other objects). If for some reason a new
    /// initialization is needed, the @ref Dispose method should be called first (however ALL
    /// other initializations will be required first such as reinitializing the nodes). Also, it is assumed that
    /// every node created externally using the @ref CreateNode method will be released (using the @ref ReleaseNode
    /// method) BEFORE releasing the context.
    /// @param logger the logger object we will enter logs into
    /// @param query A query limiting the nodes found.
    /// @param xmlFileName this will hold an xml file to initialize from. A null or empty filename
    /// will simply be ignored and the object will be built without it. An illegal filename will cause
    /// an exception!
    /// @param recordingFilename This holds the filename for playing a recording.
    /// @ref OpenNIRecordAndPlayback "Recording and playing back sensor data").
    /// @return true on success, false on failure.
    /// @note if the context was already initialized this will fail but the context would be valid!
    /// @note This implementation assumes that a depth generator is required for ALL uses including
    /// the creation of the skeleton. In theory, it is possible that some implementations will not
    /// require a depth generator. This is currently not supported.
    public virtual bool Init(NIEventLogger logger, NIQuery query, string xmlFileName, string recordingFilename)
    {
        if (Valid)
        {
            if (logger != null)
            {
                logger.Log("trying to initialized a valid context!", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Warning);
            }
            return(false); // failed to initialize
        }
        if (InitLogger(logger) == false)
        {
            Dispose();
            return(false); // we failed an initialization step.
        }
        Log("In OpenNIContext.InitContext with logger=" + logger + " query=" + query, NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Verbose);
        if (m_context != null || m_scriptNode != null || m_depth != null)
        {
            throw new System.Exception("valid is false but internal structures are not null! m_context=" + m_context + " m_scriptNode=" + m_scriptNode + " m_depth=" + m_depth);
        }
        m_Logger = logger;
        m_query  = query;
        if (xmlFileName != null && xmlFileName.CompareTo("") != 0)
        {
            try
            {
                NIOpenNICheckVersion.Instance.ValidatePrerequisite();
                m_context         = Context.CreateFromXmlFile(xmlFileName, out m_scriptNode);
                m_recordingPlayer = m_context.FindExistingNode(NodeType.Player) as Player;
            }
            catch (System.Exception ex)
            {
                Debug.Log(ex.Message);
                Log("failed to create from xmlFile!", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Errors);
                Dispose();
                return(false);
            }
            if (recordingFilename != null && recordingFilename.CompareTo("") != 0)
            {
                Log("Both xml and recording were defined. Ignoring recording information and using XML only!", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Warning);
            }
        }
        else
        {
            try
            {
                NIOpenNICheckVersion.Instance.ValidatePrerequisite();
                m_context = new Context();
                if (recordingFilename != null && recordingFilename.CompareTo("") != 0)
                {
                    try
                    {
                        m_recordingPlayer = m_context.OpenFileRecordingEx(recordingFilename) as Player;
                    }
                    catch (System.Exception ex)
                    {
                        Debug.Log(recordingFilename);
                        Log("Failed to create recorder with message " + ex.Message, NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Errors);
                        Dispose();
                        return(false);
                    }
                }
            }
            catch (System.Exception ex)
            {
                if (ex as System.DllNotFoundException != null)
                {
                    throw new System.DllNotFoundException("The dll for OpenNI is not there. Please install OpenNI (using the mega installer");
                }
                else
                {
                    Debug.Log(ex.Message);
                }
            }
        }
        if (m_context == null)
        {
            Log("failed to create a context!", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Errors);
            Dispose();
            return(false);
        }
        m_depth = CreateNode(NodeType.Depth) as DepthGenerator;
        return(true);
    }
    /// @brief Initialize the user and skeleton information
    /// 
    /// This method initializes the user and skeleton information. It assumes the 
    /// context is already valid (otherwise we fail).
    /// @note - Since we use a singleton pattern, multiple initializations will simply delete 
    /// the old information and create new one!
    /// @note - It is the responsibility of the initializer to call @ref Dispose.
    /// @param context the context used
    /// @param logger the logger object we will enter logs into
    /// @return true on success, false on failure. 
    public bool Init(NIEventLogger logger, NIContext context)
    {
        NIOpenNICheckVersion.Instance.ValidatePrerequisite();
        Dispose(); // to make sure we are not initialized
        if (InitWithContext(logger, context) == false)
            return false;

        m_userGenerator = context.CreateNode(NodeType.User) as UserGenerator;
        if (m_userGenerator == null || m_userGenerator.SkeletonCapability==null)
        {
            Log("Failed to create proper user generator.", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.Skeleton, NIEventLogger.VerboseLevel.Errors);
            // we either don't have a user generator or the user generator we received does not have a skeleton
            Dispose();
            return false;
        }
        // skeleton heuristics tries to handle the skeleton when the confidence is low. It can
        // have two values: 0 (no heuristics) or 255 (use heuristics).
        m_userGenerator.SetIntProperty("SkeletonHeuristics", 255);
        // makes sure we use all joints
        m_userGenerator.SkeletonCapability.SetSkeletonProfile(SkeletonProfile.All);
        PoseDetectionCapability cap = UserNode.PoseDetectionCapability;
        if (cap != null)
            m_legalPoses = cap.GetAllAvailablePoses();
        else
            m_legalPoses = null;
        m_poseDetectionCounter = new List<poseDetectionReferenceCounter>();
        m_userGenerator.LostUser += new EventHandler<UserLostEventArgs>(LostUserCallback);

        return true;
    }
Example #15
0
    // public methods

    /// @brief Initialize the context object
    ///
    /// This method initializes the context. It is assumed that this would be done once on the
    /// beginning of the game. Note that this is called on the singleton so multiple initializations
    /// will simply do nothing (which might cause problems with other objects). If for some reason a new
    /// initialization is needed, the @ref Dispose method should be called first (however ALL
    /// other initializations will be required first such as reinitializing the nodes). Also, it is assumed that
    /// every node created externally using the @ref CreateNode method will be released (using the @ref ReleaseNode
    /// method) BEFORE releasing the context.
    /// @param logger the logger object we will enter logs into
    /// @param query A query limiting the nodes found.
    /// @param xmlFileName this will hold an xml file to initialize from. A null or empty filename
    /// will simply be ignored and the object will be built without it. An illegal filename will cause
    /// an exception!
    /// @param playerbackMode If this is true then the context is in playback mode (see
    /// @ref OpenNIRecordAndPlayback "Recording and playing back sensor data").
    /// @return true on success, false on failure.
    /// @note if the context was already initialized this will fail but the context would be valid!
    /// @note This implementation assumes that a depth generator is required for ALL uses including
    /// the creation of the skeleton. In theory, it is possible that some implementations will not
    /// require a depth generator. This is currently not supported.
    public virtual bool Init(NIEventLogger logger, NIQuery query, string xmlFileName, bool playerbackMode)
    {
        if (Valid)
        {
            if (logger != null)
            {
                logger.Log("trying to initialized a valid context!", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects);
            }
            return(false); // failed to initialize
        }
        if (InitLogger(logger) == false)
        {
            Dispose();
            return(false); // we failed an initialization step.
        }
        Log("In OpenNIContext.InitContext with logger=" + logger + " query=" + query, NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects);
        if (m_context != null || m_scriptNode != null || m_depth != null)
        {
            throw new System.Exception("valid is false but internal structures are not null! m_context=" + m_context + " m_scriptNode=" + m_scriptNode + " m_depth=" + m_depth);
        }
        m_Logger = logger;
        m_query  = query;
        if (xmlFileName != null && xmlFileName.CompareTo("") != 0)
        {
            try
            {
                NIOpenNICheckVersion.Instance.ValidatePrerequisite();
                m_context = Context.CreateFromXmlFile(xmlFileName, out m_scriptNode);
            }
            catch
            {
                Log("failed to create from xmlFile!", NIEventLogger.Categories.Errors, NIEventLogger.Sources.BaseObjects);
                Dispose();
                return(false);
            }
        }
        else
        {
            try
            {
                NIOpenNICheckVersion.Instance.ValidatePrerequisite();
                m_context = new Context();
            }
            catch (System.Exception ex)
            {
                if (ex as System.DllNotFoundException != null)
                {
                    throw new System.DllNotFoundException("The dll for OpenNI is not there. Please install OpenNI (using the mega installer");
                }
                else
                {
                    Debug.Log(ex.Message);
                }
            }
        }
        if (m_context == null)
        {
            Log("failed to create a context!", NIEventLogger.Categories.Errors, NIEventLogger.Sources.BaseObjects);
            Dispose();
            return(false);
        }
        m_playerbackMode = playerbackMode;
        m_depth          = CreateNode(NodeType.Depth) as DepthGenerator;
        return(true);
    }
 /// @brief safe calling to the logger
 /// 
 /// This call the logger in a safe manner checking if it is null first.
 /// @param str the string we want to log
 /// @param category the category of the log
 /// @param source the source of the log
 /// @param logLevel what level to show and how to show it
 /// @note See @ref NIEventLogger.Log
 public void Log(string str, NIEventLogger.Categories category, NIEventLogger.Sources source,NIEventLogger.VerboseLevel logLevel)
 {
     if (m_Logger != null)
         m_Logger.Log(str, category,source,logLevel);
 }