Can't pass faceTracking data between classes RRS feed

  • Question

  • I am developing a Kinect application based on VS2012 using winform. After I tried several methods, I still couldn't pass value from one class to another class.

    Basically I have three class, a public MainWindow(), public partial FaceTrackingViewer(), and public SkeletonFaceTracker(). The last class reside in FaceTrackingViewer() class.

    In SkeletonFaceTracker(), I have the following:

    public bool lastFaceTrackSucceeded { get; set; }
    internal void OnFrameReady(KinectSensor kinectSensor, ColorImageFormat colorImageFormat, byte[] colorImage, DepthImageFormat depthImageFormat, short[] depthImage, Skeleton skeletonOfInterest)
        // something else
        if (this.faceTracker != null)
            this.lastFaceTrackSucceeded = frame.TrackSuccessful; //where it's set to be true.
            //something else

    I also tried to change to first line to:

    public bool lastFaceTrackSucceeded;
    public bool LastFaceTrackSucceeded
        get { return lastFaceTrackSucceeded; }
        private set { lastFaceTrackSucceeded = value; }

    I think the two are the same though.

    In MainWindow(), I have:

    public partial class MainWindow : Window
        //some other irrelevant code snippets
        private FaceTrackingViewer.SkeletonFaceTracker skeletonFaceTracker = new FaceTrackingViewer.SkeletonFaceTracker();
        private void button_faceOnly_Click(object sender, RoutedEventArgs e)
            bool faceTrackSucceeded = skeletonFaceTracker.lastFaceTrackSucceeded;
            // if I use the second structure in SkeletonFaceTracker(), it should be:
            // bool faceTrackSucceeded = skeletonFaceTracker.LastFaceTrackSucceeded;
            if (faceTrackSucceeded == true )
                 //do something

    However, the bool faceTrackSucceeded is always false, even if the lastFaceTrackSucceededor LastFaceTrackSucceeded in SkeletonFaceTracker() is true. I am very confused and don't know where it went wrong.

    Please note that all the video processing and face tracking actions occur in FaceTrackingViewer()class. I simply want to pass some parameters and structures to MainWindow().

    Thank you

    Saturday, March 16, 2013 4:48 PM


  • As it turned out, I made a stupid mistake that the skeletonFaceTracker was otherwise declared as a temp variable in the class, such that it couldn't be passed along. Thanks.
    • Marked as answer by seanlawson Saturday, March 16, 2013 8:11 PM
    Saturday, March 16, 2013 8:11 PM