3. Image capture
If you want to capture an image, e.g. take a photo after clicking a button, and the device can be positioned horizontally or vertically, make sure that the display surface and the captured image have the same orientation.
imageCapture = new ImageCapture.Builder()
.setTargetRotation(previewView.getDisplay().getRotation())
.build();
We'll save the image. This code will normally be executed when a button is clicked.
Indicate the name and location where the image will be saved. In this case, it will be in the images directory (DIRECTORY_PICTURES) :
String file_path = getExternalFilesDir(Environment.DIRECTORY_PICTURES) + "/pic.jpg";
ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(new File(file_path)).build();
We capture the image. We know from the call of onImageSaved and onError if the capture went well:
...
You do not have access to this resource.
Exclusive to subscribers. 97% yet to be discovered!
Already subscribed?
Log in!
Ongoing reading
Image capture
Bibliography
Also in our database
-
LEMOINE (F.) - Programmation de capteurs sur dispositifs mobiles. - [H 1 595]...
Websites
Android developers (page consulted on July 14, 2023). Reference site for programming on the Android™ platform. This site presents an important documentary reference base as well as the tools necessary for programming https://developer.android.com/
Development kit for the Android™ platform (page consulted on July 14, 2023). The set of tools you need to install...
Events
Google I/O (page consulted on July 14, 2023). Annual two-day conference organized by Google at the Moscone Center in San Francisco, California. Its aim is to announce developments in the many services and technologies offered by Google. https://io.google
Android Dev Summit (page accessed July 14, 2023). The world's leading conference for practical Android™ application...
Directory
Manufacturers – Suppliers – Distributors (non-exhaustive list)
Google (Pixel phone) https://store.google.com/fr/category/phones
Samsung (Android™-based phones and tablets) http://www.samsung.com
Sony (Android™-based phones and tablets)
You do not have access to this resource.
Exclusive to subscribers. 97% yet to be discovered!
Already subscribed?
Log in!