4 Configuring System
This chapter introduces how to configure system.
4.1 Compile Camera Demo
How to compile the startup test Camera example.
- Go to the folder where the test file is located.
cd /usr/share/ed-aic-lib/examples
- Compile the test code
sudo make test_camera.cpp
orpython 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
Function | Definition | Parameter Value |
---|---|---|
virtual int callback_image_ready(img_Callback callback)=0 | Get image data | - |
virtual int open(int mode, int width, int height) = 0 | Open and configure the camera | The working mode value includes 0, 1, 5
|
virtual int close() = 0 | Close camera | - |
virtual int set_exposure(int exp_value) = 0 | Setting the exposure time |
|
virtual int get_exposure(int *exp_value) = 0 | Get exposure time | - |
virtual int set_gain(int gain_value) = 0 | Setting the Gain |
|
virtual int get_gain(int *gain_value) = 0 | Get 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:
Function | Definition |
---|---|
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:
Function | Definition |
---|---|
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
- initialization
- Before operating IO, you need to obtain an IO instance
eda::EdaIo *em = eda::EdaIo::getInstance();
- Initialize the instance
em->setup();
- 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);
- Control IO (must be initialized first)
- Controlling lasers
em->openLaser()
andem->closeLaser();
- Control status indicator
em->setScanStat(true)
andem->setScanStat(false);
- Control alarm indicator light
em->openAlarm()
andem->openAlarm();
- Control two outputs
em->setDo1High(false)
andem->setDo2High(false);
- 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
- Enable light source (enabled by default)