Search in sources :

Example 6 with FrameValues

use of androidx.media.filterfw.FrameValues in project android_frameworks_base by crdroidandroid.

the class MotionSensorWTime method onProcess.

@Override
protected void onProcess() {
    OutputPort outPort = getConnectedOutputPort("values");
    FrameValues outFrame = outPort.fetchAvailableFrame(null).asFrameValues();
    synchronized (mValues) {
        if (mCounter < 3 && mCounter >= 0) {
            mTemp[0][mCounter] = mValues[0];
            mTemp[1][mCounter] = mValues[1];
            mTemp[2][mCounter] = mValues[2];
        }
        mCounter = (mCounter + 1) % 3;
        mAvgValues[0] = (mTemp[0][0] + mTemp[0][1] + mTemp[0][2]) / 3;
        mAvgValues[1] = (mTemp[1][0] + mTemp[1][1] + mTemp[1][2]) / 3;
        mAvgValues[2] = (mTemp[2][0] + mTemp[2][1] + mTemp[2][2]) / 3;
        outFrame.setValues(mAvgValues);
    }
    outFrame.setTimestamp(System.currentTimeMillis() * 1000000L);
    outPort.pushFrame(outFrame);
    OutputPort timeOutPort = getConnectedOutputPort("timestamp");
    if (timeOutPort != null) {
        long timestamp = System.nanoTime();
        Log.v("MotionSensor", "Timestamp is: " + timestamp);
        FrameValue timeStampFrame = timeOutPort.fetchAvailableFrame(null).asFrameValue();
        timeStampFrame.setValue(timestamp);
        timeOutPort.pushFrame(timeStampFrame);
    }
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameValues(androidx.media.filterfw.FrameValues) FrameValue(androidx.media.filterfw.FrameValue)

Example 7 with FrameValues

use of androidx.media.filterfw.FrameValues in project android_frameworks_base by crdroidandroid.

the class FaceSquareFilter method onProcess.

/**
     * @see androidx.media.filterfw.Filter#onProcess()
     */
@Override
protected void onProcess() {
    // Get inputs
    FrameImage2D imageFrame = getConnectedInputPort("image").pullFrame().asFrameImage2D();
    FrameValues facesFrame = getConnectedInputPort("faces").pullFrame().asFrameValues();
    Face[] faces = (Face[]) facesFrame.getValues();
    int[] dims = imageFrame.getDimensions();
    ByteBuffer buffer = imageFrame.lockBytes(Frame.MODE_WRITE);
    byte[] pixels = buffer.array();
    // For every face in faces, draw a white rect around the
    // face following the rect member of the Face
    drawBoxes(pixels, faces, dims);
    imageFrame.unlock();
    OutputPort outPort = getConnectedOutputPort("image");
    outPort.pushFrame(imageFrame);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameValues(androidx.media.filterfw.FrameValues) FrameImage2D(androidx.media.filterfw.FrameImage2D) Face(android.hardware.Camera.Face) ByteBuffer(java.nio.ByteBuffer)

Example 8 with FrameValues

use of androidx.media.filterfw.FrameValues in project android_frameworks_base by crdroidandroid.

the class MotionSensor method onProcess.

@Override
protected void onProcess() {
    OutputPort outPort = getConnectedOutputPort("values");
    FrameValues outFrame = outPort.fetchAvailableFrame(null).asFrameValues();
    synchronized (mValues) {
        outFrame.setValues(mValues);
    }
    outFrame.setTimestamp(System.currentTimeMillis() * 1000000L);
    outPort.pushFrame(outFrame);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameValues(androidx.media.filterfw.FrameValues)

Example 9 with FrameValues

use of androidx.media.filterfw.FrameValues in project platform_frameworks_base by android.

the class MotionSensorWTime method onProcess.

@Override
protected void onProcess() {
    OutputPort outPort = getConnectedOutputPort("values");
    FrameValues outFrame = outPort.fetchAvailableFrame(null).asFrameValues();
    synchronized (mValues) {
        if (mCounter < 3 && mCounter >= 0) {
            mTemp[0][mCounter] = mValues[0];
            mTemp[1][mCounter] = mValues[1];
            mTemp[2][mCounter] = mValues[2];
        }
        mCounter = (mCounter + 1) % 3;
        mAvgValues[0] = (mTemp[0][0] + mTemp[0][1] + mTemp[0][2]) / 3;
        mAvgValues[1] = (mTemp[1][0] + mTemp[1][1] + mTemp[1][2]) / 3;
        mAvgValues[2] = (mTemp[2][0] + mTemp[2][1] + mTemp[2][2]) / 3;
        outFrame.setValues(mAvgValues);
    }
    outFrame.setTimestamp(System.currentTimeMillis() * 1000000L);
    outPort.pushFrame(outFrame);
    OutputPort timeOutPort = getConnectedOutputPort("timestamp");
    if (timeOutPort != null) {
        long timestamp = System.nanoTime();
        Log.v("MotionSensor", "Timestamp is: " + timestamp);
        FrameValue timeStampFrame = timeOutPort.fetchAvailableFrame(null).asFrameValue();
        timeStampFrame.setValue(timestamp);
        timeOutPort.pushFrame(timeStampFrame);
    }
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameValues(androidx.media.filterfw.FrameValues) FrameValue(androidx.media.filterfw.FrameValue)

Example 10 with FrameValues

use of androidx.media.filterfw.FrameValues in project platform_frameworks_base by android.

the class MotionSensor method onProcess.

@Override
protected void onProcess() {
    OutputPort outPort = getConnectedOutputPort("values");
    FrameValues outFrame = outPort.fetchAvailableFrame(null).asFrameValues();
    synchronized (mValues) {
        outFrame.setValues(mValues);
    }
    outFrame.setTimestamp(System.currentTimeMillis() * 1000000L);
    outPort.pushFrame(outFrame);
}
Also used : OutputPort(androidx.media.filterfw.OutputPort) FrameValues(androidx.media.filterfw.FrameValues)

Aggregations

FrameValues (androidx.media.filterfw.FrameValues)16 OutputPort (androidx.media.filterfw.OutputPort)12 Face (android.hardware.Camera.Face)8 FrameImage2D (androidx.media.filterfw.FrameImage2D)8 Bitmap (android.graphics.Bitmap)4 Rect (android.graphics.Rect)4 Camera (android.hardware.Camera)4 FrameValue (androidx.media.filterfw.FrameValue)4 ByteBuffer (java.nio.ByteBuffer)4