Camera Blocks
Last updated
Last updated
The camera blocks provide functionalities to interact with the device's camera. These blocks enable users to capture images or record videos directly within the app.
Each block in the camera blocks drawer has a regular and advanced block. To access the advanced version of a block:
Add the block to your workspace.
Right-click on it.
Select Show advanced block.
The advanced blocks return an "error" output block. If there is an error when executing the block, the error block will return an error message. If not, the error block will return a null value.
The "photo from camera" block opens the device's camera and allows the user to take a photo. The photo can then be used in the app.
Output Name | Data Type | Function |
---|---|---|
photo | image | If a photo was taken, returns the photo. |
was cancelled | true/false | Returns whether the user cancelled taking the photo. |
error | text | If there was an error, returns the error. |
In this tutorial, you’ll use Thunkable camera app features to create an app that takes a photo with the device's camera.
The "description of image from" block generates a description of a given image. This block requires internet access.
This component is powered by Microsoft Azure. You can get your own server URL and subscription key for Microsoft Azure here. You can add these details to your app in the Project Settings panel, which you can access by clicking on your app icon.
Output | Data Type | Function |
---|---|---|
description | text | Description of the image. |
tags | list of text | Returns tags used to identify the image. |
confidence level | number between 0 and 1 | Returns calculated confidence level that the given description is accurate. |
error | text | If there was an error, returns the error. |
In this tutorial, you’ll use Thunkable camera app features to create an app that takes a photo with the device's camera and utilizes image recognition functionality to identify the photo’s content.
Some more examples:
Connect the photo from photo library
block to the description of image from
block to allow users to browse and select any image stored on their device's photo library.
Connect the photo from camera
block to the description of image from
block to let users take a picture from their device's camera and upload it instantly.
Connect the image file from device
block to the description of image from
block for a more universal option that works on Android, iOS, and even in web apps, allowing users to upload any image file from their device, no matter the platform.
The "barcode scanned using camera" block scans a barcode or QR code and returns its value.
Output | Data Type | Function |
---|---|---|
value | text | Value of scanned barcode/QR code. |
type | text | Returns whether it was a barcode or QR code that was scanned. |
was cancelled | true/false | Returns whether the user cancelled scanning a code. |
error | text | If there was an error, returns the error. |
In this tutorial, we’ll add the functionality to scan a barcode or QR code with the device's camera.
Template App
Click Copy Project in the upper right.
The "video file from [5] second recording using [back] camera" block opens the device's camera and films from the selected camera for the chosen amount of time and then returns the video file.
Input | Data Type | Function |
---|---|---|
Number of Seconds | Number | Set how long to record for. |
Using [...] Camera | Select from menu | Select camera to record with (front or back). |
Output | Data Type | Function |
---|---|---|
videoFile | Video file | The recorded video footage. |
error | Text | If there is an error, returns the error. Else returns NULL. |
The "video file from recording using [back] camera" block opens the device's camera and films from the selected camera until the user ends the recording using the controls on the device's camera. It returns the video file.
Input | Data Type | Function |
---|---|---|
Using [...] Camera | Select from menu | Select a camera to record with (front or back). |
Output | Data Type | Function |
---|---|---|
video file | Video file | Returns the recorded video footage. |
Error | Text | If there is an error, returns the error. Else returns NULL. |
In this tutorial, you’ll use Thunkable camera app features to create an app that records a video with the device's camera.