1

我目前正在开发手势识别应用程序,并且正在使用 HMM(通过 Jahmm)。目前我有两个手势(向上和向下),所以我构建了 2 个 HMM,并带有一些训练数据。

我使用 BaumWelchLearner 对它们进行了训练,并创建了一个从我的系统获得的“样本”观察序列,我必须对其进行分类。

我认为我设法从我找到的少量支持中完成了上述步骤。但目前我被困在最后阶段,我正在尝试计算最有可能适合我当前序列的 HMM,但我没有有用的输出(或者我可能无法理解它们)。这是我的示例代码,然后是输出。

    //gesture classes
    HmmUp up = new HmmUp();
    HmmDown down = new HmmDown();
    final Hmm<ObservationDiscrete<DirectionVector>> upLearnt;
    final Hmm<ObservationDiscrete<DirectionVector>> downLearnt;

    //train - should read TRAINED HMM OBJECTS in application
    BaumWelchLearner bwl = new BaumWelchLearner();
    bwl.setNbIterations(100);

    upLearnt = bwl.learn(up, up.getTrainingMaterial());
    downLearnt = bwl.learn(down, down.getTrainingMaterial());

    ArrayList<Hmm<ObservationDiscrete<DirectionVector>>> trainedHmms = new ArrayList<Hmm<ObservationDiscrete<DirectionVector>>>(){{
        add(upLearnt);
        add(downLearnt);
    }};

    ArrayList<ObservationDiscrete<DirectionVector>> currentSequence = new ArrayList<ObservationDiscrete<DirectionVector>>(){{
        add(new ObservationDiscrete<DirectionVector>(DirectionVector.NoMovement));
        add(new ObservationDiscrete<DirectionVector>(DirectionVector.Down));
        add(new ObservationDiscrete<DirectionVector>(DirectionVector.Up));
        add(new ObservationDiscrete<DirectionVector>(DirectionVector.Up));
        add(new ObservationDiscrete<DirectionVector>(DirectionVector.Up));
        add(new ObservationDiscrete<DirectionVector>(DirectionVector.Up));
        add(new ObservationDiscrete<DirectionVector>(DirectionVector.Up));
        add(new ObservationDiscrete<DirectionVector>(DirectionVector.UpLeft));
        add(new ObservationDiscrete<DirectionVector>(DirectionVector.Null));
        add(new ObservationDiscrete<DirectionVector>(DirectionVector.Null));
    }};

    //get the observation from the device (continuously feeding - 10 states always with nulls at the end?)
    for (Hmm<ObservationDiscrete<DirectionVector>> hmm : trainedHmms) {

        ViterbiCalculator vc = new ViterbiCalculator(currentSequence, hmm);
        for (int i = 0; i < vc.stateSequence().length; i++)
        {
            System.out.println(vc.stateSequence()[i]);
        }
        System.out.println(vc.lnProbability()); //e to the ln(x) = x

    }

这是我正在使用的当前输出,似乎是“空”状态序列和负概率?!!!

0 0 0 0 0 0 0 0 0 0 -1.7976931348623157E308

0 0 0 0 0 0 0 0 0 0 -56.294579216353064

4

0 回答 0