Reputation: 1971
Hello folk last few day I faced the issue on Camera Preview Callback, I want to scan the each frame
inside the added PreviewCallback, I have device (motorola g) that give me the 30 fps. below is the
code inside the preview Callback.
private PreviewCallback previewCallback = new PreviewCallback() {
/**
* {@inheritDoc}
*/
@Override
public void onPreviewFrame(byte[] data, Camera cam)
{
if (data == null) throw new NullPointerException();
Camera.Size size = cam.getParameters().getPreviewSize();
if (size == null) throw new NullPointerException();
int width = size.width;
int height = size.height;
// maximum value of the range of sum (Red) values in each frame 1/10 part of every 5th
// pixel red value sum ( if all pixels consider the red(255) then max value of sum of r)
final double analysisFrameSize = (((width * height)/100)/5f)* 255;
ImageProcessing.setMaxPixelPerFrame(analysisFrameSize);
ImageProcessModel model = ImageProcessing.decodeYUV420SPtoRedAvg(data.clone(), width, height);
List<Integer> furtherAnaylisList = model.getmFurtherAnalysisList();
final int frameSize = (((width * height)/100)/5);
int redAvg = (furtherAnaylisList.get(0) / frameSize);
int green = (furtherAnaylisList.get(1) / frameSize);
int blue = (furtherAnaylisList.get(2) / frameSize);
Log.println(TAG,String.format("AvgRed:%2d,AvgGree:%2d,AvgBlue:%2d",redAvg,green,blue));
}
};
Is program slow down the frame rate inside the preview callback because after write the code it slow down fps 30 fps to 22 fps, I have no issues with 22 fps but it is not constant.
Can I set the camera for give me the 22 or 30 fps constant.
Thank you in advance.
Upvotes: 1
Views: 1162
Reputation: 1006674
Can I set the camera for give me the 22 or 30 fps constant.
No, but you could move your image processing work to a background thread, so you stop slowing down the camera.
Upvotes: 1