Skip to content

Commit 043d2a5

Browse files
committed
Camera and Preview Callback
Signed-off-by: Umair Khan <[email protected]>
1 parent 37d556d commit 043d2a5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/in/omerjerk/processing/video/android/Capture.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
import processing.core.PConstants;
1414
import processing.core.PImage;
1515

16-
//@SuppressWarnings("deprecation")
1716
public class Capture extends PImage implements PConstants {
1817

1918
private static final boolean DEBUG = true;
2019
public static void log(String log) {if (DEBUG) System.out.println(log);}
2120

2221
private Context context;
2322

23+
private Camera mCamera;
24+
2425
private static ArrayList<String> camerasList = new ArrayList<String>();
2526

2627
private static final String KEY_FRONT_CAMERA = "front-camera-%d";
@@ -38,7 +39,16 @@ public void setCamera(String camera) {
3839
} else {
3940
selectedCamera = camerasList.indexOf(camera);
4041
}
41-
log("Selected camera = " + selectedCamera);
42+
log("Selected camera = " + selectedCamera);
43+
try {
44+
mCamera = Camera.open(selectedCamera);
45+
CameraPreview mPreview = new CameraPreview(context, mCamera);
46+
mCamera.setPreviewCallback(previewCallback);
47+
} catch (Exception e) {
48+
System.err.println("Camera not avaialble to use.");
49+
e.printStackTrace();
50+
}
51+
4252
}
4353

4454
public String[] list() {
@@ -130,4 +140,4 @@ public void surfaceDestroyed(SurfaceHolder holder) {
130140
// do nothing
131141
}
132142
}
133-
}
143+
}

0 commit comments

Comments
 (0)