Camera Module – Camera & Video

Camera

Like any general camera application present in mobile camera and video module also allows you to take pictures and videos but it also allows you to handle these activities by sending the command from your hardware.

You can send the command from your board to:

  1. Record videos
  2. Capture images
  3. Flip camera to front or rear
  4. Change the flash mode to ON, OFF or Auto
  5. Change zoom scaling
  6. Set camera quality to High or Low.

Camera Module

The Camera module allows you to use your mobile camera for different activities like recording videos, capturing images, color detection, and face detection. Depending on the type of activities you want to do with your mobile camera the module is further divided into four modules each capable of executing a specific activity.

Camera Module

These modules are:

  1. Camera and Videos
  2. Color Detector
  3. Line Follower (Coming Soon)
  4. Face Detector (Coming Soon)

Camera and Video Module

Like any general camera application present in mobile this module also allows you to take pictures and videos but it also allows you to handle these activities by sending the command from your hardware.Camera and Video

You can send the command from your board to:

  1. Record videos
  2. Capture images
  3. Flip camera to front or rear
  4. Change the flash mode to ON, OFF or Auto
  5. Change zoom scaling
  6. Set camera quality to High or Low.

Control of the same things is also possible from icons present in the module. You can view the images or videos captured through this module by clicking on the gallery icon present in middle at the top right corner of your screen beside the connect icon.

Arduino IDE Functions

Header

To include the Camera and Video module in the Arduino program, you have to include the following header:

#define CUSTOM_SETTINGS

#define INCLUDE_CAMERA_MODULE

After defining the above mention headers, you have to include the dabble library:

#include <Dabble.h>

You can download the zip of Arduino Library for

  1. evive, Uno, Mega, and Nano – Dabble-Arduino 
  2. ESP32 – Dabble-ESP32

depending on the board you are using.

Enabling Bluetooth Communication

To enable Bluetooth communication, you have to initialize serial communication using the following code:

  1. For evive and Arduino Mega, Uno and Nano
    Dabble.begin(Baud_Rate);

    Here Baud_Rate is the baud rate set for the Bluetooth module. With evive, you normally get 115200 baud rate modules.

  2. For ESP32
    Dabble.begin("Bluetooth_Name");

    In place of Bluetooth_Name  enter name that you want to keep for Bluetooth of ESP32. Default name given in the library is “MyEsp32”. 

Refreshing the data

To refresh the data that the device has got from the mobile app, you have to use the following line of code:

Dabble.processInput();

This function also change the state and the brightness of the LED automatically and you don’t have to do anything.

Functions

Following are the function available for the Camera and Video module:

  1. captureImage() – Sends command to click images.
  2. startRecording() – Sends command to start video.
  3. stopRecording() – Sends command to stop video.
  4. flipTo(direction) – This function sends the command to rotate the camera to front or rear. There are two constants namely FRONT and REAR defined in the library to change camera direction. Pass either of constant as an argument in place of “direction” in the function.
  5. setQuality(quality) – This function sends the command to set the quality of the camera. Using this function the quality of the camera can be set to high or low. There are two constants namely HIGH_QUALITY and LOW_QUALITY. Pass either of constant as an argument in place of “quality” in the function.
  6. flashMode(modeName) – This function sends the command to set flash mode. Using this command flash can be set to On, Off or Auto mode. There are three constants namely ON, OFF and AUTO. Pass either of the constant as an argument in place of “modeName” in the function.
  7. zoom(value) – Enter a value between 0 – 100 for setting that much percentage zoom on your mobile camera.
  8. setParameters(Direction, flash, quality, zoom) – This function allows you to set all basic camera settings before taking image or video. The direction of the camera, the flash status, quality and zoom value are passed as arguments to this function in sequential order as written. All these parameters are constants mentioned in the above functions.

PictoBlox (Scratch) Blocks

There are three blocks in this module. All three blocks are explained below:

  • set camera flash to” is a stacked block used for changing flash settings, camera quality and zoom settings of the camera. The block consists of two drop-down and a numeric entry section each helps in setting a unique parameter of Camera.

           First drop-down is for flash setting, it allows you to set the flash mode to On, Off or Auto.

           

         Second drop-down is for setting quality, it allows you to set camera quality to high or low. Enter zoom percent between 0 to 100 in the text field of zoom for getting that much % of zoom for camera. 

  • rotate camera to”  is a stacked block used to rotate the camera in the module. Its drop-down contains two option namely “rear” and “front” for rotating the camera to the front or rear side.
  • capture image on camera” is a stacked block used to send command for clicking image, starting the video and stopping the video in the camera module. Its drop-down consists of three options namely “Capture Image”, “Start Video” and “Stop Video”. 
evive Notes Icon
Note: When you are using this module with Arduino Uno, Mega, and Nano,  you have to set the Bluetooth baud rate to the baud rate of the Bluetooth module to have proper communication between the board and the module. To set the baud rate you have to use set bluetooth baud rate to () block.

set bluetooth baud rate to

Examples

Click here to view Arduino IDE Example for Camera Module – Camera & Video

In this example, you will capture images and record video with different camera settings.

Follow these steps:

  • Copy code as per your board in Arduino IDE
  • Upload code
  • Connect with Dabble and open Camera and Video module

evive

Following activities occur while pressing slide switch and tactile switches on evive:

  1. On pressing Tactile Switch 1 –  a High-quality image is captured from the front camera.
  2. On pressing Tactile Switch 2 – a Low-quality image is captured in auto flash mode from the rear camera.
  3. On sliding up Slide Switch 1 –  a High-quality video recording starts from the rear camera with 50% zoom. 

Mega, Uno, and Nano

After uploading code open serial monitor. you will be able to see instructions printed on Serial Monitor asking you to enter any number between 1 to 4. For each number, there is a task mentioned that will be executed.

ESP32

After uploading code open serial monitor and reset your board once. You will be able to see instructions on serial monitor follow them to capture images and videos from Camera Module.

Click here to view PictoBlox (Scratch) Example for Camera Module – Camera & Video

There are two scripts given below, out of which one is for capturing the image and one is for recording a 30-second video. Both the scripts are made for Stage Mode in PictoBlox. Both the scripts will work for evive and Arduino Uno, Nano, and Mega. Currently PictoBlox does not support ESP32; however, its support will be added soon. 

Capture Images

Record Videos

evive Notes Icon
Note: When working with evive or any of your Arduino board on PictoBlox for the very first time, or if you’ve previously uploaded another code to your board , you must upload the firmware in order to work in stage mode. You can find the procedure for the same here.

 

Projects

All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart