4 Configuring System
This chapter introduces how to configure system.
4.1 Compile Camera Demo
How to compile and startup Camera test example.
- Go to the folder where the test file is located.
cd /usr/share/ed-aic-lib/examples
- Compile the test code
- Python
sudo python test_camera.py
- c++
sudo mkdir test
cd test
sudo cmake .. -DENABLE_HQ=ON
sudo make
sudo ./test_io
4.2 Camera I/O Control
The
eda-io.h
file provides the program that operates the control interface (C++) of the AI Camera IO, which is stored at/usr/include/eda/eda-io.h
.The
libedaio.so
file provides the program to operate the control interface (Python) of the AI Camera IO, which is located at/usr/lib/python3/dist-packages/libedaio.so
.
4.3 Camera Sensor Control
The ED-AIC2000 uses the open source picamera2
library to control the camera, picamera2
provides a range of API.
4.4 Camera API Example
The control functions for the AI Camera Sensor are provided by the picamera2
library and support turning the sensor on and off, capturing images, etc. Here are some sample descriptions.
Function | Definition |
---|---|
picam2 = Picamera2() | Get Camera Control Instance |
preview_config = picam2.create_preview_configuration() | Create a preview configuration |
picam2.configure(preview_config) | Apply the preview configuration to the camera |
picam2.start_preview(Preview.NULL) | Start the camera preview function, NULL means do not show the picture on the screen |
picam2.start() | Start the camera hardware and software flow pipeline |
picam2.capture_file("test.jpg") | Capture an image and save it as test.jpg |
picam2.close() | Close the camera hardware and software streaming pipeline |
For more details and to check picamera2
official information Picamera2 Manual
4.5 I/O API
The I/O API provides control functions for the AI Camera I/O, supporting control of indicators, control of lasers, control of RGB lights, and control of outputs.
4.5.1 C++ environment
The control function of AI Camera I/O in C++ 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 I/O in Python3 language environment is shown below:
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.open_light() | Open light |
eda.close_light() | Close light |
eda.eda.enableLightSection() | Enable light(evaluatable:1,2,3,4) |
eda.eda.disableLightSection() | Disable light(evaluatable:1,2,3,4) |
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 I/O, you need to obtain an I/O instance
eda::EdaIo *em = eda::EdaIo::getInstance();
- Initialize the instance
em->setup();
- I/O 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 I/O (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)
4.5.3.2 Python
- Initialization
- Get I/O instance before manipulating IO
eda = EdaIo.singleton()
- Initialize the instance
eda.setup()
.
- I/O control supports registering callback functions for events.
- input input event
registerInput(func_input)
- Trigger keystroke
registerTrigger(func_trigger)
- Tune button
registerTune(func_tune)
.
- Control I/O (must be initialized first)
- Control of laser
eda.openLaser()
andeda.closeLaser()
- Controlling status indicators
eda.setScanStat(true)
andeda.setScanStat(false)
- Controls the alarm indicator
eda.openAlarm()
andeda.openAlarm();
- Control of two outputs
eda.setDo1High(false)
andeda.etDo2High(false);
- Control the lights (initialization must be done first)
Control the sidelight color
eda.setRgbLight(1);
- 0: OFF
- 1: Red
- 2: Green
- 3: Blue
Controlling the light source
- Enable light source (default is enabled)
eda.enableLightSection(1)
Value range 1~4, corresponding to different partitions. - Disable light source
eda.disableLightSection(1)
Range 1~4, corresponding to different partitions.
- Enable light source (default is enabled)