3dphotoshoot

view src/android/MainActivity.java @ 3:9df99687a2ff

the old camera API is horrible
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 15 May 2015 05:15:47 +0300
parents cf5964db7ff3
children 38377f54527a
line source
1 package com.mutantstargoat.photoshoot3d;
3 import android.app.NativeActivity;
4 import android.util.Log;
5 /*
6 import android.os.Bundle;
7 import android.content.Context;
8 import android.hardware.Camera;
9 import android.hardware.Camera.CameraInfo;
10 import android.hardware.camera2.*;
11 */
13 public class MainActivity extends NativeActivity {
14 private static String tag = "photoshoot3d";
16 public static int foo(String s, int n)
17 {
18 Log.i(tag, s + ": " + n);
19 return 42;
20 }
22 /*
23 // old camera api (fallback)
24 private Camera cam;
26 // camera2 api (sdk version >= 21)
27 private CameraManager cman;
28 private CameraDevice cam2;
29 private CameraCaptureSession cam_session;
31 @Override
32 protected void onCreate(Bundle state)
33 {
34 super.onCreate(state);
36 if(android.os.Build.VERSION.SDK_INT >= 21) {
37 Log.i(tag, "Using the new camera API");
39 cman = (CameraManager)getSystemService(Context.CAMERA_SERVICE);
41 try {
42 String [] clist = cman.getCameraIdList();
43 Log.i(tag, "Found " + clist.length + " cameras");
45 for(int i=0; i<clist.length; i++) {
46 Log.i(tag, "camera[" + i + "]: " + clist[i]);
47 }
48 }
49 catch(CameraAccessException e) {
50 Log.e(tag, "camera access exception");
51 }
53 } else {
54 // fallback to the old Camera API
55 Log.i(tag, "Using the old camera API");
57 int num_cams = Camera.getNumberOfCameras();
58 Log.i(tag, "Found " + num_cams + " cameras");
60 for(int i=0; i<num_cams; i++) {
61 CameraInfo info = new CameraInfo();
62 Camera.getCameraInfo(i, info);
64 String facing_str = info.facing == CameraInfo.CAMERA_FACING_FRONT ? "front" : "back";
66 Log.i(tag, "camera[" + i + "]: " + facing_str);
67 }
68 }
70 start_video();
71 }
73 public void start_video()
74 {
75 cam = Camera.open();
77 CamPreview preview = new CamPreview(this, cam);
79 }
80 */
81 }
83 /*
84 class CamPreview extends ViewGroup implements SurfaceHolder.Callback {
85 SurfaceView surf_view;
86 SurfaceHolder surf_holder;
88 CamPreview(Context ctx)
89 {
90 super(ctx);
92 surf_view = new SurfaceView(ctx);
93 addView(surf_view);
95 surf_holder = surf_view.getHolder();
96 surf_holder.addCallback(this);
97 surf_holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
98 }
99 }
100 */