0

私は自分のアプリケーションでこのように実装しようとしています http://www.youtube.com/watch?v=QrXwJIco4w8

しかし、私はそれを行う方法を本当に理解していないようです..

モーショントラッキングと手の認識を使用する必要があり、フロントエンドカメラとも通信する必要があるようですが、ほとんどのリンクは、内部オブジェクトではなく外部オブジェクトのみを検出することを示しています(デバイス内を意味します)。

だから私が欲しいのは、アプリケーションにオブジェクト(画像など)がある場合、左に移動するようにカメラの前で手を動かすと、画像の位置も左に移動することです。タッチを操作せずに画像を動かしますが、代わりにカメラを使用します (タッチレス)

それを行う方法を示すのを手伝ってもらえますか?

ありがとう

4

1 に答える 1

1

カメラについてはわかりませんが、ウェーブ ジェスチャを使用して画像などを変更する別のアイデアがあります。電話の近接センサーを使用できます。しかし、あなたが手を左から右に動かしたのか、右から左に動かしたのか理解できません。したがって、次のようなものを使用できます。

センサー上を 1 回移動 - 左から右 センサー上を 2 回移動 - 右から左

次のような近接センサーを定義できます。

public class ProximityNotifier implements SensorEventListener{

private final SensorManager mSensorManager;
private final Sensor mProximitySensor;
private final Sensor mAccelSensor;
private float mProximityMax = 0.0f;
private boolean mStartProxComparison;
public float mProximityValue = 0.0f;
private long lastBlockedTimestamp = 0;
private long gapPlayPause = 0;
private long gapNext = 0;
private static float mValue0 = 0.0f;
private static float mValue1 = 0.0f;
private ProximityNotifier.Callback cb = null;
private static final String TAG = "ProximityNotifier";

public ProximityNotifier(Context ctxt, ProximityNotifier.Callback cb, long gap1, long gap2) {

    this.cb = cb;
    this.gapPlayPause = gap1;
    this.gapNext = gap2;
    mSensorManager = (SensorManager)ctxt.getSystemService(Context.SENSOR_SERVICE);
    mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
    mAccelSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    if (null != mProximitySensor)
        mProximityMax = mProximitySensor.getMaximumRange();
    mProximityValue = mProximityMax;
    startProximityNotifier();
}



public interface Callback {
    void pageChange();        
}


public void startProximityNotifier() {
    if(null != mSensorManager) {
        if ((null != mProximitySensor) && (null != mAccelSensor)) {
            mSensorManager.registerListener(this, mProximitySensor, SensorManager.SENSOR_DELAY_UI);
            mSensorManager.registerListener(this, mAccelSensor, SensorManager.SENSOR_DELAY_UI);
            mStartProxComparison = true;
        }
        else
            mStartProxComparison = false;
    }
}

public void stopProximityNotifier() {
    if(null != mSensorManager) {
        if ((null != mProximitySensor) && (null != mAccelSensor)) {
            mSensorManager.unregisterListener(this, mProximitySensor);
            mSensorManager.unregisterListener(this, mAccelSensor);
        }
    }
}

public void onAccuracyChanged(Sensor sensor, int accuracy) {

}

public void onSensorChanged(SensorEvent sensorEvent) {

    if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
        mValue0 = sensorEvent.values[0];
        mValue1 = sensorEvent.values[1];
    }

    if ((sensorEvent.sensor.getType() == Sensor.TYPE_PROXIMITY) &&  
            ((mValue0 < 2) && (mValue0 > -2)) &&
            ((mValue1 < 2) && (mValue1 > -2))) { 
        // check for a max -> 0 transition
        if((mStartProxComparison == true) && ((mProximityValue == mProximityMax) && (sensorEvent.values[0] == 0))) {
            lastBlockedTimestamp = SystemClock.uptimeMillis(); 
        } 

        else { 
            long now = SystemClock.uptimeMillis();
            if (lastBlockedTimestamp != 0) {
                /*if ((now - lastBlockedTimestamp) > gapPlayPause) {
                    if (cb != null) {
                        //cb.gesturePlayPause();
                    }
                }else*/ if ((now - lastBlockedTimestamp) > gapNext){
                    if (cb != null)
                        cb.pageChange();
                }
            }

            lastBlockedTimestamp = 0;
        }
        mProximityValue = sensorEvent.values[0];
    }

} 

}

アクティビティでは、次のように宣言して使用できます。

mProximityNotifier = new ProximityNotifier(this, this, 400, 200);

//Callback method for Proximity Sensor
    public void pageChange() {
        //call for image change
  }

それがあなたを助けることを願っています

于 2013-11-07T01:04:25.227 に答える