EDA ED-AIC2000 Series User manual

ED-AIC2000 Series
Industrial Smart Camera Based on
Raspberry Pi CM4
SDK Development Guide
EDA Technology Co., LTD
December 2023

Contact Us
Thank you very much for purchasing and using our products, and we will serve
you wholeheartedly.
As one of the global design partners of Raspberry Pi, we are committed to
providing hardware solutions for IOT, industrial control, automation, green
energy and artificial intelligence based on Raspberry Pi technology platform.
You can contact us in the following ways:
EDA Technology Co.,LTD
Address:Room 301, Building 24, No.1661 Jialuo Road, Jiading District,
Shanghai
Mail: sales@edatec.cn
Phone: +86-18217351262
Website: https://www.edatec.cn
Technical Support:
Mail: [email protected]n
Phone: +86-18627838895
Wechat: zzw_1998-

Copyright Statement
ED-AIC2000 series and its related intellectual property rights are owned by
EDA Technology Co.,LTD.
EDA Technology Co.,LTD owns the copyright of this document and reserves
all rights. Without the written permission of EDA Technology Co.,LTD, no part
of this document may be modified, distributed or copied in any way or form.

Disclaimer
EDA Technology Co.,LTD does not guarantee that the information in this
manual is up to date, correct, complete or of high quality. EDA Technology
Co.,LTD also does not guarantee the further use of this information. If the
material or non-material related losses are caused by using or not using the
information in this manual, or by using incorrect or incomplete information, as
long as it is not proved that it is the intention or negligence of EDA Technology
Co.,LTD, the liability claim for EDA Technology Co.,LTD can be exempted.
EDA Technology Co.,LTD expressly reserves the right to modify or supplement
the contents or part of this manual without special notice.

i
Foreword
Reader Scope
This manual is applicable to the following readers:
Software Engineer
System Engineer
Related Agreement
Terminology Convention
Terminology
Meaning
CM4
Raspberry Pi Compute Module 4
Symbolic Convention
Symbolic
Instruction
Prompt symbols, indicating important features or operations.
Notice symbols, which may cause personal injury, system damage, or signal interruption/loss.
May cause great harm to people.

ii
Safety Instructions
This product should be used in an environment that meets the
requirements of design specifications, otherwise it may cause failure, and
functional abnormality or component damage caused by non-compliance
with relevant regulations are not within the product quality assurance
scope.
Our company will not bear any legal responsibility for personal safety
accidents and property losses caused by illegal operation of products.
Please do not modify the equipment without permission, which may cause
equipment failure.
When installing equipment, it is necessary to fix the equipment to prevent it
from falling.
If the equipment is equipped with an antenna, please keep a distance of at
least 20cm from the equipment during use.
Do not use liquid cleaning equipment, and keep away from liquids and
flammable materials.
This product is only supported for indoor use.

目录
Foreword .....................................................................................................................................................i
Reader Scope ......................................................................................................................................i
Related Agreement ..............................................................................................................................i
Terminology Convention................................................................................................................i
Symbolic Convention ....................................................................................................................i
Safety Instructions...................................................................................................................................... ii
1SDK Overview................................................................................................................................. 1-1
1.1 SDK Introduction............................................................................................................... 1-2
1.2 SDK Composition.............................................................................................................. 1-3
2Function Description ....................................................................................................................... 2-1
2.1 IO Control ......................................................................................................................... 2-2
2.1.1 Flow Diagram............................................................................................................. 2-2
2.1.2 Getting Instance and Initializing ................................................................................. 2-2
2.1.3 Event Callback Function ............................................................................................ 2-2
2.1.4 Controlling IO............................................................................................................. 2-3
2.1.5 Controlling light .......................................................................................................... 2-4
2.1.6 Source File................................................................................................................. 2-5
2.2 Sensor Control .................................................................................................................. 2-9
2.2.1 Flow Diagram............................................................................................................. 2-9
2.2.2 Operating Steps......................................................................................................... 2-9
2.2.3 Source File................................................................................................................2-11
3Example .......................................................................................................................................... 3-1
3.1 Writing Code ..................................................................................................................... 3-2
3.2 Compiling and Running Code ........................................................................................... 3-3

1 SDK Overview
ED-AIC2000 Series SDK Development Guide 1-2
1.1 SDK Introduction
The SDK of the ED-AIC2000 series Camera is a set of software development kit, which provides
users with the interfaces required for upper-layer applications to facilitate secondary development of
the camera.
The SDK functions of the ED-AIC2000 series Camera include registering Trigger/Tune button, DI
definition, laser control, status indicator control, alarm indicator control, 2-channel DO control, Light
and light source control, camera working mode setting, camera exposure time setting, camera gain
setting and image data processing.
The location of SDK in the camera system is shown in the figure below.
WiringPi V4L2 libcamera
OV2311 AR0234 HQ GS
Buttons Laser Light Source
Indicators RGB Light12-Pin M12
IO
Working Mode
Exposure Time
Gain
Image Processing
Camera Sensor
GPIO MCU
Raspberry Pi CM4
Hardware
Drive
SDK
Application

1 SDK Overview
ED-AIC2000 Series SDK Development Guide 1-3
1.2 SDK Composition
The SDK of camera is composed of multiple header files and library files. The details file names and
installation paths are as follows.
Function
File Type
File Names
Installation Paths
IO Control
Head File
eda-io.h
/usr/include/eda/
Library
libeda_io.so
/usr/lib/
Camera Sensor Control Head File
camera.h
/usr/include/eda/
CameraManger.h
camera_0234.h
camera_2311.h
Library
libeda_camera.so
/usr/lib/
During the development process, users can complete the development of upper-layer applications
based on actual needs and refer to the corresponding function description below.

2 Function Description
ED-AIC2000 Series SDK Development Guide 2-2
2.1 IO Control
This section introduces the operations of indicator control, laser control, event callback, and output
control.
2.1.1 Flow Diagram
Get Instance
Set Up for Initialization
Event Callback Function IO Control Light Control
Set RGB of Side Lights Light Enable/DisableLaser On/Off Set Status Indicator Set Alarm Indicator Set 2 Output Signals
Register Input Register Trigger Button Register Tune Button
2.1.2 Getting Instance and Initializing
Before operating IO, you need to obtain an IO instance and initialize the instance. The steps are as
follows.
1. Getting an IO instance.
eda::EdaIo *em = eda::EdaIo::getInstance();
2. Initializing the instance.
em->setup();
2.1.3 Event Callback Function
IO control supports registering callback functions for events, including registering Input, registering
Trigger button, and registering Tune button.
DI1 trigger event

2 Function Description
ED-AIC2000 Series SDK Development Guide 2-3
em->registerInput(trigger_input);
The COMMON_IN pin in the 12-Pin M12 interface is connected to ground signal, and the DI1
pin is connected to 5V signal for triggering.
Registering Trigger button
em->registerTrigger(trigger_trigger);
Registering Tune button
em->registerTune(trigger_tune);
Sample
#include "eda/eda-io.h"
void trigger_input(int b){
printf("[Test] Tirgger input: %d\n", b);
}
int main(int argc, char *argv[]){
eda::EdaIo *em = eda::EdaIo::getInstance();
em->registerInput(trigger_input);
em->setup();
....
}
2.1.4 Controlling IO
Using IO to control the on/off of the laser, the on/off of the status indicator, the on/off of the alarm
indicator and the enable/disable of the 2 outputs.
Preparation
Initialization of the instance has been completed.
Operating Instructions
Laser On/Off
em->openLaser();
em->closeLaser();

2 Function Description
ED-AIC2000 Series SDK Development Guide 2-4
Status indicator On/Off
em->setScanStat(true)
em->setScanStat(false)
Alarm indicator On/Off
em->openAlarm()
em->openAlarm()
2 outputs enable/disable
em->setDo1High(false);
em->setDo2High(false);
2.1.5 Controlling light
Both the camera side lights and area lights can be controlled independently.
Preparation
Initialization of the instance has been completed.
Operating Instructions
Side light color
em->setRgbLight(1);
0: Closing side light
1: Setting the color to Red
2: Setting the color to Green
3: Setting the color to Blue
RGB color of side light
void setRgbLight_rgb(uint8_t r, uint8_t g, uint8_t b);
Area lights

2 Function Description
ED-AIC2000 Series SDK Development Guide 2-5
Enable (The default state)
em->enableLightSection(1);
The value range is 1~4, corresponding to different partitions.
Disable
em->disableLightSection(1);
The value range is 1~4, corresponding to different partitions.
Enabling/disabling the area light does not turn on/off the light. The area light and the camera
are linked. The area light will only turn on when the area light is enabled and the camera is
turned on.
2.1.6 Source File
IO Control Class (C++)
typedef void (*IoTrigger)(int level);
class EdaIo{
public:
static EdaIo* getInstance();
static void close_io();
~EdaIo();
/**
* @brief Laser On
*
*/
void openLaser();
/**
* @brief Laser Off
*
*/
void closeLaser();
/**
* @brief set status indicator
*
* @param good
*/
void setScanStat(bool good);

2 Function Description
ED-AIC2000 Series SDK Development Guide 2-6
/**
* @brief alarm indicator On
*
*/
void openAlarm();
/**
* @brief alarm indicator Off
*
*/
void closeAlarm();
/**
* @brief
*
* @param section 1~4
* @return int
*/
int enableLightSection(int section);
/**
* @brief
*
* @param section 1~4
* @return int
*/
int disableLightSection(int section);
/**
* @brief set output1 to [high/low]
*
* @param high
*/
void setDo1High(bool high);
/**
* @brief set output2 to [high/low]
*
* @param high
*/
void setDo2High(bool high);
// void setAimerColor(RGBColor color);
/**
* @brief register input trigger callback function
*
* @param callback
*/

2 Function Description
ED-AIC2000 Series SDK Development Guide 2-7
void registerInput(IoTrigger callback);
/**
* @brief register button callback function
*
* @param callback
*/
void registerTrigger(IoTrigger callback);
/**
* @brief register Tune button callback function
*
* @param callback
*/
void registerTune(IoTrigger callback);
/**
* @brief set RGB light
*
* @param light 0: Close; 1: Red; 2: Green; 3: Blue,
* @return int
*/
void setRgbLight(uint8_t light);
/**
* @brief Set the RGB Light
*
* @param r red
* @param g green
* @param b blue
*/
void setRgbLight_rgb(uint8_t r, uint8_t g, uint8_t b);
/**
* @brief initializing IO settings
*
*/
void setup();
};

2 Function Description
ED-AIC2000 Series SDK Development Guide 2-8
IO Control (Python3)
from libedaio import EdaIo,registerInput,registerTrigger,registerTune
def func_trigger(v):
print("[Debug] Trigger: trigger button!", v)
...
eda = EdaIo.singleton(); # Get IO control instance
registerTrigger(func_trigger); # Register Trigger button callback
# registerInput(func_trigger); # Register Input callback
# registerTune(func_trigger); # Register Tune button callback
eda.setup(); # Initialization
...
eda.openLaser(); # Laser On
# eda.closeLaser(); # Laser Off
eda.setScanStat(True); # Set status indicator
eda.openAlarm(); # Alarm indicator on
# eda.closeAlarm(); # Alarm indicator off
eda.setDo1High(True); # Set output1
eda.setDo2High(False); # Set output2
eda.setRgbLight(1); # Set side light,0: Off; 1: Red; 2: Green; 3: Blue

2 Function Description
ED-AIC2000 Series SDK Development Guide 2-9
2.2 Sensor Control
This section introduces the operations of opening/closing camera, setting the camera working mode,
setting the camera exposure time and setting the camera gain, etc.
2.2.1 Flow Diagram
Open Camera
Set Working Mode Set Exposure Set Gain Register Image Callback Function
Thread Processing Image Data
2.2.2 Operating Steps
1. Getting an instance
eda::Camera *t_camera = eda::load_default();
2. Checking sensor type
t_camera->name()
eda::CameraName::AR0234
eda::CameraName::OV2311
AR0234 is the 2.3-megapixel camera.
OV2311 is the 2-megapixel camera.
3. Open the camera and set working mode, camera area width and camera area height.
t_camera->open(mod, width, height);
mod is the working mode, the value includes 0, 1 and 5.

2 Function Description
ED-AIC2000 Series SDK Development Guide 2-10
0 means continuous mode (the camera keeps opening), both AR0234 and OV2311
support this mode.
1 means hardware trigger mode, connecting 5V signal to trigger through trigger pin.
Both AR0234 and OV2311 support this mode.
5 means software trigger mode, triggering through manual adjustment. Only OV2311
supports this mode.
int call_trigger();
width is area width of camera.
height is area height of camera.
4. Setting gain
t_camera->set_gain(gain);
OV2311:The value range of gain is 0~30.
AR0234: The value range of gain is 0~64.
5. Setting exposure time
t_camera->set_exposure(exposure);
OV2311: The value range of exposure is 0~65523, which unit is microsecond.
AR0234:The value range of exposure is 1~1500, which unit of 6.8 times the value is
microsecond.
6. Obtaining camera data through callback.
t_camera->callback_image_ready(image_callback);
In the callback function, it is recommended to only obtain data and not process logic.
7. Close camera
eda::EdaIo::close_io();
Table of contents
Other EDA Digital Camera manuals