How to create a camera2
more detail blog: http://vinta.ws/booch/?p=30
reference:
Camera 2
Google I/o video:https://www.youtube.com/watch?v=92fgcUNCHic#t=1758
Camera basic demo code: https://developer.android.com/preview/samples.html
Camera2 sdk reference (Need download 60mb): http://storage.googleapis.com/androiddevelopers/preview/l-developer-preview-reference.zip
Set up android l: https://developer.android.com/preview/setup-sdk.html
Camera
HAL3:https://source.android.com/devices/camera/camera3.html
HAL Subsystem https://source.android.com/devices/camera/camera3_requests_hal.html
https://source.android.com/devices/camera/camera.html
Slides from Android Builder's Summit 2014 in San Jose, CA
In this talk I describe the internal workings of the Android graphics stack from the Application layer down through the stack to pixels on the screen. It is a fairly complex journey, taking in two different 2D rendering engines, applications calling OpenGL ES directory, passing buffers on to the system compositor, SurfaceFlinger, and then down to the display controller or frame buffer.
Slides from Android Builder's Summit 2014 in San Jose, CA
In this talk I describe the internal workings of the Android graphics stack from the Application layer down through the stack to pixels on the screen. It is a fairly complex journey, taking in two different 2D rendering engines, applications calling OpenGL ES directory, passing buffers on to the system compositor, SurfaceFlinger, and then down to the display controller or frame buffer.
There are many books, articles and paper publications about Android and related applications but only a few are related to how Android operating system works internally.In this talk we will see how android boots up , an overview of zygote , how system server and package manager works. This talk will be extremely helpful to foster understanding among android developers about Android Internals as well as everybody else who desires a general understanding of the internal working of Android powered devices.
Découvrez le framework web Spring Boot qui a la cote !
Apprenez comment son système d'auto-configuration fonctionne.
Live coding et exemple de migration vers Spring Boot sont de la partie.
Ce support explique les concepts de bases du principe de l'inversion de contrôle et d'injections des dépendances.
Les concepts les plus importants à comprendre par les futurs ingénieurs du génie Logiciel.
Third chapter of the lecture Unreal Engine Basics taught at SAE Institute Hamburg.
- Learning how to expose class fields and functions to blueprints
- Writing basic Unreal gameplay code, such as spawning actors, accessing components and listening for events
- Getting familiar with gameplay concepts in the context of Unreal, such as damage and collision
Exemple d'application qui montre comment utiliser les bonnes pratiques de JEE pour développer un site web de commerce électronique en utilisant les outils :
- Eclipse comme environnement de développement
- Maven comme outil d’intégration
- JUnit comme Framework des tsts unitaire
- Spring IOC pour l'inversion de contrôle
- Spring MVC pour la couche web
- Spring Security pour la sécurité
- JPA, Hibernate
- Web Service SOAP
- Web Service REST
- Service RMI
This talk is about Nestjs and how it can help you build clean Nodejs backend apps, we will be covering also essential web development and JavaScript must know technologies and tools such as TypeScript and others.
Android Lollipop was released with new Camera2 APIs. This talk was delivered at the Samsung Developer's Conference 2014 showing how to use it and how it enables new use cases
There are many books, articles and paper publications about Android and related applications but only a few are related to how Android operating system works internally.In this talk we will see how android boots up , an overview of zygote , how system server and package manager works. This talk will be extremely helpful to foster understanding among android developers about Android Internals as well as everybody else who desires a general understanding of the internal working of Android powered devices.
Découvrez le framework web Spring Boot qui a la cote !
Apprenez comment son système d'auto-configuration fonctionne.
Live coding et exemple de migration vers Spring Boot sont de la partie.
Ce support explique les concepts de bases du principe de l'inversion de contrôle et d'injections des dépendances.
Les concepts les plus importants à comprendre par les futurs ingénieurs du génie Logiciel.
Third chapter of the lecture Unreal Engine Basics taught at SAE Institute Hamburg.
- Learning how to expose class fields and functions to blueprints
- Writing basic Unreal gameplay code, such as spawning actors, accessing components and listening for events
- Getting familiar with gameplay concepts in the context of Unreal, such as damage and collision
Exemple d'application qui montre comment utiliser les bonnes pratiques de JEE pour développer un site web de commerce électronique en utilisant les outils :
- Eclipse comme environnement de développement
- Maven comme outil d’intégration
- JUnit comme Framework des tsts unitaire
- Spring IOC pour l'inversion de contrôle
- Spring MVC pour la couche web
- Spring Security pour la sécurité
- JPA, Hibernate
- Web Service SOAP
- Web Service REST
- Service RMI
This talk is about Nestjs and how it can help you build clean Nodejs backend apps, we will be covering also essential web development and JavaScript must know technologies and tools such as TypeScript and others.
Android Lollipop was released with new Camera2 APIs. This talk was delivered at the Samsung Developer's Conference 2014 showing how to use it and how it enables new use cases
The Mobile Vision API provides a framework for recognizing objects in photos and videos. The framework includes detectors, which locate and describe visual objects in images or video frames, and an event-driven API that tracks the position of those objects in video.
Useful Tools for Making Video Games - XNA (2008)Korhan Bircan
A presentations I gave back in 2008 when I was the teaching assistant for Innovating Game Development course in Brown University.
This is an introductory tutorial of Microsoft XNA Game Studio. I talk about displaying 3D models, handling keyboard and mouse input, 3rd person shooter camera, and creating spline animations.
With recent advances in wearable technology, it's now possible to create novel fitness experiences without building custom hardware. In this talk we take you through creating a fitness tracker in C# on Android Wear, covering Google Play Services and watch-faces along the way. If this piques your interest, you can build your own Android Wear-based fitness tracker in our code lab!
Programming with Segue
Dynamic design through coding
Views and its Co-ordinates
Core animations
Picture pickers
Sound manager
Address book picker
- Hussain KMR Behestee
For a number of years now we have been hearing about all of the benefits that automated unit testing provides like increasing our quality, catching errors earlier, ensuring that all developers are testing in the same manner and deploying updates with high confidence that nothing will break. Testing a Web UI though was difficult and fragile which meant that typically we had no automated unit test for our Web UI. This is no longer the case with the latest release of Angular. Unit testing is now a first class citizen in Angular.
Out of the box, the project generated by the Angular CLI has unit testing setup with Karma and Jasmine and includes sample tests. Generating new components, services, and pipes includes the unit test Spec file already wired up. Thus allowing you to focus on writing your unit tests and not on the infrastructure needed to get them running. The barriers to writing unit test have been destroyed.
This talk will walk through getting started unit testing your Angular components, services, and pipes. Along the way I will share the tips and tricks that I have learned as I have implemented unit testing on my Angular projects at a Fortune 100 company. You will walk away ready to immediately implement unit testing on your Angular project.
This presentation that we're going to talk about how to use CameraKit to implement high performance real-time camera app. We also will cover the tips that you should know when you implement customized camera feature in your app.
How to implement camera recording for USB webcam or IP camera in C#.NETOzeki Informatics Ltd.
More info: www.camera-sdk.com
Source code: http://www.camera-sdk.com/p_123-video-tutorial-on-how-to-record-video-in-c-onvif.html
Welcome to this presentation that explains step-by-step how to develop video recording feature for your USB webcam and your IP camera / ONVIF IP camera in C#.NET to be able to capture and save the camera image. Good luck, have fun!
2. How to create a camera2
• Step1:To enumerate, query, and open available camera devices,
obtain a CameraManager instance.
CameraManager manager = (CameraManager)
activity.getSystemService(Context.CAMERA_SERVICE);
String cameraId = manager.getCameraIdList()[0];
3. Initialize CameraDevice
● Step2:Individual CameraDevices provide a set of static property
information that describes the hardware device and the available
settings and output parameters for the device.
// To get a list of available sizes of camera preview, we retrieve an instance of
// StreamConfigurationMap from CameraCharacteristics
CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
StreamConfigurationMap map = characteristics
.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
(Camera.Size) mPreviewSize = map.getOutputSizes(SurfaceTexture.class)[0];
(SurfaceTexture) mTextureView.setAspectRatio(mPreviewSize.getWidth(),
// We are opening the camera with a listener. When it is ready, onOpened of
// (CameraDevice.StateListener)mStateListener is called.
manager.openCamera(cameraId, mStateListener, null);
4. CameraDevice.StateListener
A listener for notifications about the state of a camera device.
onOpened(CameraDevice cameraDevice) ;
//The method called when a camera device has finished opening.
// always start preview after camera device open
(CameraDevice) mCameraDevice = cameraDevice;
StartPreview(); //Not camera2 API.
onDisconnected(CameraDevice cameraDevice);
//The method called when a camera device is no longer available for use.
cameraDevice.close();
onError(CameraDevice cameraDevice, int error) ;
//The method called when a camera device has encountered a serious
error.
// Some error code , ex:in use , device disable....
5. CameraDevice
The CameraDevice class is a representation of a single camera connected to an
Android device, allowing for fine-grain control of image capture and post-
processing at high frame rates.
•Device is modeled as a pipeline
• Input : CaptureRequest for a single Frame
• Output: CaptureResult Metadata packet + output image buffers for the
request. These buffers can go to one or multiple output targets
•SurfaceView
•SurfaceTexture
•MediaCodec
•MediaRecorder
•Renderscript Allocation et al
•ImageReader
• Requests are processed in order, multiple requests are in flight to maintain
full frame rate ( generally means 30 frames per second )
6. Start preview
Step3:To capture or stream images from a camera device, the
application must first create a camera capture session with a
set of output Surfaces for use with the camera device
SurfaceTexture texture = mTextureView.getSurfaceTexture();
// We configure the size of default buffer to be the size of camera preview we want.
texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
// This is the output Surface we need to start preview.
Surface surface = new Surface(texture);
// We set up a CaptureRequest.Builder with the output Surface.
mPreviewBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
mPreviewBuilder.addTarget(surface);
// Here, we create a CameraCaptureSession for camera preview.
mCameraDevice.createCaptureSession(Arrays.asList(surface),
new CameraCaptureSession.StateListener(){.....}
7. CaptureRequest.Builder
A builder for capture requests.
To obtain a builder instance, use the createCaptureRequest(int)
method, which initializes the request fields to one of the templates
defined in CameraDevice.
Method
addTarget(Surface outputTarget)
Add a surface to the list of targets for this request
set(Key<T> key, T value)
Set a capture request field to a value.
8. CaptureRequest
An immutable package of settings and outputs needed to capture a single
image from the camera device.
Contains the configuration for the capture hardware (sensor, lens, flash),
the processing pipeline, the control algorithms, and the output buffers. Also
contains the list of target Surfaces to send image data to for this capture.
CaptureRequests can be created by using a CaptureRequest.Builder instance,
obtained by calling createCaptureRequest(int)
Method
(<T> T) get(Key<T> key)
Get a capture request field value.
(List<Key<?>>) getKeys()
Returns a list of the keys contained in this map.
9. CameraCaptureSession.StateListener
A listener for tracking the state of a camera capture session.
onConfigured(CameraCaptureSession session)
This method is called when the camera device has finished configuring itself, and the
session can start processing capture requests.
//In here, we set this session to update preview
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
// When the session is ready, we start displaying the preview.
mPreviewSession = cameraCaptureSession;
// In this sample, we just let the camera device pick the automatic settings.
mPreviewBuilder.set(CaptureRequest.CONTROL_MODE
, CameraMetadata.CONTROL_MODE_AUTO);
HandlerThread thread = new HandlerThread("CameraPreview");
thread.start();
Handler backgroundHandler = new Handler(thread.getLooper());
// Finally, we start displaying the camera preview.
mPreviewSession.setRepeatingRequest(mPreviewBuilder.build(), null, backgroundHandler);
}
10. CameraCaptureSession
A configured capture session for a CameraDevice, used for capturing images from
the camera.
A CameraCaptureSession is created by providing a set of target output surfaces to
createCaptureSession. Once created, the session is active until a new session is
created by the camera device, or the camera device is closed.
Method
capture(CaptureRequest request, CameraCaptureSession.CaptureListener
listener, Handler handler)
Submit a request for an image to be captured by the camera device.
captureBurst(List<CaptureRequest> requests,
CameraCaptureSession.CaptureListener listener, Handler handler)
Submit a list of requests to be captured in sequence as a burst.
setRepeatingBurst(List<CaptureRequest> requests,
CameraCaptureSession.CaptureListener listener, Handler handler)
Request endlessly repeating capture of a sequence of images by this
capture session.
setRepeatingRequest(CaptureRequest request,
CameraCaptureSession.CaptureListener listener, Handler handler)
Request endlessly repeating capture of images by this capture session.
11. Take picture
Step4: Capture of JPEG images or RAW buffers forDngCreator can be done
with ImageReader with the {android.graphics.ImageFormat#JPEG} and
{android.graphics.ImageFormat#RAW_SENSOR} formats.
CameraManager manager =
(CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
// Pick the best JPEG size that can be captured with this CameraDevice.
CameraCharacteristics characteristics =
manager.getCameraCharacteristics(mCameraDevice.getId());
Size[] jpegSizes = null;
if (characteristics != null) {
jpegSizes =
characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP) .getOutputSizes(ImageFor
mat.JPEG);
}
int width = 640; int height = 480;
if (jpegSizes != null && 0 < jpegSizes.length) {
width = jpegSizes[0].getWidth();
height = jpegSizes[0].getHeight();
}
12. Take picture
Step5:Use ImageReader to get output data.
// We use an ImageReader to get a JPEG from CameraDevice.
// Here, we create a new ImageReader and prepare its Surface as an output from camera.
ImageReader reader = ImageReader.newInstance(width, height, ImageFormat.JPEG, 1);
List<Surface> outputSurfaces = new ArrayList<Surface>(2);
outputSurfaces.add(reader.getSurface());
outputSurfaces.add(new Surface(mTextureView.getSurfaceTexture()));
// This is the CaptureRequest.Builder that we use to take a picture.
final CaptureRequest.Builder captureBuilder =
mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
captureBuilder.addTarget(reader.getSurface());
// In this sample, we just let the camera device pick the automatic settings.
captureBuilder.set(CaptureRequest.CONTROL_MODE,CameraMetadata.CONTROL_MODE_AUTO);
13. ImageReader
The ImageReader class allows direct application access to image data rendered into
a Surface
Method
static (ImageReader) newInstance(int width, int height, int format, int
maxImages)
Create a new reader for images of the desired size and format.
(Image) acquireLatestImage()
Acquire the latest Image from the ImageReader's queue, dropping
older images.
(Image) acquireNextImage()
Acquire the next Image from the ImageReader's queue.
14. Take picture
Step5:Set output data parameters.
// In this sample, we just let the camera device pick the automatic settings.
capturebuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
// Orientation
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATIONS.get(rotation));
// Output file
final File file = new File(activity.getExternalFilesDir(null), "pic.jpg");
// This listener is called when a image is ready in ImageReader
ImageReader.OnImageAvailableListener readerListener =
new ImageReader.OnImageAvailableListener() {….}
15. ImageReader.OnImageAvailableListener
Callback interface for being notified that a new image is available.
onImageAvailable(ImageReader reader) {
image = reader.acquireLatestImage();
ByteBuffer buffer = image.getPlanes()[0].getBuffer();
byte[] bytes = new byte[buffer.capacity()];
buffer.get(bytes);
save(bytes);
…..//Use output stream to write out to file.
……
Image.close();
16. Take picture
Step6:Set output data parameters. And start camera capture picture thread.
// In this sample, we just let the camera device pick the automatic settings.
capturebuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
// Orientation
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATIONS.get(rotation));
// Output file
final File file = new File(activity.getExternalFilesDir(null), "pic.jpg");
// This listener is called when a image is ready in ImageReader
ImageReader.OnImageAvailableListener readerListener =
new ImageReader.OnImageAvailableListener() {….}
// We create a Handler since we want to handle the result JPEG in a background thread
HandlerThread thread = new HandlerThread("CameraPicture");
thread.start();
final Handler backgroundHandler = new Handler(thread.getLooper());
reader.setOnImageAvailableListener(readerListener, backgroundHandler);
17. Take picture
Step7:Restart preview thread after capture complete.
// This listener is called when the capture is completed.
// Note that the JPEG data is not available in this listener, but in the
// ImageReader.OnImageAvailableListener we created above.
final CameraCaptureSession.CaptureListener captureListener =
new CameraCaptureSession.CaptureListener() {
public void onCaptureCompleted(CameraCaptureSession session,
CaptureRequest request, TotalCaptureResult result) {
// We restart the preview when the capture is completed
startPreview();
}
};
// Finally, we can start a new CameraCaptureSession to take a
picture. mCameraDevice.createCaptureSession(outputSurfaces,
new CameraCaptureSession.StateListener() {
public void onConfigured(CameraCaptureSession session) {
try {
session.capture(captureBuilder.build(), captureListener,
backgroundHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
}
}
}, backgroundHandler );
22. Q4
Q:ImageReader 使用方法?
A:Use ImageReader.getSurface() to get a Surface that can
be used to produce Images for this ImageReader.
Q3-1:what is surface?
A3-1:
1.Handle onto a raw buffer that is being managed by
the screen compositor.
2. surface 的canvas成員可以用來提供繪圖的場所,
raw buffer 用來保存data ,取得surface 等同取得
canvas 和 raw buffer的內容。
summary: 於camera ap 裡則是等同提供capture輸出