public final class CameraManager extends Object
Modifier and Type | Field and Description |
---|---|
private AutoFocusCallback |
autoFocusCallback
Autofocus callbacks arrive here, and are dispatched to the Handler which requested them.
|
private Camera |
camera |
private CameraConfigurationManager |
configManager |
private Context |
context |
private Rect |
framingRect |
private Rect |
framingRectInPreview |
private boolean |
initialized |
private static int |
MAX_FRAME_HEIGHT |
private static int |
MAX_FRAME_WIDTH |
private static int |
MIN_FRAME_HEIGHT |
private static int |
MIN_FRAME_WIDTH |
private PreviewCallback |
previewCallback
Preview frames are delivered here, which we pass on to the registered handler.
|
private boolean |
previewing |
private int |
requestedFramingRectHeight |
private int |
requestedFramingRectWidth |
private boolean |
reverseImage |
private static String |
TAG |
Constructor and Description |
---|
CameraManager(Context context) |
Modifier and Type | Method and Description |
---|---|
PlanarYUVLuminanceSource |
buildLuminanceSource(byte[] data,
int width,
int height)
A factory method to build the appropriate LuminanceSource object based on the format
of the preview buffers, as described by Camera.Parameters.
|
void |
closeDriver()
Closes the camera driver if still in use.
|
Rect |
getFramingRect()
Calculates the framing rect which the UI should draw to show the user where to place the
barcode.
|
Rect |
getFramingRectInPreview()
Like
getFramingRect() but coordinates are in terms of the preview frame,
not UI / screen. |
void |
openDriver(SurfaceHolder holder)
Opens the camera driver and initializes the hardware parameters.
|
void |
requestAutoFocus(Handler handler,
int message)
Asks the camera hardware to perform an autofocus.
|
void |
requestPreviewFrame(Handler handler,
int message)
A single preview frame will be returned to the handler supplied.
|
void |
setManualFramingRect(int width,
int height)
Allows third party apps to specify the scanning rectangle dimensions, rather than determine
them automatically based on screen resolution.
|
void |
startPreview()
Asks the camera hardware to begin drawing preview frames to the screen.
|
void |
stopPreview()
Tells the camera to stop drawing preview frames.
|
private static final String TAG
private static final int MIN_FRAME_WIDTH
private static final int MIN_FRAME_HEIGHT
private static final int MAX_FRAME_WIDTH
private static final int MAX_FRAME_HEIGHT
private final Context context
private final CameraConfigurationManager configManager
private Camera camera
private Rect framingRect
private Rect framingRectInPreview
private boolean initialized
private boolean previewing
private boolean reverseImage
private int requestedFramingRectWidth
private int requestedFramingRectHeight
private final PreviewCallback previewCallback
private final AutoFocusCallback autoFocusCallback
public CameraManager(Context context)
public void openDriver(SurfaceHolder holder) throws IOException
holder
- The surface object which the camera will draw preview frames into.IOException
- Indicates the camera driver failed to open.public void closeDriver()
public void startPreview()
public void stopPreview()
public void requestPreviewFrame(Handler handler, int message)
handler
- The handler to send the message to.message
- The what field of the message to be sent.public void requestAutoFocus(Handler handler, int message)
handler
- The Handler to notify when the autofocus completes.message
- The message to deliver.public Rect getFramingRect()
public Rect getFramingRectInPreview()
getFramingRect()
but coordinates are in terms of the preview frame,
not UI / screen.public void setManualFramingRect(int width, int height)
width
- The width in pixels to scan.height
- The height in pixels to scan.public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height)
data
- A preview frame.width
- The width of the image.height
- The height of the image.