OSAI SDK Programming Manual V5.2.0
1.Revision history
Date
Version number
Revision description
Revised by
2024.07.15
V5.0.0
Windows/Linux/Android multi-platform unified management, sharing the underlying SDK.
Optimize SDK code to improve efficiency, user experience and solve existing problems.
OSAI
2024.09.15
V5.1.0
Add weighing protocol, detect whether the status can be recognized, detect the device list and other interfaces or functions in the LAN.
Scrap the interface that requests the trial period.
Fix the problem that Windows export/import data is not compatible with Chinese paths, and initialization fails when the initial interface is invoked during initialization.
OSAI
2024.11.05
V5.1.7
Export/Import AI data Add the sku_id parameter to export/import the learning data of a single product.
OSAI
2024.12.20
V5.2.0
Fix known bugs.
Add the interface for setting the identification range.
Optimize the algorithm for more accurate recognition.
OSAI
2.SDK download and usage process description
2.1 OSAI SDK Download
Please contact your account manager for download links for the OSAI SDK.
2.2 OSAI Different Platform Introduction
Supportable platform
System version requirements
Deployment process
Windows
Windows 7 and above
Enter program directory
Double click to run OSAIService.exe program
Linux
Ubuntu 18.04 and above
Enter program directory
Run "./OSAIService.run" command starts the script
Android
Android 7.1 and above
Follow the Latest SDK gets dependency links and code to add document in the SDK package
2.3 OSAI SDK Usage process
AI visual recognition technology has been widely used in industries such as fresh snacks. To meet this demand, we developed a powerful AI SDK and provided a complete HTTP service program. Our SDK has the ability to learn products and efficiently identify products that have been learned. To facilitate developer integration, we provide two standard interface docking methods, and a small number of unique interfaces may be provided according to specific platform characteristics:
HTTP interface: Through HTTP interface, you can easily interact with our AI visual recognition service to realize the learning and recognition functions of goods. This approach has the advantage of being easy to implement and cross-platform.
SDK DLL interface: For users who want to integrate into their own programs, you can directly interface with our SDK DLL interface. This provides more customization options and flexibility.
2.3.1 Flow chart of AI recognition by application software
First, if you want to use the SDK's AI features, you need to activate your device first. You can call the details interface (osai/sys/details) to obtain the activation status of the device. For devices that are not activated, you need to call the activation interface to activate them.
Second, when building an AI system, you only need to follow two main steps: recognition and learning. Specific to the application of business scenarios, such as in the fresh food industry, this process can be implemented in the following ways:
Recognition phase: automatic triggering of recognition mechanism by monitoring weight changes of electronic scales. This can be achieved by setting a weight threshold, and when the item is placed on the scale and reaches or exceeds this threshold, the system will automatically initiate the recognition process.
Learning phase: After identifying the item, the system waits for final confirmation from the user. Users can confirm the recognition result by clicking on the correct item on the interface. Once the user clicks OK, the system will record the recognition result as learning data, thus completing the learning process.
In this way, AI systems can continuously learn and optimize in actual business processes, thereby improving the accuracy and efficiency of recognition.
The specific flow chart is shown in the following figure:

2.3.2 Set the coordinate range for identifying the scale area image
In order to improve the recognition accuracy of the AI system, we recommend setting the coordinate range of the scale area in the image accurately. The purpose of this setup is to minimize the interference of external factors and ensure that the AI can focus more on identifying objects on the scale.
To do this, you should define a rectangular area that is large enough to just cover the scale and exclude other unnecessary background and objects.
As shown in the figure, the area marked by the green box is the recommended coordinate range. By accurately setting this area, the recognition efficiency and accuracy of AI in practical applications can be significantly improved.

3. HTTP Interface description
Note: The following HTTP interface request address is: 127.0.0.1:47000. WebSocket interface request address is: 127.0.0.1:47001. For OSAIService service program, set the device type through the environment variable USE_DEVICE=CPU/NPU/GPU. If not set, it will search for available NPU/GPU by default.
3.1 GET: sys/version (Get version number)
Interface name
/osai/sys/version
Function description
Get version number information.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
version
Version information
sdk_version
AI SDK version number
model_version
AI model version number
Example of returned result is as
{
"code": 1,
"msg": "GetVersion success! ",
"version": {
"sdk_version": "5.0.0",
"model_version": "231221"
}
}
3.2 GET: sys/init (initialize)
Interface name
/osai/sys/init
Function description
Initialize the service, which is called automatically when the service program is started.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "Init success! "
}
3.3 GET: sys/exit (Exit procedure)
Interface name
/osai/sys/exit
Function description
Exit the service process. It is recommended to exit the program through this interface to avoid abnormal problems such as data loss.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "Exit success! "
}
3.4 GET: sys/details (Get details)
Interface name
/osai/sys/details
Function description
Get detailed information: device number, activation code, device expiration time, store information, etc.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code,
0: Unknown error,
1: Activated. Please note that the activated device will return this status code even when the network is disconnected.
1001: Not initialized,
1008: Initializing,
2002: Device not activated,
2005: expired,
2007: Probationary period,
2008: The trial periodhas endedand
6001: Abnormal communication with server, possibly due to network disconnection or connection timeout. Note that inactive or expired devices will also return this status code in case of network disconnection
msg
State description
deviceinfo
Equipment information
cdkey
Activation code
device_id
Device number
deadline
Expiration time of equipment. If blank, it means permanent use
storename
Store Name
storecontact
Linkman, contacts
storemobile
Phone
Example of returned result is as
{
"code": 1,
"msg": "GetDetails success! ",
"deviceinfo": {
"cdkey": "04HW51ULV9MEDPRMBVJXXX",
"device_id": "13829662055196697XXX",
"deadline": "2029-09-21",
"storename": "XXX",
"storecontact": "XXX",
"storemobile": "XXX"
}
}
3.5 GET: sys/setshopinfo (Set store information)
Interface name
/osai/sys/setshopinfo
Function description
Set store information, you can set store name, contact person, contact phone number.
Request parameters
Parameter name
Parameter specification
name
Store Name
contact
Linkman, contacts
mobile
Phone
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "SetShopInfo success! "
}
3.6 GET: sys/upgradeinfo (Obtain program upgrade information)
Interface name
/osai/sys/upgradeinfo
Function description
Get program upgrade information, latest version number, download link, etc.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
ver
Latest version number
url
Download link
mode
Upgrade mode, 1: forced upgrade, 2: automatic upgrade, 3: pop-up prompt upgrade, corresponding upgrade strategy can be defined according to mode
Example of returned result is as
{
"code": 1,
"msg": "UpgradeInfo success! ",
"ver": "a.b.c",
"url": "http: //dl.tx.cdn.osai.cc/update/xxx_update_a.b.c_only.zip",
"mode": "3"
}
3.7 GET: sys/upgrade (Upgrade service program)
Interface name
/osai/sys/upgrade
Function description
Upgrade service procedures. You can obtain the upgrade url by calling UpgradeInfo.
Request parameters
Parameter name
Parameter specification
url
Upgrade package download address
Response parameter
Parameter name
Parameter specification
Request example
Example of returned result is as
N/A
3.8 GET: sys/modelinfo (Get model upgrade information)
Interface name
/osai/sys/modelinfo
Function description
Obtain model upgrade information to check whether there is an upgradable model. If the device is online, obtain cloud model upgrade information; if it is not the latest model, pull the latest model from the cloud and update it; If the device is offline, check whether the upgradeable model exists on the local device and update it. Note that the model file is the retrieval_latest.ai file in the sdk directory.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
result
Check result: -2: abnormal,-1: AI not initialized, 0: upgrade [Non-required], 1: upgrade requirements met
Example of returned result is as
{
"code": 1,
"msg": "New model ready for upgrade. ",
"result": 1
}
3.9 GET: sys/upgrademodel (Upgrade model)
Interface name
/osai/sys/upgrademodel
Function description
Upgrade the algorithm model. Please note that AI model upgrade automatically to learn, can't use the AI recognition function, can use /osai/ai/gallery/batchlearn interface to get progress (0-100).
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful, 1007: Relearning
msg
State description
result
Upgrade result,-1: exception, 0: upgrade failed, 1: upgrade started
estimate
Estimated time remaining
Example of returned result is as
{
"code": 1,
"msg": "Model start upgrade. ",
"result": 1,
"estimate": "1m 51s"
}
3.10 GET: sys/thmbyname (Get thumbnail)
Interface name
/osai/sys/thmbyname
Function description
Get thumbnail images of online products. You can get relevant thumbnail images by passing in the product name.
Request parameters
Parameter name
Parameter specification
name
Product Image Name
lang
[Optional] Language, zh: Simplified Chinese name, en: English name, tw: Traditional Chinese name, default is zh
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "ThmbyName success!",
"data": [
"OSAIIcon/apple.jpg"
]
}
3.11 POST: sys/thmbymultiname (Get thumbnails in bulk)
Interface name
/osai/sys/thmbymultiname
Function description
Get thumbnails of online products. You can get thumbnails by passing inmultiple product names.
Request parameters
Parameter name
Parameter specification
name
Product image name, multiple products with "|" Divided
lang
[Optional] Language, zh: Simplified Chinese name, en: English name, tw: Traditional Chinese name, default is zh
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Request example
http://127.0.0.1:47000/osai/sys/thmbymultiname?lang=en
Content-Type: application/json should be configured in the request header
{
"name": ["apple|banana|pear|pineapple"]
}
Example of returned result is as
{
"code": 1,
"msg": "ThmbyMultiName success!",
"data": {
"apple": [
"OSAIIcon/apple.jpg"
],
"banana": [
"OSAIIcon/banana.jpg"
],
"pear": [
"OSAIIcon/pear.jpg"
],
"pineapple": [
"OSAIIcon/pineapple.jpg"
]
}
}
3.12 GET: sys/onlinedevices (Find an online device)
Interface name
/osai/sys/onlinedevices
Function description
Detects the IP addresses of online devices on the LAN.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
devices
IP address that can communicate on a LAN
Example of returned result is as
{
"code": 1,
"msg": "OnlineDevices success!",
"devices": [
"192.168.31.219",
"192.168.31.23",
"192.168.31.100",
"192.168.31.208"
]
}
3.13 GET: sys/codestatus (Obtain the activation code status)
Interface name
/osai/sys/codestatus
Function description
Check whether the activation code is used.
Request parameters
Parameter name
Parameter specification
actcode
Activation code
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
code_isused
Whether the passed activation code is used, 0: not used, 1: used
Example of returned result is as
{
"code": 1,
"msg": "CodeStatus success!",
"code_isused": 1
}
3.14 GET: auth/setvid (Set the customer exclusive ID)
Interface name
/osai/auth/setvid
Function description
Set a customer-specific ID that imposes activation code usage restrictions on configured devices, i.e. only activation codes belonging to that VID can be used to activate the device. For specific ID values, please contact OSAI's Commercial Team. Note that you need to invoke this interface before activating a product or requesting a trial period.
Request parameters
Parameter name
Parameter specification
vid
Customer-specific ID
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "SetVID success! "
}
3.15 GET: auth/activate (Activating device)
Interface name
/osai/auth/activate
Function description
Activate the current device. Please note that inactive devices will affect the use of AI functions.
Request parameters
Parameter name
Parameter specification
code
Activation code
name
Store Name
contact
Linkman, contacts
phone
Phone
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Request example
Example of returned result is as
{
"code": 1,
"msg": "Activate success! ",
}
3.16 GET: auth/qrcode (Get activation QR code)
Interface name
/osai/auth/qrcode
Function description
Get the QR code picture for dealer/ordinary user code scanning activation.
Request parameters
Parameter name
Parameter specification
type
Gets the type parameter, which can be set to agent or user. When set to agent, it refers to dealers; when set to user, it refers to ordinary users
Response parameter
Parameter name
Parameter specification
Request example
Example of returned result is as

3.17 GET: auth/unbind (Unbind the current device)
Interface name
/osai/auth/unbind
Function description
Unbinding the current device means revoking its activation state. Note that once a device is untied, the availability of its AI functionality will be affected.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "Unbind success! "
}
3.18 GET: cam/list (Get camera list)
Interface name
/osai/cam/list
Function description
Get a list of cameras for this device and the cameras in use.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
selected
Camera information currently in use
id
Camera ID
name
Name of camera.
symlink
Camera path
camlist
Camera list information
Example of returned result is as
{
"code": 1,
"msg": "CameraList success!",
"selected": {
"id": 0,
"name": "USB Camera_0",
"symlink": "\\\\?\\usb#vid_0bda&pid_2571&mi_00#7&3d14434&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global"
},
"camlist": [
{
"id": 0,
"name": "USB Camera_0",
"symlink": "\\\\?\\usb#vid_0bda&pid_2571&mi_00#7&3d14434&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global"
}
],
"cameralist": [
{
"id": 0,
"name": "USB Camera_0",
"symlink": "\\\\?\\usb#vid_0bda&pid_2571&mi_00#7&3d14434&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global"
}
]
}
3.19 GET: cam/open (Turn on the camera)
Interface name
/osai/cam/open
Function description
Turn on the specified camera, please note that the program will try to turn on the first camera when it starts.
Request parameters
Parameter name
Parameter specification
id
[Optional] The camera id can be obtained from the /osai/cam/list interface, and the default is 0
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "OpenCamera success! "
}
3.20 GET: cam/setresolution (Set camera resolution)
Interface name
/osai/cam/setresolution
Function description
Set the camera resolution. Note that if the resolution exceeds the maximum resolution supported by the camera, the resolution is automatically set to the maximum resolution supported by the camera, and the interface has a saving function. The last resolution will be set at the next startup.
Request parameters
Parameter name
Parameter specification
width
Resolution width
height
Resolution height
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "SetCameraResolution success! "
}
3.21 GET: cam/capture (Get the current frame data of the video)
Interface name
/osai/cam/capture
Function description
Get a picture of the camera's current live frame.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
Example of returned result is as

3.22 GET: cam/livestream (Get video stream data)
Interface name
/osai/cam/livestream
Function description
Acquire the current real-time image frame of the camera and return it in the form of video stream. It is Not recommended that you call this interface during actual use, because it consumes a lot of system resources and affects recognition speed.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
Example of returned result is as

3.23 GET: cam/croparea (Get the AI recognizable region)
Interface name
/osai/cam/croparea
Function description
Get the parameters of the AI recognizable region. Please note whether the width and height of the rendered image returned is consistent with that of the rendered image on the UI interface. If not, corresponding conversion is required.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
x
Render image Select coordinate x in the upper left corner of the rectangular area
y
Render image Select the coordinate y in the upper left corner of the rectangular area
w
Render image selected rectangular area width
h
Render image with selected rectangular area height
topleft_x
Render image by selecting the top left coordinate x of the trapezoid area
topleft_y
To render the image, select coordinate y in the upper left corner of the trapezoid area
topright_x
Render image by selecting the top right corner coordinate x of the trapezoid area
topright_y
Render image by selecting the top right corner coordinate y of the trapezoid area
bottomleft_x
Render image by selecting the lower-left coordinate x of the trapezoid area
bottomleft_y
Render image by selecting the bottom left coordinate y of the trapezoid area
bottomright_x
Render image by selecting the lower right corner coordinate x of the trapezoid area
bottomright_y
Render image by selecting the lower-right coordinate y of the trapezoid area
img_w
The width of the rendered image
img_h
Render the height of the image
Example of returned result is as
{
"code": 1,
"msg": "CameraCropArea success!",
"x": 0,
"y": 0,
"w": 0,
"h": 0,
"topleft_x": 50,
"topleft_y": 50,
"topright_x": 150,
"topright_y": 50,
"bottomleft_x": 10,
"bottomleft_y": 300,
"bottomright_x": 190,
"bottomright_y": 300,
"img_w": 640,
"img_h": 480,
"cam_w": 640,
"cam_h": 480,
"area_w": 640,
"area_h": 480
}
3.24 GET: cam/setcroparea (Set the AI recognition area)
Interface name
/osai/cam/setcroparea
Function description
Set AI identification area parameters: This interface allows the user to define the recognition range of the AI system by specifying the location and size of the area, and the AI will only perform recognition tasks in the defined area. Please note that the rendered image is the image used to set the identification area on your company's application software, and the interface has its own saving function, and the identification area set last time will be set at the next startup.
We provide two setting methods: rectangular area and trapezoidal area, please choose the way suitable for you to enter the corresponding parameters, if you pass in the parameters of both ways, we will give priority to the trapezoidal area to set the identification area.
Request parameters
Parameter name
Parameter specification
x
Render image Select coordinate x in the upper left corner of the rectangular area
y
Render image Select the coordinate y in the upper left corner of the rectangular area
w
Render image selected rectangular area width
h
Render image with selected rectangular area height
topleft_x
Render image by selecting the top left coordinate x of the trapezoid area
topleft_y
To render the image, select coordinate y in the upper left corner of the trapezoid area
topright_x
Render image by selecting the top right corner coordinate x of the trapezoid area
topright_y
Render image by selecting the top right corner coordinate y of the trapezoid area
bottomleft_x
Render image by selecting the lower-left coordinate x of the trapezoid area
bottomleft_y
Render image by selecting the bottom left coordinate y of the trapezoid area
bottomright_x
Render image by selecting the lower right corner coordinate x of the trapezoid area
bottomright_y
Render image by selecting the lower-right coordinate y of the trapezoid area
img_w
The width of the rendered image
img_h
Render the height of the image
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Request example
Example of returned result is as
{
"code": 1,
"msg": "SetCameraCropArea success! "
}
3.25 GET: ai/visrecimg (Get recognition image)
Interface name
/osai/ai/visrecimg
Function description
Get the picture of this recognition. In the multi-target recognition scene, you can also highlight the commodity boxes of multiple targets on the picture by passing in the bbox parameter.
Request parameters
Parameter name
Parameter specification
bbox
[Optional] Whether to add bbox box, default is not added
skus
[Optional] The SKU number in the bbox will be automatically converted to the actual commodity name in the format of "11: apple;12: orange", which is blank by default.
Response parameter
Parameter name
Parameter specification
Example of returned result is as

3.26 GET: ai/recognition (AI recognition)
Interface name
/osai/ai/recognition
Function description
AI Product Recognition: The system will return the result of this recognition.
Request parameters
Parameter name
Parameter specification
top
[Optional] Maximum output quantity, default is 0
save_img
[Optional] Whether to save this recognition picture. Default is 0. If set to 1, the program will provide the name of the picture in the return field filename and save the picture in the OSAITemp folder of the program directory
skuid_range
[Non-required] List of identification ranges. If the identification range is set, the AI algorithm will search for the identification result within the range. Note that this parameter is valid only for this identification request.
timeout
[Optional] When the recognition timeout value is set, if the recognition process takes longer than this set value, the system will return a timeout error. If this value is set to 0, it means that no timeout determination is made. By default, a timeout value is preset
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
used_time
Time spent on this recognition, in milliseconds
filename
The name of this identification picture
result
Identification result record
index
Results of index
rank
Recognition result list
id
ID, the only parameter in fast learning mode
Request example
Example of returned result is as
{
"code": 1,
"msg": "AiRecognition success, extract feat time:15, capture frame time:5",
"sku_ids": ["11"],
"used_time": 31,
"filename": "osai_temp.png",
"result": [
{
"index": 0,
"rank": ["11" ]
}
]
}
{
"code": 1,
"msg": "SetLearnMode success!"
}
{
"code": 1,
"msg": "AiFastRecognition success!",
"id": 0}
3.27 GET: ai/autotriggerrec (The identification interface is automatically triggered)
Interface name
/osai/ai/autotriggerrec
Function description
When this interface is enabled, the identification interface is automatically triggered when IsReadyState detects that the interface is recognizable, and the identification result is pushed through the websocket service. The default value is 0.
Request parameters
Parameter name
Parameter specification
close
[Non-required] If this parameter is set to 1, automatic invocation of the identification interface is disabled. The default value is 0
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "AutoTriggerRec success!"
}
3.28 GET: ai/isreadystate (Gets whether the identification status is ready to trigger)
Interface name
/osai/ai/isreadystate
Function description
Obtain whether to trigger recognition status, the interface will determine whether to trigger recognition based on the weight.
Request parameters
Parameter name
Parameter specification
weight
Weight, in g
is_steady
If the current situation is stable, 1 indicates stable and 0 indicates unstable
rec_after_steady
If the value is set to 1, the system will recognize the weight only after the weight is steady. The default value is 0
start_from_zero
[Non-required] Recognition after zero. When it is set to 1, it means that the recognition can be triggered only when the weight has returned to zero. Otherwise, the recognition can be triggered when the difference between the stable weight after last learning and the current stable weight is 100g, and the default value is 0
max_check_time
[Non-required] Maximum detection duration (unit: ms). The default value is 120
min_rec_weight
[Non-required] Minimum identification weight, unit g, default 20
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
is_ready
true: identification can be triggered. false: identification cannot be triggered
Example of returned result is as
{
"code": 1,
"msg": "IsReadyState success!",
"is_ready": false
}
3.29 GET: ai/autorec (Turn on automatic recognition)
Interface name
/osai/ai/autorec
Function description
This interface will turn on automatic recognition, we will automatically detect the picture status, when something is placed on the pan, it will automatically trigger recognition, and the recognition result will be pushed through the websocket service.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": " AutoRec success!"
}
3.30 GET: ai/emptypandetection (Open the empty pan test)
Interface name
/osai/ai/emptypandetection
Function description
This interface will turn on the empty pan detection function, we will detect whether the current recognition result is empty pan, if it is empty pan, it will return the empty recognition result.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "EmptyPanDetection success!"
}
3.31 GET: ai/gallery/setlearnmode (Set learning mode)
Interface name
/osai/ai/gallery/setlearnmode
Function description
The system provides two learning modes: fast learning mode and standard learning mode. In the fast learning mode, the systemcan identify a commodity many times and then learn the identificationdata uniformly.The standard learning mode is to learn immediately after completing a recognition of a commodity. Note that standard learning mode is by default.
Request parameters
Parameter name
Parameter specification
learnmode
Set learning mode, fast: fast learning mode;normal: standard learning mode
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "SetLearnMode success! "
}
3.32 GET: ai/gallery/learn (AI learning)
Interface name
/osai/ai/gallery/learn
Function description
AI Learning Item: The system will mark the result as learning data for this SKU after recognition, please note that one recognition is required before learning. When your application scenario only needs recognition and does not involve learning, we recommend that you still call this interface and set the is_learn parameter to 0. This helps ensure the stability of the AI system.
Request parameters
Parameter name
Parameter specification
sku_id
Product ID
rec_ids
In Quick Learning mode, the system allows the user to specify a list of IDs to learn. This list is provided in array format, e.g.: [0,1,2], where each ID value is obtained during identification
productname
[Optional] Name of commodity number. Default is blank.
bool is_learn
[Optional] When set to 0, it means that the learning result will not be loaded Into the AI database. The default is 1. This parameter is suitable for "recognition only, no learning" scenarios
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Request example
Example of returned result is as
{
"code": 1,
"msg": "AiLearning success! "
}
{
"code": 1,
"msg": "SetLearnMode success! "
}
{
"code": 1,
"msg": "AiFastLearning success! "
}
3.33 GET: ai/gallery/list (Get a list of AI learned)
Interface name
/osai/ai/gallery/list
Function description
Get a list of learned SKUs.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
sku_ids
List of learned commodity numbers
Example of returned result is as
{
"code": 1,
"msg": "AiGalleryList success! ",
"sku_ids": [
"11"
]
}
3.34 GET: ai/gallery/batchlearn (Batch AI learning)
Interface name
/osai/ai/gallery/batchlearn
Function description
For batch image learning, users only need to specify a directory, and the system will automatically learn all the images in the directory.
Request parameters
Parameter name
Parameter specification
path
The parent directory of the picture collection, the picture directory structure isOSAIBackup/00001/xxx.png,
OSAIBackup/00002/xxx.png,
Among them, the first-level directory is the parent directory, the second-level directory is the directory named after the commodity number, and the third-level directory stores the corresponding pictures.
count
[Optional] Limit the maximum number of pictures that can be learned in each folder. Default is 0, which means there is no limit, i.e. learn all pictures in the folder.
return_progress
[Optional] If it is set to 1, the current progress bar value will be returned. If there is no process, 0 will be returned. Default is 0.
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
progress
Progress bar value, range 0-100, unit: %
estimate
Estimated time remaining
Request example
Example of returned result is as
{
"code": 1,
"msg": "AiBatchLearn success! "
}
{
"code": 1,
"msg": "AiBatchLearnProcess success! ",
"progress": 100,
"estimate": "0"
}
3.35 GET: ai/gallery/deleteku (AI removes products)
Interface name
/osai/ai/gallery/deletesku
Function description
AI Delete Item: The learning data for this SKU will be deleted.
Request parameters
Parameter name
Parameter specification
sku_id
Deleted article numbers
count
[Optional] Delete the nearest count records of the selected commodity number. 0 means all. Default is 0.
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "AiGalleryDelete success! "
}
3.36 GET: ai/gallery/clear (AI clears learning data)
Interface name
/osai/ai/gallery/clear
Function description
Clear learning data for all SKUs.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "AiGalleryClear success! "
}
3.37 POST: ai/gallery/prelearn (AI pre-learning)
Interface name
/osai/ai/gallery/prelearn
Function description
AI pre-learning function, the system improves the recognition accuracy of the initial use stage by learning predefined commodity pictures and matching the data of the commodity library.
Request parameters
Parameter name
Parameter specification
productlist
Product list
rule
[Optional] Matching rule, 0: exact matching, 1: fuzzy matching, default is 0
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
Return status description,
>=0: The number of successfully pre-learned goods,
-1: The parameter is null.
-2: The algorithm is not activated
Request example
http://127.0.0.1:47000/osai/ai/gallery/prelearn
Content-Type: application/json should be configured in the request header
{
"rule": 0,
"productlist": [{
"name": "cabbage",
"sku": "123456"
}]
}
Example of returned result is as
{
"code": 1,
"msg": "2"}
3.38 POST: ai/gallery/filterskus (Filter identification data)
Interface name
/osai/ai/gallery/filterskus
Function description
Filter identification data. The system will filter and exclude identification data that does not belong to the existing commodity library. Please note that these data will not be deleted.
Request parameters
Parameter name
Parameter specification
keep_skus
Keep a list of commodity numbers, and learn data for commodity numbers not in this list will be filtered out
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Request example
http://127.0.0.1:47000/osai/ai/gallery/filterskus
Content-Type: application/json should be configured in the request header
{
"keep_skus": ["80001","80002","1001"]
}
Example of returned result is as
{
"code": 1,
"msg": "KeepSkus success! "
}
3.39 POST: ai/gallery/range (Set recognition range)
Interface name
/osai/ai/gallery/range
Function description
Set the recognition range, and the AI algorithm will search for the recognition result within the range. Note that the interface will override the previous setting range, and the recognition range needs to be reset after restarting the algorithm.
Request parameters
Parameter name
Parameter specification
skuid_range
Recognition range list
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "AiGalleryRange success!"
}
3.40 GET: ai/gallery/export (Export AI data)
Interface name
/osai/ai/gallery/export
Function description
Export AI data files, you can export AI data files and store them on other devices, if you only need AI data for a single sku, you can pass in the sku_id parameter to get it, but we do not recommend doing this.
Request parameters
Parameter name
Parameter specification
packpath
Export folder path, if you do not provide a file name, the default file name will be used, such as D: /OSAI or D: /OSAI/test.zip, please note that the file name must end with ".zip"
sku_id
[Non-required] Product ID. Only the AI data of the sku is exported. The default file name is {sku_id}.feature.
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
filepath
Path to export file, blank means export failed
Request example
Example of returned result is as
{
"code": 1,
"msg": "AiGalleryExport success! ",
"filepath": "D: /feature_20290821_173637.zip"
}
3.41 GET: ai/gallery/restore (Import AI data)
Interface name
/osai/ai/gallery/restore
Function description
Import AI data files. After exporting on other devices, you can import these AI data files to this device. If you only need to import AI data of a single sku, you can pass in the.feature file, but this is not recommended.
Request parameters
Parameter name
Parameter specification
packpath
Import folder path, must be zip package
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
result
Import results,
>=0: indicates the number of studies,
-1: Algorithm not active,
-2: File does not exist,
-3: Decompression failed,
-4: Version inconsistency
Request example
Example of returned result is as
{
"code": 1,
"msg": "AiGalleryRestore success! ",
"result": 999
}
3.42 GET: ai/gallery/syncall (Synchronizing AI data)
Interface name
/osai/ai/gallery/syncall
Function description
This interface allows users to send AI data to a target machine by specifying the machine's IP address. This is suitable for scenarios where AI data needs to be synchronized or migrated between different devices.
Request parameters
Parameter name
Parameter specification
ip
Destination IP address
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "SyncAll success! "
}
3.43 GET: ai/gallery/synconlearn (Data sharing)
Interface name
/osai/ai/gallery/synconlearn
Function description
This interface is used to share AI data online in real time. When the feature is enabled, each time the system adds a new piece of AI data, the data will be automatically sent to all clients that have the feature enabled. This method is suitable for application scenarios that require instant synchronization of the latest AI data. Please note that this feature is turned off by default.
Request parameters
Parameter name
Parameter specification
enable
Turn on or off the function, 1: ON, 0: OFF
port
[Optional] Port number, default 40064
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "SyncOnLearn success! "
}
3.44 GET: ai/gallery/synconlearnstatus (Data sharing state)
Interface name
/osai/ai/gallery/synconlearnstatus
Function description
Obtain the status of the data sharing function and check whether the function is enabled.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
is_on
true: started, false: not started
Example of returned result is as
{
"code": 1,
"msg": "SyncOnLearnStatus success!",
"is_on": false
}
3.45 GET: serial/open (Open the serial port)
Interface name
/osai/serial/open
Function description
Open the serial port.
Request parameters
Parameter name
Parameter specification
dev_name
Serial device name, for example, COM2
baud_rate
[Non-required]. Baud rate. The default value is 9600
parity
[Non-required]. The default value is 0
byte_size
[Non-required]: Data bit. The default value is 8
stop_bits
[Non-required]. Stop bit. The default value is 1
protocol_type
The supported protocol types can be called serial/getprotocol?lang=en interface
async_read
[Non-required] If the value is set to 1, data over the serial port is read asynchronously and the result is pushed through the websocket service. The default value is 0
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "OpenSerial success!"
}
3.46 GET: serial/close (Close the serial port)
Interface name
/osai/serial/close
Function description
Shut down the serial port.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": " CloseSerial success!"
}
3.47 GET: serial/read (Read serial data)
Interface name
/osai/serial/read
Function description
Read serial port data.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
data
Fetch information
Status
Take the weight state, "NORM": normal
steady
Stable state, true: stable, false: unstable
tare
Tare weight
unit
Unit of weight
weight
weight
msg
State description
Example of returned result is as
{ "code": 1,
"data": {
"Status": "NORM",
"steady": true,
"tare": "+000.000",
"unit": "kg",
"weight": "+000.150"
},
"msg": "ReadSerial success!"
}
3.48 GET: serial/zero (Return to zero)
Interface name
/osai/serial/zero
Function description
Return to zero.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code":1,
"msg":"ZeroSerial success!"
}
3.49 GET: serial/peel (Peel the weight)
Interface name
/osai/serial/peel
Function description
Peel the weight.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code":1,
"msg":"PeelSerial success!"
}
3.50 GET: serial/exitasyncread (Exits the asynchronous read)
Interface name
/osai/serial/exitasyncread
Function description
Quit reading serial port data asynchronously.
Request parameters
Parameter name
Parameter specification
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code":1,
"msg":"ExitAsyncReadSerialData success!"
}
3.51 GET: serial/getprotocol (Gets the supported protocol types)
Interface name
/osai/serial/getprotocol
Function description
Gets the supported protocol types.
Request parameters
Parameter name
Parameter specification
lang
[Non-required] Language, zh: Simplified Chinese name, en: English name, default is zh
Response parameter
Parameter name
Parameter specification
code
Status code, 0: Unknown error, 1: Operation successful
msg
State description
Example of returned result is as
{
"code": 1,
"msg": "GetSerialProtocol success!",
"protocol": [
"TLD",
"DBG",
"DH",
"DJ",
"LF",
"YT",
"ZKYT",
"WD",
"RD",
"TH",
"XS",
"BC",
"QH"
]}
3.52 status code definition
default status code
explain
0
Default unknown error
1
Default operation successful
200 (old version)
Operation is successful
Program dependent status code
Description
1001
The program is not initialized
1002
Program initialization failed
1003
Interface parameter error
1004
The program version information is abnormal
1005
Failed to modify configuration information. Procedure
1006
Unsupported operations
1007
Relearning.
1008
Initializing
Device related status code
Description
2001
The old SN and the new SN are replaced incorrectly
2002
Device inactive
2003
Device activation failure
2004
Device information exception
2005
The test activation code has expired
2006
System time exception
2007
Equipment is on probation
2008
Equipment trial period has ended
so library related status code
Description
3001
The SO library is not loaded
3003
The SO library failed to load
3003
The SO library is not initialized
3004
Failed to initialize the SO library
3005
Identify exception
3006
No identification record
Identify model-related status codes
Description
3600
Identification model error
3601
Error identifying model encryption library
3602
Error identifying model accelerator library
3603
Identification model preprocessing phase error
3604
Error in identifying model post-processing phase
3605
Identify model incoming parameter errors
3606
Identify model memory errors
3607
Identify model data errors
3608
Identify model call process errors
3609
Identify model file error
3610
There is no error in identifying model keys
Matching algorithm related status code
Description
3801
Matching algorithms need to synchronize commodity data
3802
Matching algorithm incoming parameter error
3803
Matching algorithm memory error
3804
Matching algorithm data error
3805
Matching algorithm call process error
3806
The matching algorithm file is incorrect
Camera-related status code
Description
4001
Camera anomaly
4002
Image processing exception
Commodity related status code
Description
5001
The initialization item data is abnormal
5002
Example Initialize the ICON matching service exception
5003
Item ICON matching exception
5004
Nonexistence of commodity
5005
Goods locked
5006
Failed to modify commodity information
Network related status code
Description
6001
Network exception
Database related status code
Description
7001
Database operation exception
Status codes related to file operations
Description
8001
File deletion exception
8002
File replication exception
8003
File rename exception
8004
File decompression exception
8005
File does not exist
8006
File open exception
AI-related status code
Description
9001
The eigenvalue is not obtained correctly
9002
The AI model failed to load
9003
AI model versions are inconsistent
4.SDK DLL Interface description
Note: The following SDK DLL Interface namespaces are: osai
Informal interfaces not documented elsewhere may be unstable
4.1 RegIsReadyStateCallback (Register identification callbacks)
Interface name
void RegIsReadyStateCallback(IsReadyStateCallback callback);
typedef void (*IsReadyStateCallback)(const char* result);
Function description
Register the identification callback function. If the callback function is registered, the identification interface is automatically called and the callback function is executed when IsReadyState detects the identification (asynchronous operation).
Input parameters
Parameter name
Parameter specification
IsReadyStateCallback callback
Identify the resulting callback function
Output parameter
Parameter type
Parameter specification
bool
TRUE: yes FALSE: no
4.2 SetDevice (Set device type)
Interface name
bool SetDevice(const char* device);
Function description
Set the device type, AI will reason and calculate according to the way of selecting the optimal performance of the corresponding device. If not set, it will search for available NPU/GPU by default. Note that this interface needs to be called before initialization.
Input parameters
Parameter name
Parameter specification
const char* device
Type of equipment, enter" cpu"," npu"," gpu"
Output parameter
Parameter type
Parameter specification
bool
TRUE: Setting succeeded, FALSE: Setting failed
4.3 GetSdkVersion (Obtain the SDK version)
Interface name
const char* GetSdkVersion();
Function description
Get SDK version number information.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
const char*
SDK version number
4.4 GetModelVersion (Gets the model version number)
Interface name
const char* GetModelVersion();
Function description
Get the version number of the AI model currently in use.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
const char*
AI model version number
4.5 OsaiInit (SDK initialization)
Interface name
bool OsaiInit(const char* vid = "");
Function description
SDK initialization.
Input parameters
Parameter name
Parameter specification
const char* vid
vid, see SetVid interface for details,default is blank
Output parameter
Parameter type
Parameter specification
bool
TRUE: initialization succeeded, FALSE: initialization failed
4.6 OsaiUnInit (SDK release)
Interface name
bool OsaiUnInit();
Function description
SDK released.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
bool
TRUE: Release succeeded, FALSE: Release failed
4.7 GetDeviceInfo (Get details)
Interface name
bool GetDeviceInfo(DeviceInfo& deviceInfo);
Function description
Get detailed information: device number, activation code, device expiration time, store information, etc.
Input parameters
Parameter name
Parameter specification
DeviceInfo& deviceInfo
For device information, see section 4.57 of the DeviceInfo data type
Output parameter
Parameter type
Parameter specification
bool
TRUE: acquisition succeeded, FALSE: acquisition failed
4.8 SetShopInfo (Set store information)
Interface name
bool SetShopInfo(const char* name, const char* contact, const char* phone);
Function description
Set store information, you can set store name,contact person, contact phone number.
Input parameters
Parameter name
Parameter specification
const char* name
Store Name
const char* contact
Contact person
const char* phone
Phone
Output parameter
Parameter type
Parameter specification
bool
TRUE: Setting succeeded, FALSE: Setting failed
4.9 UpgradeInfo (Set store information)
Interface name
bool UpgradeInfo(char* ver, char* url, char* mode, bool model_ver = false);
Function description
Get update information: latest version number, download link, etc.
Input parameters
Parameter name
Parameter specification
char* ver
Store Name
char* url
Contact person
char* mode
Phone
bool model_ver
Whether to request upgrade information for algorithmic models. False by default means to obtain SDK upgrade information, True means to obtain algorithm model upgrade information
Output parameter
Parameter type
Parameter specification
bool
TRUE: acquisition succeeded, FALSE: acquisition failed
4.10 UpgradeProgram (Upgrade service program)
Interface name
bool UpgradeProgram(const char* url);
Function description
Upgrade program. UpgradeInfo can be called to get the upgrade url link.
Input parameters
Parameter name
Parameter specification
const char* url
Upgrade link
Output parameter
Parameter type
Parameter specification
bool
TRUE: Upgrade succeeded, FALSE: Upgrade failed
4.11 CheckNewModelUpgrade (Get model upgrade information)
Interface name
int CheckNewModelUpgrade();
Function description
Obtain model upgrade information to check whether there is an upgradable model. If the device is networked, obtain cloud model upgrade information; if it is not the latest model, pull the latest model from the cloud and update it; If the device is offline, check whether the upgradeable model exists on the local device and update it. Note that the model file is the retrieval_latest.ai file in the sdk directory.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
int
Status code,
-2: Abnormal,
-1: AI is not initialized,
0: No update required,
1: Meet update requirements
4.12 UpgradeModel (Upgrade model)
Interface name
int UpgradeModel();
Function description
Upgrade algorithm model. Please note that AI model will be automatically re-learned when upgrading, during which AI recognition function cannot be used. You can use AiGalleryBatchLearnProgress interface to obtain progress (0-100) .
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
int
Status code,
-1: Abnormal,
0: Upgrade failed,
1: Start upgrading
4.13 ThmbyMultiName (Get thumbnail)
Interface name
const char* ThmbyMultiName(const char* names, const char* lang);
Function description
Get thumbnails of online products. You can get thumbnails by passing inmultiple product names.
Input parameters
Parameter name
Parameter specification
names
Trade name, if there are multiple passes '|'Split, e.g.: "Apple|banana|pear"
lang
zh: Simplified Chinese name, en: English name, tw: Traditional Chinese name
Output parameter
Parameter type
Parameter specification
const char*
Image path, with multiple paths by ';' split, if there are multiple product names, by ''Split, e.g.: "Apple 1.jpg; Apple 2.jpg Banana.jpg pear. jpg "|||
4.14 FindOnlineDevices (Find an online device)
Interface name
const char* FindOnlineDevices(const char* type = "");
Function description
Detects the IP addresses of online devices on the LAN.
Input parameters
Parameter name
Parameter specification
type
Get by type, default is empty, get all (currently no other types).
Output parameter
Parameter type
Parameter specification
const char*
If there are multiple online device IP addresses, split them by '|'
4.15 SetVid (Set the customer exclusive ID)
Interface name
bool SetVid(const char* vid);
Function description
Set a customer-specific ID that imposes activation code usage restrictions on configured devices. For specific ID values, please contact OSAI's Commercial Team. Note that you need to invoke this interface before activating a product or requesting a trial period.
Input parameters
Parameter name
Parameter specification
const char* vid
Customer ID, please contact OSAI business staff to obtain
Output parameter
Parameter type
Parameter specification
bool
TRUE: Setting succeeded, FALSE: Setting failed
4.16 DeviceActivate (Activating device)
Interface name
bool DeviceActivate(const char* name, const char* contact, const char* phone);
Function description
Device activation, please note that inactive devices will affect the use of AI functions.
Input parameters
Parameter name
Parameter specification
const char* code
Activation code
const char* name
Store Name
const char* contact
Contact person
const char* phone
Phone
Output parameter
Parameter type
Parameter specification
bool
TRUE: activation successful, FALSE: activation failed
4.17 DeviceIsActivated (Get device activation status)
Interface name
int DeviceIsActivated();
Function description
Get device activation status.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
int
Active state,
3: Trial expires (no unbinding required),
2: Trial (no need to unbind),
1: Activated (no need to unbind),
0: Not activated (can be unbound),
-1: expired (can be unbound),
-2: Device number inconsistent with cache (can be unbound),
-3: AI not initialized (no unbinding required),
-4: Network exception, local cache read exception (no need to unbind),
-5: The cache information has expired and needs to be reconnected (no unbinding is required).
-6: Initializing (no unbinding required)
4.18 GetQRCode (Get activation QR code)
Interface name
uint8_t* GetQRCode(int* len, const char* user_type);
Function description
Get the QR code for activation of dealer or agent/general user scanning code.
Input parameters
Parameter name
Parameter specification
int* len
Qr code data stream size
const char* user_type
User type,"agent" is dealer or agent,"user" is ordinary user
Output parameter
Parameter type
Parameter specification
unsigned char*
Qr code data stream
4.19 Unbind (Unbind the current device)
Interface name
bool Unbind();
Function description
Unbinding the current device means revoking its activation state. Note that once a device is untied, the availability of its AI functionality will be affected.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
bool
TRUE: Unbinding succeeded, FALSE: Unbinding failed
4.20 GetCameraInfo (Get camera list)
Interface name
CameraInfo* GetCameraInfo(int* len);
Function description
Get a list of cameras for this device.
Input parameters
Parameter name
Parameter specification
int* len
Camera Info List Size
Output parameter
Parameter type
Parameter specification
CameraInfo*
For a list of camera information, see section 4.57 for the CameraInfo data type
4.21 OpenCamera (Turn on the camera)
Interface name
bool OpenCamera(int id = 0);
Function description
Turn on the specified camera, please note that the program will try to turn on the first camera when it starts.
Input parameters
Parameter name
Parameter specification
int id
camera ID
Output parameter
Parameter type
Parameter specification
bool
TRUE: Open successfully, FALSE: Open failed
4.22 CloseCamera (Turn off the camera)
Interface name
bool CloseCamera();
Function description
Turn off the cameras.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
bool
TRUE: closure succeeded, FALSE: closure failed
4.23 SetCameraResolution (Set camera resolution)
Interface name
bool SetCameraResolution(int width, int height);
Function description
Set the camera resolution. Note that when the resolution is set to exceed the maximum resolution supported by the camera, it is automatically set to the maximum resolution supported by the camera.
Input parameters
Parameter name
Parameter specification
int width
Resolution width
int height
Resolution height
Output parameter
Parameter type
Parameter specification
bool
TRUE: Setting succeeded, FALSE: Setting failed
4.24 GetCameraCurFrame (Get the current frame data of the video)
Interface name
uint8_t* GetCameraCurFrame(int* len);
Function description
Get a picture of the camera's current live frame.
Input parameters
Parameter name
Parameter specification
int* len
Current real-time frame data stream size
Output parameter
Parameter type
Parameter specification
unsigned char*
Current real-time frame data stream
4.25 GetCameraArea (Get the AI recognizable region)
Interface name
XYWHArea GetCameraArea();
Function description
Obtain AI identifiablearea parameters. Note the conversion between render scale and true scale.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
XYWHArea
AI can recognize the area, XYWHArea data type see section 4.57
4.26 SetCameraArea (Set the AI recognition area)
Interface name
bool SetCameraArea(XYWHArea area);
Function description
Set AI identification area parameters: This interface allows the user to define the recognition range of the AI system by specifying the location and size of the area, and the AI will only perform recognition tasks in the defined area. Please note that the rendered image is the image used to set the identification area on your company's application software, and the interface has its own saving function, and the identification area set last time will be set at the next startup.
We provide two setting methods: rectangular area and trapezoidal area, please choose the way suitable for you to enter the corresponding parameters, if you pass in the parameters of both ways, we will give priority to the trapezoidal area to set the identification area.
Input parameters
Parameter name
Parameter specification
XYWHArea area
AI identifiable area
Output parameter
Parameter type
Parameter specification
bool
TRUE: Setting succeeded, FALSE: Setting failed
4.27 VisRecImg (Get recognition image)
Interface name
uint8_t* VisRecImg(int* len, bool bbox = false, const char* skus = "");
Function description
Get the picture of this recognition. In the multi-target recognition scene, you can also highlight the commodity boxes of multiple targets on the picture by passing in the bbox parameter.
Input parameters
Parameter name
Parameter specification
int* len
Image Stream Size
bool bbox
Whether to add bbox, default is not added
const char* skus
The SKU number in the bbox box will be automatically converted to the actual product name in the format "11: apple;12: orange," which is empty by default
Output parameter
Parameter type
Parameter specification
unsigned char*
Picture data stream
4.28 AiRecognition (AI recognition)
Interface name1
const char* AiRecognition(int8_t topk_mode = 0, int8_t max_output = 0);
Interface name2
const char* AiRecognition(int8_t topk_mode, int8_t max_output, bool save_img, int timeout = 0);
Interface name3
const char* AiRecognition(ImageData imagedata, int8_t topk_mode = 0, int8_t max_output = 0);
This interface can only be called by android
Function description
Standard learning mode: AI product recognition, the system will return the result of this recognition. In the standard learning mode, the system can only identify a commodity once. If it is called repeatedly, the previous identification result will be overwritten.
Input parameters
Parameter name
Parameter specification
ImageData imagedata
Identify the data format input by the interface, only the android interface needs to be used
int8_t topk_mode
Return recognition result mode, 0 means intelligent output, output the best recognition result; greater than 0 means fixed output k recognition results
int8_t max_output
The topk_mode parameter takes effect when it is set to 0. It specifies the maximum number of outputs, where 0 indicates that the system internal default is used. That is, the output number range of recognition results is [0, max_output]
bool save_img
Save this identification picture. If set to True, the program provides the name of the picture in the return field filename and saves the picture in the program directory under the "OSAITemp" folder
int timeout
Identify timeout value. When identification time exceeds this threshold, timeout error will be returned directly.=0 represents no timeout judgment.
Output parameter
Parameter type
Parameter specification
const char*
Return recognition result, json format,rank is recognition result, corresponding to sku
{
"time": {
"extract_feat_time": 15,
"capture_frame_time": 20,
"vector_search_time": 1
},
"result": [{
"index": 0,
"rank": ["00002","00001"],
"filename": "",
"log": {"dis": ["00002: 0.991514","00001: 0.990286"]}
}]
}
4.29 AiFastRecognition (Fast learning pattern AI recognition)
Interface name1
const char* AiFastRecognition();
Interface name2
const char* AiFastRecognition(ImageData imagedata);
This interface can only be called by android
Function description
Fast learning mode: AI product identification, the system will return this identificationid. In the fast learning mode, the system can identify a commodity many times and then learn the identification data uniformly.
Input parameters
Parameter name
Parameter specification
ImageData imagedata
Identify the data format input by the interface, only the android interface needs to be used
Output parameter
Parameter type
Parameter specification
const char*
Return identification result, json format,id is theidentification of this identification
{
"result": [{
"id": 0
}]
}
4.30 IsReadyState (Gets whether the identification status is ready to trigger)
Interface name
bool IsReadyState(IsReadyStateArg arg);
Function description
Obtain whether to trigger recognition status, the interface will determine whether to trigger recognition based on the weight.
Input parameters
Parameter name
Parameter specification
IsReadyStateArg arg
Input parameters, IsReadyStateArg data type as described in 4.57
Output parameter
Parameter type
Parameter specification
bool
TRUE: yes FALSE: no
4.31 EnableEmptyPanDetection (Open the empty pan test)
Interface name
bool EnableEmptyPanDetection();
Function description
This interface will turn on the empty pan detection function, we will detect whether the current recognition result is empty pan, if it is empty pan, it will return the empty recognition result.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
bool
TRUE: success FALSE: failure
4.32 AiGalleryLearn (AI learning)
Interface name1
bool AiGalleryLearn(const char* sku_id, size_t index = 0);
Interface name2
bool AiGalleryLearn(const char* sku_id, const char* sku_name, bool is_learn = true, size_t index = 0);
Function description
Standard learning mode: AI learns the product, and the system marks the recognition result as the learning data of the SKU. Please note that one recognition is required before learning. When you only need to recognize and not learn in your application scenario, we recommend that you still call this interface and set the is_learn parameter to false to ensure the stability of the AI system.
Input parameters
Parameter name
Parameter specification
const char* sku_id
Product ID
const char* sku_name
Name of commodity number
bool is_learn
Whetherto execute learning operation. If false, it means that thelearning result is not loaded into the library, that is, only the non-learning mode is identified.
size_t index
Learn the index of thetarget product, this indexwill be returned in the recognition result, in the single-target recognition scenario this parameter is always 0
Output parameter
Parameter type
Parameter specification
bool
TRUE: Learning successful, FALSE: Learning failed
4.33 AiGalleryFastLearn (Fast learning mode AI learning)
Interface name1
bool AiGalleryFastLearn(const char* sku_id, size_t* rec_ids, int len);
Interface name2
bool AiGalleryFastLearn(const char* sku_id, const char* sku_name, size_t* rec_ids, int len);
Function description
Fast learning mode: AI learning commodities . In the fast learning mode, the system allows the user to specify a list of IDs to learn, and then collectively learn these IDs.
Input parameters
Parameter name
Parameter specification
const char* sku_id
Product ID
const char* sku_name
Name of commodity number
size_t* rec_ids
Identification ID list, wherein each ID value is acquired during identificationof the fast learning mode
int len
IdentificationID listsize
Output parameter
Parameter type
Parameter specification
bool
TRUE: Learning successful, FALSE: Learning failed
4.34 AiGalleryList (Get a list of AI learned)
Interface name
const char* AiGalleryList();
Function description
Get a list of learned SKUs.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
const char*
List of SKUs learned, separated by commas
4.35 AiGalleryBatchLearn (Batch AI learning)
Interface name
bool AiGalleryBatchLearn(const char* dirpath = "OSAIBackup", int count = 0);
Function description
For batch image learning, users only need to specify a directory, and the system will automatically learn all the images in the directory. Please note that the picture directory structureOSAIBackup/00001/xxx.png,
OSAIBackup/00002/xxx.png, where the primary directory is the parent directory, the secondary directory is the directory named after the commodity number, and the tertiary directory stores the corresponding pictures.
Input parameters
Parameter name
Parameter specification
const char* dirpath
The parent directory of a picture collection
int count
Limit the maximum number of pictures that can be learned in each folder. The default is 0, which means there is no limit, i.e. learn all pictures in the folder.
Output parameter
Parameter type
Parameter specification
bool
TRUE: Learning successful, FALSE: Learning failed
4.36 AiGalleryBatchLearnProgress (Batch AI learning progress)
Interface name
uint8_t AiGalleryBatchLearnProgress();
Function description
Get progressand estimated time remaining for batch image learning items.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
unsigned char
Progress value (0-100), 120 represents learning failure
4.37 AiGalleryDeleteSku (AI removes products)
Interface name
bool AiGalleryDeleteSku(const char* sku_id, size_t count = 0);
Function description
AI Delete Item: The learning data for this SKU will be deleted. Note that when you want to recall a learning record, you can call this interface and set count to 1.
Input parameters
Parameter name
Parameter specification
const char* sku_id
Item number, passing in "*" means deleting all items
size_t count
Delete the most recent count records for the selected item number, 0 for all
Output parameter
Parameter type
Parameter specification
bool
TRUE: Delete succeeded, FALSE: Delete failed
4.38 AiGalleryPreLearn (AI pre-learning)
Interface name
int AiGalleryPreLearn(Product** products, int len, int rule = 0);
Function description
AI pre-learning function, the system improves the recognition accuracy of the initial use stage by learning predefined commodity pictures and matching the data of the commodity library.
Input parameters
Parameter name
Parameter specification
Product** products
See Section 4.57 for the list of Product data types
int len
Product list size
int rule
Matching rules, 0 is exact matching, 1 is fuzzy matching
Output parameter
Parameter type
Parameter specification
int
Return code,
>=0: Number of successful pre-learning items,
-1: parameter is empty,
-2: Algorithm not active
4.39 AiGalleryFilterSkus (Filter identification data)
Interface name
bool AiGalleryFilterSkus(const char* keepsku_array[], int count);
Function description
Filter identification data, the system will filter and exclude identification data that does not belong to the existing product library, please note that these data will only be filtered at the time of identification, and will not be deleted.
Input parameters
Parameter name
Parameter specification
const char* keepsku_array[]
Keep a list of commodity numbers, and learn data for commodity numbers not in this list will be filtered out
int count
Number of item number lists
Output parameter
Parameter type
Parameter specification
bool
TRUE: reservation succeeded, FALSE: reservation failed
4.40 AiGalleryRange (Set recognition range)
Interface name
bool AiGalleryRange(const char* skuid_range[], size_t skuid_range_len);
Function description
Set the recognition range, and the AI algorithm will find the recognition result within the range. Note that the interface will override the previous setting range.
Input parameters
Parameter name
Parameter specification
const char* skuid_range[]
Identification range array
size_t skuid_range_len
Array size
Output parameter
Parameter type
Parameter specification
bool
TRUE: The setup was successful; FALSE: the setup failed
4.41 AiGalleryRenameSku (Change SKU name)
Interface name
bool AiGalleryRenameSku(const char* oldsku, const char* newsku);
Function description
Change sku name, please note that error is returned when new sku exists or old sku does not exist.
Input parameters
Parameter name
Parameter specification
const char* oldsku
Old sku
const char* newsku
New sku
Output parameter
Parameter type
Parameter specification
bool
TRUE: replacement succeeded , FALSE: replacement failed
4.42 ExportFeature (Export AI data)
Interface name1
const char* ExportFeature(const char* packpath);
Interface name2
const char* ExportFeature(const char* packpath, const char* sku_id);
Function description
Export the AI data files. You can export the AI data files and store them on another device. If you only need the AI data of a single sku, you can get it by passing the sku_id parameter, but this is not recommended.
Input parameters
Parameter name
Parameter specification
const char* packpath
Export folder path, if you do not provide a file name, the default file name will be used, such as D: /OSAI or D: /OSAI/test.zip, please note that the file name must end with ".zip"
const char* sku_id
[Non-required] product number, only export the AI data of the sku, the default file name is {sku_id}.feature.
Output parameter
Parameter type
Parameter specification
const char*
Path to export file, blank means export failed
4.43 LoadFeature (Import AI data)
Interface name
int LoadFeature(const char* packpath);
Function description
Import the AI data files. Once the export is done on another device, you can import the AI data files to this device. If you only need to import the AI data of a single sku, you can pass the.feature file, but this is not recommended.
Input parameters
Parameter name
Parameter specification
const char* packpath
Import folder path, must be zip package
Output parameter
Parameter type
Parameter specification
int
Return code,
>= 0: indicates the number of studies,
-1: Algorithm not active,
-2: File does not exist,
-3: Decompression failed,
-4: Version inconsistency
4.44 SyncData (Synchronizing AI data)
Interface name
bool SyncData(const char* ip);
Function description
This interface allows users to send AI data to a target machine by specifying the machine's IP address. This applies to scenarios where AI data needs to be synchronized or migrated between different devices. Please note that the network between the two devices must be able to ping.
Input parameters
Parameter name
Parameter specification
const char* ip
Destination IP
Output parameter
Parameter type
Parameter specification
bool
TRUE: synchronization successful, FALSE: synchronization failed
4.45 ShareStartData (Data sharing)
Interface name
bool StartShareData(int port = 40064);
Function description
This interface is used to enable online real-time AI data sharing. When the feature is enabled, each time the system adds a new piece of AI data, the data will be automatically sent to all clients that have the feature enabled. This method is suitable for application scenarios that require instant synchronization of the latest AI data. Please note that this feature is turned off by default, and the default port is 40064.
Input parameters
Parameter name
Parameter specification
int port
Port number
Output parameter
Parameter type
Parameter specification
bool
TRUE: Open successfully, FALSE: Open failed
4.46 CloseShareData (Disabling Data Sharing)
Interface name
bool CloseShareData();
Function description
Turn off real-time sharing of AI data online.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
bool
TRUE: closure succeeded, FALSE: closure failed
4.47 ShareDataStatus (Data sharing status)
Interface name
bool ShareDataStatus();
Function description
Share learning data functional status.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
bool
TRUE: open, FALSE: closed
4.48 OpenSerial (Open the serial port)
Interface name
bool OpenSerial(const char* dev_name, uint32_t baud_rate, char parity, char byte_size, char stop_bits, ProtocolType protocol_type);
Function description
Open the serial port.
Input parameters
Parameter name
Parameter specification
const char* dev_name
Serial device name, for example, COM2
uint32_t baud_rate
Baud rate
char parity
Check bit (0 is no check, 1 is odd check, 2 is even check, 3 is mark check)
char byte_size
Data bit
char stop_bits
Stop bit (1 is 1 stop bit,2 is 2 stop bit,3 is 1.5 stop bit)
ProtocolType protocol_type
Protocol type of the scale ; see 4.57 for the ProtocolType data type
Output parameter
Parameter type
Parameter specification
bool
TRUE: open successfully, FALSE: open failed
4.49 CloseSerial (Close the serial port)
Interface name
bool CloseSerial();
Function description
Shut down the serial port.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
bool
TRUE: The shutdown succeeds. FALSE: the shutdown fails
4.50 ReadSerial (Read serial data)
Interface name
SerialData ReadSerial();
Function description
Read serial port data.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
SerialData
For details about the serial port data, see 4.57 for the data type SerialData
4.51 Peel (Peel the weight)
Interface name
bool Peel();
Function description
Peel the weight.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
bool
TRUE: Peeling succeeds. FALSE: peeling fails
4.52 Zero (Return to zero)
Interface name
bool Zero();
Function description
Return to zero.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
bool
TRUE: zeroing succeeds FALSE: zeroing fails
4.53 AsyncReadSerialData (Asynchronous read serial data)
Interface name
bool AsyncReadSerialData(const SerialDataCallback& callback);
Function description
Asynchronously reading serial port data.
Input parameters
Parameter name
Parameter specification
const SerialDataCallback& callback
Read data callback function
Output parameter
Parameter type
Parameter specification
bool
TRUE: The call succeeds. FALSE: the call fails
4.54 ExitAsyncReadSerialData (Exits the asynchronous read)
Interface name
bool ExitAsyncReadSerialData();
Function description
The asynchronous reading of serial port data exits.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
bool
TRUE: the exit succeeds. FALSE: the exit fails
4.55 LastError (The last error message is displayed)
Interface name
const char* LastError();
Function description
Output the last error message.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
const char*
Last error message
4.56 LastErrorCode (Output the last error code)
Interface name
int LastErrorCode();
Function description
Output the last error code.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
int
Last error code
4.57 Complex Data Type Description
type name
DeviceInfo
parameter
Parameter name
Parameter specification
bool activated
Whether to activate
bool expired
For expiration
char sn[128]
Device serial number
char cd_key[128]
Activation code
char deadline[128]
Expiration time
type name
CameraInfo
parameter
Parameter name
Parameter specification
unsigned int id
Camera ID number
char name[128]
Camera name
char link[128]
Camera Path
type name
XYWHArea
parameter
Parameter name
Parameter specification
unsigned int x
Render image Select coordinate x in the upper left corner of the rectangular area
unsigned int y
Render image Select the coordinate y in the upper left corner of the rectangular area
unsigned int w
Render image selected rectangular area width
unsigned int h
Render image with selected rectangular area height
unsigned int topleft_x
Render image by selecting the top left coordinate x of the trapezoid area
unsigned int topleft_y
To render the image, select coordinate y in the upper left corner of the trapezoid area
unsigned int topright_x
Render image by selecting the top right corner coordinate x of the trapezoid area
unsigned int topright_y
Render image by selecting the top right corner coordinate y of the trapezoid area
unsigned int bottomleft_x
Render image by selecting the lower-left coordinate x of the trapezoid area
unsigned int bottomleft_y
Render image by selecting the bottom left coordinate y of the trapezoid area
unsigned int bottomright_x
Render image by selecting the lower right corner coordinate x of the trapezoid area
unsigned int bottomright_y
Render image by selecting the lower-right coordinate y of the trapezoid area
unsigned int img_w
The width of the rendered image
unsigned int img_h
Render the height of the image
type name
IsReadyStateArg
parameter
Parameter name
Parameter specification
float weight
Weight, in g
bool is_steady
Whether the steady state of the pan
bool rec_after_steady = false
Post-stabilization recognition
bool start_from_zero = true
Recognition after zero
int max_check_time = 120
Maximum detection time, the maximum time to detect image quality after weight is reached
int min_rec_weight = 20
Minimum discernible weight in g
type name
Product
parameter
Parameter name
Parameter specification
char sku[128]
Product ID
char name[128]
Product name
type name
ProtocolType
parameter
Parameter name
Parameter specification
TUO_LI_DUO
METTLER TOLEDO Protocol type
DI_BAO_G
DIBAL G Series Protocol type
DA_HUA
DAHUA Protocol type
DING_JIANG
Aclas Protocol type
LONG_FLY
LONGFLY Protocol type
YING_TUO
ENTOAM Protocol type
ZK_YT
WINTEC Protocol type
VAN_DING
Wandin Protocol type
RONGTA
RONGTA Protocol type
TAI_HANG
Ttaihang Protocol type
XIANG_SHAN
SESSUN Protocol type
BIZER_BA
BIZERBR Protocol type
QI_HUA
QIHUA Protocol type
type name
SerialData
parameter
Parameter name
Parameter specification
bool steady
Whether stable or not
const char* weight
weight
const char* unit
Weight unit (the default is kg, if the weighing protocol has a unit, then the weight unit resolved by the protocol is returned)
const char* tare
Tare weight
Status status
State
type name
Status
parameter
Parameter name
Parameter specification
NORM
normal
ERRO
exception
5. Android SDK Interface description
Note: Android SDK interfaces are uniformly maintained in the Osai class. For other interfaces, please see Section 6.2 Java Interface Comparison Table.
5.1 setCameraBrightness (Set camera brightness)
Interface name
void setCameraBrightness(int brightness);
Function description
Set camera brightness, Android camera is not supported.
Input parameters
Parameter name
Parameter specification
int brightness
Brightness value: 0-100
Output parameter
Parameter type
Parameter specification
5.2 getCameraBrightness (Get camera brightness)
Interface name
int getCameraBrightness();
Function description
Get camera brightness, Android camera does not support, willget 0.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
int
luminance value
5.3 getCameraImageData (Get camera image data)
Interface name
ImageData getCameraImageData();
Function description
Acquire cameraimage data, the data type being the image format passed into the recognition interface.
Input parameters
Parameter name
Parameter specification
Output parameter
Parameter type
Parameter specification
ImageData
Identify interface image data types
Example usage
ImageData img = getCameraImageData();
String ret = aiRecognition(img);
5.4 getBitmapImageData (Get bitmap image data)
Interface name
ImageData getBitmapImageData(Bitmap bitmap);
Function description
Gets bitmapimage data, the data type being the image format passed into the recognition interface.
Input parameters
Parameter name
Parameter specification
Bitmap bitmap
Bitmap type data image
Output parameter
Parameter type
Parameter specification
ImageData
Identify interface image data types
Example usage
Bitmap bitmap;
ImageData img = getBitmapImageData(bitmap);
String ret = aiRecognition(img);
5.5 initialize (SDK initialization)
Interface name
Osai initialize(ConfigBuilder builder);
Function description
Before performing algorithm initialization, you need to use the configuration parameter initialization interface to set some parameters. You can check out the "Example usage" below for specific usage. Also, you can consult the interface description with the prefix "ConfigBuilder::" for more details about configuring the interface.
Input parameters
Parameter name
Parameter specification
ConfigBuilder builder
ConfigBuilder class object
Output parameter
Parameter type
Parameter specification
Osai
Osai class
Example usage
Osai.ConfigBuilder builder = new Osai.ConfigBuilder()
builder.setcontext(this);
builder.setOpenCamera(true);
builder.setVid(“XXX");
Osai.initialize(builder);
5.6 ConfigBuilder::setVid (Set the customer exclusive ID)
Interface name
ConfigBuilder setVid(String vid);
Function description
Set a customer-specific ID that imposes activation code usage restrictions on configured devices. For specific ID values, please contact OSAI's Commercial Team. Note that you need to invoke this interface before activating a product or requesting a trial period.
Input parameters
Parameter name
Parameter specification
String vid
Customer ID, please contact OSAI business staff to obtain
Output parameter
Parameter type
Parameter specification
ConfigBuilder
Return ConfigBuilder object
Example usage
Osai.ConfigBuilder builder = new Osai.ConfigBuilder()
builder.setcontext(this);
builder.setVid(“XXX");
Osai.initialize(builder);
5.7 ConfigBuilder::setOpenCamera (Set whether to turn on the camera automatically)
Interface name
ConfigBuilder setOpenCamera(boolean open);
Function description
Set whether to turn on the camera automatically.
Input parameters
Parameter name
Parameter specification
boolean open
Turn on camera automatically
Output parameter
Parameter type
Parameter specification
ConfigBuilder
Return ConfigBuilder object
Example usage
Osai.ConfigBuilder builder = new Osai.ConfigBuilder()
builder.setcontext(this);
builder.setOpenCamera(true);
Osai.initialize(builder);
5.8 ConfigBuilder::setCameraVid (Specify the Usb camera id)
Interface name
ConfigBuilder setCameraVid(int cameraVid);
Function description
Specify the Usb camera id.
Input parameters
Parameter name
Parameter specification
int cameraVid
Usb camera id
Output parameter
Parameter type
Parameter specification
ConfigBuilder
Return ConfigBuilder object
Example usage
Osai.ConfigBuilder builder = new Osai.ConfigBuilder()
builder.setcontext(this);
builder.setCameraVid(0);
Osai.initialize(builder);
5.9 addInitCallback (Obtain the progress of loading AI data)
Interface name
addInitCallback(new InitCallback()
Function description
Obtain the progress of loading AI data
Input parameters
Parameter name
Parameter specification
InitCallback
callback
Output parameter
Parameter type
Parameter specification
Example usage
Osai.getInstance().addInitCallback(new InitCallback() {
@Override
public void onInit(int progress) {
if(progress == 100) {
// Load complete
}
}
});
6.Comparison of programming language interfaces
6.1 C# Interface Comparison Table
C++ Interface name
C# Interface name
RegIsReadyStateCallback
?RegIsReadyStateCallback@osai@@YGXP6AXPBD@Z@Z
GetSdkVersion
?GetSdkVersion@osai@@YGPBDXZ
GetModelVersion
?GetModelVersion@osai@@YGPBDXZ
OsaiInit
?OsaiInit@osai@@YG_NPBD@Z
OsaiUnInit
?OsaiUnInit@osai@@YG_NXZ
GetDeviceInfo
?GetDeviceInfo@osai@@YG?AVDeviceInfo@1@XZ
SetShopInfo
?SetShopInfo@osai@@YG_NPBD00@Z
UpgradeInfo
?UpgradeInfo@osai@@YG_NPAD00_N@Z
UpgradeProgram
?UpgradeProgram@osai@@YG_NPBD@Z
CheckNewModelUpgrade
?CheckNewModelUpgrade@osai@@YGHXZ
UpgradeModel
?UpgradeModel@osai@@YGHXZ
ThmbyMultiName
?ThmbyMultiName@osai@@YGPBDPBD0@Z
DetectionOnlineDevices
?DetectionOnlineDevices@osai@@YGPBDPBD@Z
SetVid
?SetVid@osai@@YG_NPBD@Z
DeviceActivate
?DeviceActivate@osai@@YG_NPBD000@Z
DeviceIsActivated
?DeviceIsActivated@osai@@YGHXZ
AgentQRCode
?AgentQRCode@osai@@YGPAEPAH@Z
UserQRCode
?UserQRCode@osai@@YGPAEPAH@Z
GetQRCode
?GetQRCode@osai@@YGPAEPAHPBD@Z
Unbind
?Unbind@osai@@YG_NXZ
GetCameraInfo
?GetCameraInfo@osai@@YGPAVCameraInfo@1@PAH@Z
OpenCamera
?OpenCamera@osai@@YG_NH@Z
CloseCamera
?CloseCamera@osai@@YG_NXZ
SetCameraResolution
?SetCameraResolution@osai@@YG_NHH@Z
GetCameraCurFrame
?GetCameraCurFrame@osai@@YGPAEPAH@Z
GetCameraArea
?GetCameraArea@osai@@YG?AVXYWHArea@1@XZ
SetCameraArea
?SetCameraArea@osai@@YG_NVXYWHArea@1@@Z
VisualizeRecImg
?VisualizeRecImg@osai@@YGPAEPAH_NPBD@Z
AiRecognition
?AiRecognition@osai@@YGPBDCC@Z
AiRecognition
?AiRecognition@osai@@YGPBDCC_NH@Z
AiFastRecognition
?AiFastRecognition@osai@@YGPBDXZ
IsReadyState
??0IsReadyStateArg@osai@@QAE@XZ
EnableEmptyPanDetection
?EnableEmptyPanDetection@osai@@YG_NXZ
AiGalleryLearn
?AiGalleryLearn@osai@@YG_NPBD0_NI@Z
AiGalleryLearn
?AiGalleryLearn@osai@@YG_NPBDI@Z
AiGalleryFastLearn
?AiGalleryFastLearn@osai@@YG_NPBD0PAIH@Z
AiGalleryFastLearn
?AiGalleryFastLearn@osai@@YG_NPBDPAIH@Z
AiGalleryList
?AiGalleryList@osai@@YGPBDXZ
AiGalleryBatchLearn
?AiGalleryBatchLearn@osai@@YG_NPBDH@Z
AiGalleryBatchLearnProgress
?AiGalleryBatchLearnProgress@osai@@YGEXZ
AiGalleryDeleteSku
?AiGalleryDeleteSku@osai@@YG_NPBDI@Z
AiGalleryPreLearn
?AiGalleryPreLearn@osai@@YGHPAPAVProduct@1@HH@Z
AiGalleryFilterSkus
?AiGalleryFilterSkus@osai@@YG_NQAPBDH@Z
AiGalleryRange
?AiGalleryRange@osai@@YG_NQAPBDI@Z
AiGalleryRenameSku
?AiGalleryRenameSku@osai@@YG_NPBD0@Z
ExportFeature
?ExportFeature@osai@@YGPBDPBD@Z
ExportFeature
?ExportFeature@osai@@YGPBDPBD0@Z
UnpackFeature
?UnpackFeature@osai@@YGHPBD@Z
LoadFeature
?LoadFeature@osai@@YGHPBD@Z
SyncData
?SyncData@osai@@YG_NPBD@Z
StartShareData
?StartShareData@osai@@YG_NH@Z
CloseShareData
?CloseShareData@osai@@YG_NXZ
ShareDataStatus
?ShareDataStatus@osai@@YG_NXZ
OpenSerial
?OpenSerial@serial@osai@@YG_NPBDIDDDW4ProtocolType@serialtype@2@@Z
CloseSerial
?CloseSerial@serial@osai@@YG_NXZ
ReadSerial
?ReadSerial@serial@osai@@YG?AUSerialData@serialtype@2@XZ
AsyncReadSerialData
?AsyncReadSerialData@serial@osai@@YG_NABQ6AXABUSerialData@serialtype@2@@Z@Z
ExitAsyncReadSerialData
?ExitAsyncReadSerialData@serial@osai@@YG_NXZ
Peel
?Peel@serial@osai@@YG_NXZ
Zero
?Zero@serial@osai@@YG_NXZ
LastError
?LastError@osai@@YGPBDXZ
LastErrorCode
?LastErrorCode@osai@@YGHXZ
6.2 Java Interface Comparison Table
C++ Interface name
Java Interface name
void RegIsReadyStateCallback(IsReadyStateCallback callback);
regIsReadyStateCallback(RecognitionCallback callback)
const char* GetSdkVersion();
String getSdkVersion();
const char* GetModelVersion();
String getModelVersion();
bool OsaiInit();
boolean osaiInit();
bool OsaiUnInit();
boolean osaiUnInit();
bool GetDeviceInfo(DeviceInfo& deviceInfo);
DeviceInfo getDeviceInfo();
bool SetShopInfo(const char* name, const char* contact, const char* phone);
boolean setShopInfo(String name, String contact, String phone);
int CheckNewModelUpgrade();
int checkNewModelUpgrade();
int UpgradeModel();
int upgradeModel();
bool SetVid(const char* vid);
ConfigBuilder: : setVid(String vid);
bool DeviceActivate(const char* code, const char* name, const char* contact, const char* phone);
boolean deviceActivate(String code, String name, String contact, String phone);
int DeviceIsActivated();
int deviceIsActivated();
uint8_t* GetQRCode(int* len, const char* user_type);
byte[] getQRCode(String user_type);
bool Unbind();
boolean unbind();
bool OpenCamera(int id = 0);
ConfigBuilder: : setOpenCamera(boolean open);
ConfigBuilder: : setCameraVid(int cameraVid);
uint8_t* GetCameraCurFrame(int* len);
Bitmap GetCameraCurFrame();
XYWHArea GetCameraArea();
XYWHArea getCameraArea();
bool SetCameraArea(XYWHArea area);
boolean setCameraArea(XYWHArea area);
uint8_t* VisRecImg(int* len, bool bbox = false, const char* skus = "");
byte[] visRecImg(boolean bbox, String skus);
const char* AiRecognition(ImageData imagedata, int8_t topk_mode = 0, int8_t max_output = 0);
String aiRecognition(ImageData imagedata, int topk_mode, int max_output);
const char* AiFastRecognition(ImageData imagedata);
String aiFastRecognition(ImageData imagedata);
bool IsReadyState(IsReadyStateArg arg);
isReadyState(IsReadyStateArg isReadyStateArg)
bool EnableEmptyPanDetection();
boolean enableEmptyPanDetection();
bool AiGalleryLearn(const char* sku_id, size_t index = 0);
boolean aiGalleryLearn(String sku_id, int index);
bool AiGalleryLearn(const char* sku_id, const char* sku_name, bool is_learn = true, size_t index = 0);
boolean aiGalleryLearn(String sku_id, String sku_name, bool is_learn, int index);
bool AiGalleryFastLearn(const char* sku_id, const char* sku_name, size_t* rec_ids, int len);
boolean aiGalleryFastLearn(String sku_id, String sku_name,int[] rec_ids);
const char* AiGalleryList();
String aiGalleryList();
bool AiGalleryBatchLearn(const char* dirpath = "OSAIBackup", int count = 0);
boolean aiGalleryBatchLearn(String dirpath,int count);
uint8_t AiGalleryBatchLearnProgress();
int AiGalleryBatchLearnProgress();
bool AiGalleryDeleteSku(const char* sku_id, size_t count = 0);
boolean aiGalleryDeleteSku(String sku_id, int count);
int AiGalleryPreLearn(Product** products, int len, int rule = 0);
int aiGalleryPreLearn(Product[] products, int rule);
bool AiGalleryFilterSkus(const char* keepsku_array[], int count);
boolean aiGalleryFilterSkus(String[] keepsku_array, int count);
bool AiGalleryRenameSku(const char* oldsku, const char* newsku);
boolean aiGalleryRenameSku(String oldsku, String newsku);
const char* ExportFeature(const char* packpath);
String exportFeature(String packpath);
const char* ExportFeature(const char* packpath, const char* sku_id);
exportFeature(String path, String sku)
int LoadFeature(const char* packpath);
int loadFeature(String packpath);
bool SyncData(const char* ip);
boolean syncData(String ip);
bool StartShareData(int port = 40064);
boolean startShareData();
boolean startShareData(int port);
bool CloseShareData();
boolean closeShareData();
bool ShareDataStatus();
boolean shareDataStatus();
7. Appendix
7.1 OSAI Windows SDK package file details
SO library
Explain
api-ms-win-xxx.dll
Windows OS so library
vcruntime140.dll
VC++ Runtime
msvcp120.dll
msvcp140.dll
msvcr120.dll
ucrtbase.dll
Basic components of Universal C Runtime (UCRT)
libosai.dll
OSAI AI so library
File
Explain
osai.db
AI learned database
prelearned.db
AI Pre-Learning Database
retrieval.ai
AI model file
retrieval_latest.ai
AI new model file
osai_configure.ini
AI Profile
UpdatePkg.exe
AI upgrade replacement program
OSAIService.exe
AI Service Program
Folder
Explain
OSAILog
AI Log File Storage Directory
OSAIBackup
AI Learning Data Backup Catalog
OSAIIcon
AI thumbnail storage directory
OSAITemp
AI recognition picture storage directory
7.2 OSAI Linux SDK package file details
SO library
Explain
libxxx.so
Linux operating system so library
libQt5Core.so.5
QT runtime
libQt5DBus.so.5
libQt5Gui.so.5
libQt5Widgets.so.5
libQt5XcbQpa.so.5
platforms/libqxcb.so
libosai.so
OSAI AI so library
File
Explain
osai.db
AI learned database
prelearned.db
AI Pre-Learning Database
retrieval.ai
AI model file
retrieval_latest.ai
AI new model file
osai_configure.ini
AI Profile
UpdatePkg
AI upgrade replacement program
OSAIService
AI Service Program
OSAIService.run
AI Service Program Startup Script
Folder
Explain
OSAILog
AI Log File Storage Directory
OSAIBackup
AI Learning Data Backup Catalog
OSAIIcon
AI thumbnail storage directory
OSAITemp
AI recognition picture storage directory
7.3 OSAI Android SDK package file details
SO library
Explain
libc++_shared.so
C++ standard library so library
libjpeg-turbo1500.so
Image compression and decompression library
libmmkv.so
key-value store
libopencv_java4.so
Opencv Image Processing Algorithm Library
librknnrt.so
Npu inference library
libcamera.so
OSAI self-developed camera processing library
libosai.so
OSAI AI C++ interface so library
libosnn5-lib.so
OSAI AI Java interface so library
File
Explain
osai.db
AI learned database
prelearned.db
AI Pre-Learning Database
retrieval.ai
AI model file
retrieval.aik
AI model file
retrieval_latest.ai
AI new model file
osai_configure.ini
AI Profile
Folder
Explain
OSAILog
AI Log File Storage Directory
OSAIBackup
AI Learning Data Backup Catalog
OSAIIcon
AI thumbnail storage directory
OSAITemp
AI recognition picture storage directory
Last updated