PowerApp Camera Control

Introduction

This would be a common scenario in most cases working with camera control in PowerApps. In this article, we will go through some of the important functions of camera control. There is a step-by-step article already explained by Anugunila Meghanathan, and the link I am putting in the references section.

Feeding the images from Camera Control to Gallery

For this create an empty canvas App with a Tablet layout and do the following steps,

Step 1

Drag the camera control to your design pane, name it “MyCameraControl”.

PowerApp Camera Control

You can name it according to your needs. You should see a screen capture similar to the one below,

PowerApp Camera Control

Step 2

Now insert the ‘Gallery’ control from the Ribbon, and then select ‘Horizontal’ gallery. Adjust this according to your screen.

PowerApp Camera Control

After adjusting you should see the below screen.

PowerApp Camera Control

Step 3

For the camera, you have the ‘OnSelect’ function. Select the camera control and then select the ‘OnSelect’ function, in the value enter the following formula.

Collect(CollCameraImages,Self.Photo)

Let's try to understand. At first, you are using ‘Collect’ which is used to create a collection and declared a collection variable called ‘CollCameraImages’. You can name this variable according to your need. Last I have used the ‘Self’ function, which is a function defined for ‘Camera’ control, and then select the ‘Photo’ property. You can also choose the camera control (in this case MyCameraControl.Photo).

PowerApp Camera Control

Now that you have defined the function for camera ‘Onselect’, each time you click on the camera control, it captures the picture and then stores it in the collection ‘CollCameraImages’.

Step 4

You can feed the collection so that it displays in the gallery. For this select the ‘Gallery’ control and then select the ‘Data sources’ as the collection as shown in the below screen capture.

PowerApp Camera Control

After this observe that items property for the gallery is set to collection ‘CollCameraImages’.

Step 5

Preview the App. Each time, you click on the camera control, the image is captured and shown in the gallery.

PowerApp Camera Control

PowerApp Camera Control

Feeding the items to the gallery automatically(Burst Mode)

The camera control has a property called ‘stream’. By default, the StreamRate is set to 0 and the ‘OnSteam’ function is set to false. You can set the ‘StreamRate’ to 10000 and the OnStream function to,

Collect(CollCameraImages,Self.Stream)

For every 10 seconds, your camera can take a picture and then puts it in the Image gallery.

PowerApp Camera Control

Clear the gallery

 This is very simple. Please follow the below steps to clear the images.

Step 1

Insert a button and then set the ‘OnSelect’ property to clear the collection CollImageGallery.

Function for ‘OnSelect’ property is set to Clear(CollCameraImages).

Preview the app, and click on the ‘Clear Images’ button, you should see all the gallery items are cleaned up.

PowerApp Camera Control

PowerApp Camera Control

Conclusion

Thus, in this article, we have seen how to load images from picture control to gallery, and how to auto feed the stream of image captures and then finally clearing up the captured images in Power App.

References


Similar Articles