Working with Image Files in the Camera

Image List

The image files in the storage of the camera can be browsed from the application. The CameraFileListViewActivity class uses the CustomListAdapter class to save information of the images.

 

The list of images in the camera is obtained by executing camera.listFiles command. The CameraFileListViewActivity class implements getListFiles()to execute this action. Note that the method is called with mediaType set to “image”.

 

If the camera cannot return the complete list, the continuationToken field is set in the response. Then the client should send camera.listFiles command again to obtain the remaining list of images. Repeat this command until the last item is obtained.  

Thumbnail List

The sample application shows the thumbnail images as a list on the screen. The getView() method gets a thumbnail view for each image item in the list by using camera.getFile command. It ensures to display multiple thumbnail images in a seamless manner. The sample application assigns 144 to maxSize. 

Image Information

By clicking on one of the thumbnail images listed on the screen, the sample application shows the following list dialog:

 

android_list_dialog_selected_image.png

 

 ‘Show Information’ shows a dialog that displays information of the image selected. This information is obtained by camera.getMetadata command. The CameraFileListViewActivity class implements the getFileMetadata() method to execute this action.

 

android_image022.png

Download Image

‘Get File’ downloads the selected image from the camera to the smartphone that runs the sample application. The CameraFileListViewActivity class implements the getFullFile() method to download the file by using camera.getFile command. Make sure to update the HTTP header to include "Accept: image/jpeg".

 

android_image_download_1.png android_image_download_2.png

Delete Image

‘Delete’ deletes the image from the camera. The CameraFileListViewActivity class implements the deleteFilesFromCamera() method to delete the file by using camera.delete command. The deleteFilesFromCamera() method also updates the list object to remove the item from the list.

 

android_image_delete.png 

Capture Image

By clicking the ‘CAMERA TAKE PICTURE’ button, the sample application starts TakePictureActivity. If the ‘TAKE PICTURE’ button is clicked, the sample application sends camera.takePicture command. The captured image is saved in the camera.

 

android_image026.png

 

By clicking the ‘MANUAL METADATA’ button, the sample application sends camera._manualMetadata command and shows its result as shown below. Note that exposureProgram option must be set to 1(manual) prior to command submission; otherwise the camera returns an error indicating that exposureProgram is not set to manual.

 

android_image027.png 

Interval Capture

The application can control the camera to execute interval capture action. The CaptureIntervalActivity class is responsible for managing the interval capture feature.

 

By clicking the ‘INTERVALSHOT’ button from the UI of TakePictueActivity, the sample application starts CaptureIntervalActivity. The following figure shows the UI layout of CaptureIntervalActivity. Before entering this Activity, the TakePictueActivity presents a dialog where the user can easily change captureMode option to “interval” so that the user can readily use the interval capture features.

 

android_image028.png

 

Set captureNumber and captureInterval options and click ‘START CAPTURE’ (camera.startCapture) to execute a non-open-ended interval capture. If captureNumber is set to 0, the sample application executes an open-ended capture.

 

Click ‘STOP CAPTURE’ (camera.stopCapture) to finish interval capture. Non-open-ended capture stops automatically when the camera completes the specified capture action. It can still be terminated earlier by sending camera.stopCapture command.

 

Note that the camera does not return fileUrls response immediately; make sure to check the command status with the /osc/commands/status API. Although the command status returns “done”, the camera might have not finished saving captured images and listing them in the fileUrls field. The sample application waits for captureNumber * captureInterval seconds after submitting camera.startCapture command to get the full list of fileUrls. For this reason, startCapture() method of CaptureIntervalActivity uses postDelayed() with a handler when executing interval capture action.

 

It is a good design practice to make the application wait for a certain amount of time (captureNumber * captureInterval) after submitting camera.startCapture command so that the camera can respond with the full list of captured images. 

Burst Capture

The application can control the camera to execute burst capture action. The BurstShotActivity class is responsible for managing the burst capture feature.

 

By clicking the ‘BURSTSHOT’ button from from the UI of TakePictueActivity, the sample application starts BurstShotActivity. The following figure shows the UI layout of BurstShotActivity. Before entering this Activity, the TakePictueActivity presents a dialog where the user can easily change captureMode option to “burst” so that the user can readily use the burst capture features.

 

android_burstshot.png

 

Set ‘burstNumber’ option (_burstshotNumber option) and click ‘START CAPTURE’ (camera.startCapture) to execute a burst capture. Note that the command returns ‘done’ state and no fileUrls are specified in the output.

 

Note that Burst Capture is supported on Action CAMLTE only.
Navigation