我正在使用 winform 开发基于 VS2012 的 Kinect 应用程序。在我尝试了几种方法之后,我仍然无法将值从一个类传递到另一个类。
基本上我有三个类,一个 public MainWindow()
, public partialFaceTrackingViewer()
和 public SkeletonFaceTracker()
。最后一节课住在FaceTrackingViewer()
课堂上。
在 SkeletonFaceTracker() 中,我有以下内容:
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
}
}
我还尝试将第一行更改为:
public bool lastFaceTrackSucceeded;
public bool LastFaceTrackSucceeded
{
get { return lastFaceTrackSucceeded; }
private set { lastFaceTrackSucceeded = value; }
}
不过我觉得两者是一样的。
在 MainWindow() 中,我有:
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
}
}
}
但是,即使 the或in是, thebool faceTrackSucceeded
也始终是。我很困惑,不知道哪里出错了。false
lastFaceTrackSucceeded
LastFaceTrackSucceeded
SkeletonFaceTracker()
true
请注意,所有视频处理和面部跟踪操作都在FaceTrackingViewer()
课堂上进行。我只是想将一些参数和结构传递给MainWindow()
.
谢谢