AnDevCon 2014: "Building a Custom Camera Application"
This repository contains the Android project that I used for my AnDevCon Boston 2014 Presentation "Building a Custom Camera Application." I actually plan to clean-up the code and package some of the code in a library for re-use so please drop me a note if you are interested in that or any other features which I did not get a chance to discuss.
Project structure
So for demonstration purposes and for playing-around-with-gradle purposes, I created a different product flavor for each demo application. There are some flavors with minute changes and some which I did not actually use or both. For those demos that I actually reviewed today, you can install them via gradle as follow:
- Basic setup and picture taking: demonstration of camera setup, calling the
Camera#takePicture
method and displaying image data in anImageView
.
- Flavor: basicPictureTaking
- Main activity:
BasicPictureTakingActivity.java
- Build command:
./gradlew iBPTD
- Using
CameraInfo
to switch cameras: demonstration of how to queryCameraInfo
for the various cameras on a device and using info to find and switch between device cameras.
- Flavor: basicCameraInfo
- Main activity:
BasicCameraInfoActivity.java
- Build command:
./gradlew iBCID
- Dealing with activity orientation vs. camera/preview orientation.
- Flavor: basicOrientation
- Main activity:
BasicOrientationActivity.java
- Build command:
./gradlew iBOD
- Using
Camera.Parameters
to access device settings.
- Flavor: basicParameters
- Main activity:
BasicParametersActivity.java
- Build command:
./gradlew iBPD
- Implementing touch-to-focus with focus areas and
Camera.Area
.
- Flavor: area
- Main activity:
CameraAreaActivity.java
- Build command:
./gradlew iAD
- Using face detection.
- Flavor: faceDetection
- Main activity:
FaceDetectionActivity.java
- Build command:
./gradlew iFDD
Other classes
PreviewSurface
: ASurfaceView
class used inBasicParametersActivity
andBasicOrientationActivity
to consolidateSurfaceView
-related logic.Preview
andPreviewOverlay
: Views used inCameraAreaActivity
andFaceDetectionActivity
in lieu of a plainSurfaceView
orPreviewSurface
. Includes logic for capturing touch events and drawing on top of a camera preview.