use of androidx.media.filterfw.FrameValue in project android_frameworks_base by DirtyUnicorns.
the class TextViewTarget method onProcess.
@Override
protected void onProcess() {
FrameValue textFrame = getConnectedInputPort("text").pullFrame().asFrameValue();
final String text = (String) textFrame.getValue();
if (mTextView != null) {
mTextView.post(new Runnable() {
@Override
public void run() {
mTextView.setText(text);
}
});
}
}
use of androidx.media.filterfw.FrameValue 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);
}
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by crdroidandroid.
the class CSVWriterFilter method onProcess.
@Override
protected void onProcess() {
Log.v(TAG, "in csv writer on process");
FrameValue sharpnessValue = getConnectedInputPort("sharpness").pullFrame().asFrameValue();
float sharpness = ((Float) sharpnessValue.getValue()).floatValue();
FrameValue overExposureValue = getConnectedInputPort("overExposure").pullFrame().asFrameValue();
float overExposure = ((Float) overExposureValue.getValue()).floatValue();
FrameValue underExposureValue = getConnectedInputPort("underExposure").pullFrame().asFrameValue();
float underExposure = ((Float) underExposureValue.getValue()).floatValue();
FrameValue colorfulnessValue = getConnectedInputPort("colorfulness").pullFrame().asFrameValue();
float colorfulness = ((Float) colorfulnessValue.getValue()).floatValue();
FrameValue contrastValue = getConnectedInputPort("contrastRating").pullFrame().asFrameValue();
float contrast = ((Float) contrastValue.getValue()).floatValue();
FrameValue brightnessValue = getConnectedInputPort("brightness").pullFrame().asFrameValue();
float brightness = ((Float) brightnessValue.getValue()).floatValue();
FrameValue motionValuesFrameValue = getConnectedInputPort("motionValues").pullFrame().asFrameValue();
float[] motionValues = (float[]) motionValuesFrameValue.getValue();
float vectorAccel = (float) Math.sqrt(Math.pow(motionValues[0], 2) + Math.pow(motionValues[1], 2) + Math.pow(motionValues[2], 2));
FrameValue imageFileNameFrameValue = getConnectedInputPort("imageFileName").pullFrame().asFrameValue();
String imageFileName = ((String) imageFileNameFrameValue.getValue());
FrameValue csvFilePathFrameValue = getConnectedInputPort("csvFilePath").pullFrame().asFrameValue();
String csvFilePath = ((String) csvFilePathFrameValue.getValue());
if (mFirstTime) {
try {
FileWriter fileWriter = new FileWriter(csvFilePath + "/CSVFile.csv");
BufferedWriter csvWriter = new BufferedWriter(fileWriter);
csvWriter.write("FileName,Sharpness,OverExposure,UnderExposure,Colorfulness," + "ContrastRating,Brightness,Motion");
csvWriter.newLine();
csvWriter.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mFirstTime = false;
}
try {
Log.v(TAG, "about to write to file");
FileWriter fileWriter = new FileWriter(csvFilePath + mFileName, true);
BufferedWriter csvWriter = new BufferedWriter(fileWriter);
csvWriter.write(imageFileName + "," + sharpness + "," + overExposure + "," + underExposure + "," + colorfulness + "," + contrast + "," + brightness + "," + vectorAccel);
Log.v(TAG, "" + imageFileName + "," + sharpness + "," + overExposure + "," + underExposure + "," + colorfulness + "," + contrast + "," + brightness + "," + vectorAccel);
csvWriter.newLine();
csvWriter.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by crdroidandroid.
the class ContrastRatioFilter method onProcess.
@Override
protected void onProcess() {
FrameImage2D inputImage = getConnectedInputPort("image").pullFrame().asFrameImage2D();
float contrastRatio;
ByteBuffer inputBuffer = inputImage.lockBytes(Frame.MODE_READ);
contrastRatio = contrastOperator(inputImage.getWidth(), inputImage.getHeight(), inputBuffer);
inputImage.unlock();
if (mLogVerbose)
Log.v(TAG, "contrastRatio: " + contrastRatio);
OutputPort contrastToGoodnessPort = getConnectedOutputPort("contrastRatingToGoodness");
FrameValue contrastOutFrame2 = contrastToGoodnessPort.fetchAvailableFrame(null).asFrameValue();
contrastOutFrame2.setValue(contrastRatio);
contrastToGoodnessPort.pushFrame(contrastOutFrame2);
}
use of androidx.media.filterfw.FrameValue in project android_frameworks_base by crdroidandroid.
the class ExposureFilter method onProcess.
@Override
protected void onProcess() {
FrameImage2D inputImage = getConnectedInputPort("image").pullFrame().asFrameImage2D();
float overExposedPixels, underExposedPixels;
ByteBuffer inputBuffer = inputImage.lockBytes(Frame.MODE_READ);
overExposedPixels = overExposureOperator(inputImage.getWidth(), inputImage.getHeight(), inputBuffer);
underExposedPixels = underExposureOperator(inputImage.getWidth(), inputImage.getHeight(), inputBuffer);
inputImage.unlock();
if (mLogVerbose)
Log.v(TAG, "underExposedPixelCount: " + underExposedPixels);
OutputPort underPort = getConnectedOutputPort("underExposedNum");
if (underPort != null) {
FrameValue underOutFrame = underPort.fetchAvailableFrame(null).asFrameValue();
underOutFrame.setValue(underExposedPixels * inputImage.getWidth() * inputImage.getHeight());
underPort.pushFrame(underOutFrame);
}
OutputPort underPort2 = getConnectedOutputPort("underExposureRating");
FrameValue underOutFrame2 = underPort2.fetchAvailableFrame(null).asFrameValue();
underOutFrame2.setValue(underExposedPixels);
underPort2.pushFrame(underOutFrame2);
if (mLogVerbose)
Log.v(TAG, "overExposedPixelCount: " + overExposedPixels);
OutputPort overPort = getConnectedOutputPort("overExposedNum");
if (overPort != null) {
FrameValue overOutFrame = overPort.fetchAvailableFrame(null).asFrameValue();
overOutFrame.setValue(overExposedPixels * inputImage.getWidth() * inputImage.getHeight());
overPort.pushFrame(overOutFrame);
}
OutputPort overPort2 = getConnectedOutputPort("overExposureRating");
FrameValue overOutFrame2 = overPort2.fetchAvailableFrame(null).asFrameValue();
overOutFrame2.setValue(overExposedPixels);
overPort2.pushFrame(overOutFrame2);
}
Aggregations