Created
March 10, 2011 22:26
-
-
Save Two9A/865066 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.imrannazar.anpr; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.pm.ActivityInfo; | |
import android.graphics.PixelFormat; | |
import android.hardware.Camera; | |
import android.hardware.Camera.Parameters; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.view.SurfaceHolder; | |
import android.view.SurfaceHolder.Callback; | |
import android.view.SurfaceView; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.FrameLayout; | |
import android.widget.Toast; | |
import java.net.*; | |
import java.io.IOException; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.ResponseHandler; | |
import org.apache.http.client.methods.HttpGet; | |
import org.apache.http.impl.client.DefaultHttpClient; | |
import org.apache.http.impl.client.BasicResponseHandler; | |
public class Anpr extends Activity implements SurfaceHolder.Callback | |
{ | |
private static final String LOGTAG = "Anpr"; | |
private Camera mCam; | |
private SurfaceHolder mSH; | |
private SurfaceView mSV; | |
private boolean mPreview = false; | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) | |
{ | |
Log.v(LOGTAG, "Created"); | |
try | |
{ | |
super.onCreate(savedInstanceState); | |
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | |
setContentView(R.layout.main); | |
mSV = (SurfaceView)findViewById(R.id.surface_camera); | |
mSH = mSV.getHolder(); | |
mSH.addCallback(this); | |
mSH.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); | |
} | |
catch(Exception e) | |
{ | |
Log.e(LOGTAG, "View creation failed"); | |
e.printStackTrace(); | |
} | |
} | |
public void surfaceCreated(SurfaceHolder sh) | |
{ | |
Log.v(LOGTAG, "Created surface"); | |
mCam = Camera.open(); | |
mPreview = false; | |
} | |
public void surfaceChanged(SurfaceHolder sh, int format, int w, int h) | |
{ | |
Log.v(LOGTAG, "Surface parameters changed: "+w+"x"+h); | |
if(mPreview) mCam.stopPreview(); | |
Camera.Parameters p = mCam.getParameters(); | |
p.setPreviewSize(w, h); | |
mCam.setParameters(p); | |
Log.v(LOGTAG, "Preview size set"); | |
try | |
{ | |
mCam.setPreviewDisplay(sh); | |
} | |
catch(Exception e) | |
{ | |
Log.e(LOGTAG, "Preview set failed"); | |
e.printStackTrace(); | |
} | |
mCam.startPreview(); | |
mPreview = true; | |
} | |
public void surfaceDestroyed(SurfaceHolder sh) | |
{ | |
Log.v(LOGTAG, "Destroyed surface"); | |
mCam.stopPreview(); | |
mPreview = false; | |
mCam.release(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
V/Anpr (22490): Created | |
V/Anpr (22490): Created surface | |
E/QualcommCameraHardware( 160): openCameraHardware: call createInstance | |
E/QualcommCameraHardware( 160): createInstance: E | |
E/QualcommCameraHardware( 160): Storing the current target type as 1 | |
E/QualcommCameraHardware( 160): constructor EX | |
E/QualcommCameraHardware( 160): startCamera E | |
E/QualcommCameraHardware( 160): loading liboemcamera at 0x700102f4 | |
E/QualcommCameraHardware( 160): startCamera X | |
E/QualcommCameraHardware( 160): initDefaultParameters E | |
E/QualcommCameraHardware( 160): max zoom is 50 | |
E/QualcommCameraHardware( 160): Using Overlay : NO | |
E/QualcommCameraHardware( 160): initDefaultParameters X | |
E/QualcommCameraHardware( 160): createInstance: X created hardware=0x934a8 | |
E/QualcommCameraHardware( 160): Using Overlay : NO | |
V/Anpr (22490): Surface parameters changed: 320x483 | |
E/QualcommCameraHardware( 160): setParameters: E params = 0x7ef69b28 | |
E/QualcommCameraHardware( 160): requested preview size 320 x 483 | |
E/QualcommCameraHardware( 160): Invalid preview size requested: 320x483 | |
E/QualcommCameraHardware( 160): requested picture size 2048 x 1536 | |
E/QualcommCameraHardware( 160): native_set_parm: fd 21, type 21, length 4 | |
E/QualcommCameraHardware( 160): native_set_parm: fd 21, type 14, length 4 | |
E/QualcommCameraHardware( 160): native_set_parm: fd 21, type 15, length 4 | |
E/QualcommCameraHardware( 160): setFlash: flash not supported | |
E/QualcommCameraHardware( 160): native_get_maxzoom E | |
E/QualcommCameraHardware( 160): ctrlCmd.value = 0 | |
E/QualcommCameraHardware( 160): native_get_maxzoom X | |
E/QualcommCameraHardware( 160): Maximum zoom value is 0 | |
E/QualcommCameraHardware( 160): Set zoom=0, mMaxZoom=0 | |
E/QualcommCameraHardware( 160): setZoom: mMaxZoom = 0 | |
E/QualcommCameraHardware( 160): setParameters: setZoom failed! | |
E/Camera (22490): Failed to set all parameters | |
E/AndroidRuntime(22490): FATAL EXCEPTION: main | |
E/AndroidRuntime(22490): java.lang.IllegalArgumentException: Invalid Parameters | |
E/AndroidRuntime(22490): at android.hardware.Camera.setParameters(Camera.java:659) | |
E/AndroidRuntime(22490): at com.imrannazar.anpr.Anpr.surfaceChanged(Anpr.java:73) | |
E/AndroidRuntime(22490): at android.view.SurfaceView.updateWindow(SurfaceView.java:538) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment