Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recon-jet running android 4.1.2 exception fix -- set a lower frame rate #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/android/CameraManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.Size;
import android.media.CamcorderProfile;
import android.os.Build;
import android.os.Handler;
import android.util.Log;
Expand All @@ -32,6 +33,8 @@ public final class CameraManager {
private final Context context;
public final CameraConfigurationManager configManager;
public Camera camera;
Camera.Parameters param;
CamcorderProfile camcorderProfile;
private boolean initialized;
public boolean previewing;

Expand Down Expand Up @@ -108,6 +111,14 @@ public void openDriver() throws IOException {
}

if (DEBUG) Log.i(TAG, "Camera open success");

// Get the camera profile. Low quality is adequate for display our demo purposes right now.
camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);

param = camera.getParameters();
param.setPreviewFrameRate(camcorderProfile.videoFrameRate);
camera.setParameters(param);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you think of cycling through the CamcorderProfiles, beginning with QUALITY_ and working downwards, until we find one that doesn't throw an error?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, the quality could be passed as a parameter someplace, but that may be a more obtrusive change.



camera.setPreviewDisplay(null);

Expand All @@ -125,11 +136,11 @@ public void openDriver() throws IOException {

if (!initialized) {
initialized = true;
configManager.initFromCameraParameters(camera);
if (DEBUG) Log.i(TAG, "configManager initialized");
//configManager.initFromCameraParameters(camera);
//if (DEBUG) Log.i(TAG, "configManager initialized");
}
configManager.setDesiredCameraParameters(camera);
if (DEBUG) Log.i(TAG, "Camera set desired parameters");
//configManager.setDesiredCameraParameters(camera);
//if (DEBUG) Log.i(TAG, "Camera set desired parameters");


} else {
Expand Down Expand Up @@ -642,6 +653,7 @@ final class PreviewCallback implements Camera.PreviewCallback {
public static float currentFPS = 0f;

private final CameraConfigurationManager configManager;
Camera.Parameters param;

public byte[][] frameBuffers;
public int fbCounter = 0;
Expand Down Expand Up @@ -724,8 +736,9 @@ public void onPreviewFrame(byte[] data, Camera camera)

try
{
int w = this.configManager.cameraResolution.x;
int h = this.configManager.cameraResolution.y;
param = camera.getParameters();
int w = param.getPreviewSize().width;
int h = param.getPreviewSize().height;

int[] rgbArray = new int[w * h];

Expand All @@ -750,6 +763,7 @@ public void onPreviewFrame(byte[] data, Camera camera)
bitmap.compress(Bitmap.CompressFormat.JPEG, 75, outputStream);
}


synchronized (this)
{
lastImage = outputStream.toByteArray();
Expand Down