Kinect SDK と c# を使用して、Kinect を使用するコンソール アプリケーションを作成する必要があります。これはコンソール アプリケーションであるため、処理が必要なフレームを取得するにはポーリングが最適な方法であることがわかりました。深度カメラと RGB カメラからフレームを取得し、別のスレッド (深度画像用に 1 つ、RGB 画像用に 1 つ) で処理を行い、2 つのそれぞれについてユーザーに出力する必要があります。加工されたフレーム。これを行うために私が考えてきた方法は次のとおりです。
1 - 2 つのスレッドを作成します。1 つ目は RGB カメラをポーリングして処理を行うメソッド、2 つ目は深度カメラをポーリングして処理を行うメソッドです。
2 - スレッドを開始する
3 - while いくつかの停止条件ループに入る
4 - 各スレッドが生きているかどうかを個別に確認し、そうでない場合は、それらを再度作成して再度開始します
これらの手順に従うテスト プログラムを作成しましたが、動作しますが、それが最善の方法であるかどうかはわかりません。私のテストプログラムは
class Program
{
private static ClassExecutioner Executioner;
private static Class1 Cls;
static void Main(string[] args)
{
Executioner = new ClassExecutioner();
Cls = new Class1();
Thread fThread = new Thread(new ThreadStart(processA));
Thread sThread = new Thread(new ThreadStart(processB));
fThread.Start();
sThread.Start();
while (true)
{
if (!fThread.IsAlive)
{
fThread = new Thread(new ThreadStart(processA));
fThread.Start();
}
if (!sThread.IsAlive)
{
sThread = new Thread(new ThreadStart(processB));
sThread.Start();
}
}
}
static void processA()
{
String frameA = Cls.pollA();
Executioner.CallA(frameA);
}
static void processB()
{
String frameB = Cls.pollB();
Executioner.CallB(frameB);
}
}
クラス 1 メソッドは、kinect 上のカメラのポーリングを表します
class Class1
{
private int a;
private int b;
public Class1()
{
a = 0;
b = 0;
}
public String pollA()
{
String frame = "this is " + a % 100;
a++;
return frame;
}
public String pollB()
{
String frame = "I am " + b % 100;
b++;
return frame;
}
}
Executioner は、Kinect から取得したフレームを処理するメソッドを表します
class ClassExecutioner
{
public ClassExecutioner()
{
}
public void CallA(String frameA)
{
Random rand = new Random();
int time = rand.Next() % 1000000000;
//'processing' - wait some time
for (int i = 0; i < time; i++)
{
}
// finishes the processing of the 'frame' from stream A
Console.WriteLine(frameA);
}
public void CallB(String frameB)
{
Random rand = new Random();
int time = rand.Next() % 1000000000;
// 'processing' - wait some time
for (int i = 0; i < time; i++)
{
}
// finishes the processing of the 'frame' from stream B
Console.WriteLine(frameB);
}
}
このプログラムは非常に単純ですが、Kinect ストリームで私がやりたいことをよく表しています。問題は、これが最善の方法であるかどうか、またはこれが実用的な Kinect アプリケーションでまったく機能するかどうかわからないことです。現時点では、各処理 (深度と RGB) が他の処理からの情報を必要としないことに注意してください。
前もって感謝します!