4 Configuring System

This chapter introduces how to configure system.

4.1 Compile Camera Demo

How to compile the startup test Camera example.

  1. Go to the folder where the test file is located.

cd /usr/share/ed-aic-lib/examples

  1. Compile the test code

sudo make test_camera.cpppython test_camera.py

sudo ./test_camera

4.2 Camera Interface

  • The "camera.h" file provides the control interface for operating the AI Camera Sensor. The file is stored in "/usr/include/eda/camera.h".

  • The "eda-io.h" file provides the control interface for operating the AI Camera IO. The storage path of this file is "/usr/include/eda/eda-io.h".

4.3 Library Files

  • The storage path of the "libeda_camera.so" library file is "/usr/lib/libeda_camera.so".

  • The storage path of the "libeda_io.so" library file is "/usr/lib/libeda_io.so".

4.4 Camera API

The Camera API provides control functions for the AI Camera Sensor, which support turning the sensor on and off, setting the sensor operating mode, setting the exposure time, and setting the gain. The following describes each function according to different Camera scenarios.

Control Function

The control functions of the AI Camera Sensor provided by the Camera API are shown in the following table, including obtaining image data, opening the camera, closing the camera, setting the working mode, setting the exposure time, and setting the gain.

  • AR0234 means 2.3 million pixel camera
  • OV2311 means 2 million pixel Camera
FunctionDefinitionParameter Value
virtual int callback_image_ready(img_Callback callback)=0Get image data-
virtual int open(int mode, int width, int height) = 0Open and configure the cameraThe working mode value includes 0, 1, 5
  • 0 means continuous mode (the camera is always on), which is supported by both AR0234 and OV2311.
  • 1 indicates hardware trigger mode, which is supported by AR0234 and OV2311, and is triggered by 5V via the Trigger pin.
  • 5 indicates software trigger mode, which is only supported by OV2311 and is triggered by manual adjustment.
virtual int close() = 0Close camera-
virtual int set_exposure(int exp_value) = 0Setting the exposure time
  • OV2311: t_exposure value range is 0~65523, unit is us
  • AR0234: t_exposure ranges from 1 to 1500. The value of exposure multiplied by 6.8 is expressed in us.
virtual int get_exposure(int *exp_value) = 0Get exposure time-
virtual int set_gain(int gain_value) = 0Setting the Gain
  • OV2311: t_gain value range is 0~30
  • AR0234: t_gain value range is 0~64
virtual int get_gain(int *gain_value) = 0Get Gain-

Get AR0234 instance

#include "CameraManger.h"
#include "camera_0234.h"

void test()
  eda::Camera *t_camera = eda::create_ar0234();
  if(t_camera){
  eda::Camera_0234 *t_camera_1 = static_cast<eda::Camera_0234*>(t_camera);
  }
  ...
}

4.5 IO API

The IO API provides control functions for the AI Camera IO, supporting control of indicator lights, lasers, side lights, and outputs.

4.5.1 C language environment

The control function of AI Camera IO in C language environment is as follows:

FunctionDefinition
eda::EdaIo *em = eda::EdaIo::getInstance()Get IO control instance
void setup()Initialize IO settings
void openLaser()Turn on the laser
void closeLaser()Turn off the laser
void setScanStat(bool good)Set status indicator
void openAlarm()Turn on the warning light
void closeAlarm()Turn off the warning light
void setDo1High(bool high)Set output1 output
void setDo2High(bool high)Set output2 output
void registerInput(IoTrigger callback)Register input trigger callback function
void registerTrigger(IoTrigger callback)Register trigger button callback function
void registerTune(IoTrigger callback)Register Tune button callback function
void setRgbLight(uint8_t light)Set up RGB lighting

4.5.2 Python3 language environment

The control function of AI Camera IO in Python3 language environment is as follows:

FunctionDefinition
eda = EdaIo.singleton()Get IO control instance
eda.setup()initialization
eda.openLaser()Turn on the laser
eda.closeLaser()Turn off the laser
eda.setScanStat(True)Set status indicator
eda.openAlarm()Turn on the warning light
eda.closeAlarm()Turn off the warning light
eda.setDo1High(True)Set output1 output
eda.setDo2High(False)Set output2 output
registerInput(func_trigger)Register input trigger callback function
registerTrigger(func_trigger)>Register trigger button callback function
registerTune(func_trigger)Register Tune button callback function
eda.setRgbLight(1)Set up RGB lighting

4.5.3 Operating Instructions

  1. initialization
  • Before operating IO, you need to obtain an IO instance eda::EdaIo *em = eda::EdaIo::getInstance();
  • Initialize the instance em->setup();
  1. IO control supports event registration callback functions
  • input event em->registerInput(trigger_input);
  • Trigger button em->registerTrigger(trigger_trigger);
  • Tune button em->registerTune(trigger_tune);
  1. Control IO (must be initialized first)
  • Controlling lasers em->openLaser() and em->closeLaser();
  • Control status indicator em->setScanStat(true) and em->setScanStat(false);
  • Control alarm indicator light em->openAlarm() and em->openAlarm();
  • Control two outputs em->setDo1High(false) and em->setDo2High(false);
  1. Control lights (must be initialized first)
  • Control side light color em->setRgbLight(1);
    • 0: Close
    • 1: Red
    • 2: Green
    • 3: Blue
  • Control light source
    • Enable light source (enabled by default) em->enableLightSection(1) The value range is 1~4, corresponding to different partitions
    • Disable light source em->disableLightSection(1), the value range is 1~4, corresponding to different partitions