API Reference
Mech-Vision SDK provides the following core classes to manage the full lifecycle of solutions, projects, and Steps.
Core Class Overview
| Class | Description |
|---|---|
|
Manages the lifecycle of a solution, including opening, closing, saving, and renaming a solution, as well as obtaining solution information, project information, camera information, and communication configurations. |
|
Manages vision projects, including saving projects, running/stopping projects, obtaining output data, pinning Step output ports, and registering callbacks for running-state changes and acquisition completion. |
|
Manages a single Step in a vision project, including getting Step information, reading/writing Step parameters (JSON format), running a Step independently, and obtaining Step output data. |
|
A unified error status structure that includes an error code ( |
Solution Class
Common Methods
| Method signature | Return value | Description |
|---|---|---|
|
|
Opens the solution at the specified path. |
|
|
Closes the opened solution. When |
|
|
Saves the current solution. |
|
|
Renames the solution (and its solution directory). Keep a short interval between two rename operations. |
|
|
Gets basic solution information and outputs it to the |
|
|
Gets information for all projects in the solution and outputs it to |
Project Class
Common Methods
| Method signature | Return value | Description |
|---|---|---|
|
- |
Constructor. Pass in the project name. |
|
|
Gets basic project information and outputs it to the |
|
|
Saves the project. |
|
|
Runs the project. |
|
|
Stops the running project. |
|
|
Gets project output data (JSON string). |
|
|
Pins output data of specified Step ports to prevent data loss after project execution finishes. |
|
|
Registers a callback for project running-state changes (triggered when the project starts/ends). |
|
|
Registers a callback for project acquisition completion (triggered after all acquisition Steps are completed). |
ProjectInfo Structure
struct ProjectInfo {
int id; // Unique project ID
std::string name; // Project name
std::string path; // Absolute path of the project file
bool hasChanges; // Whether there are unsaved changes
bool isRegistered; // Whether it is registered
bool isRunning; // Whether it is currently running
};
Step Class
Common Methods
| Method signature | Return value | Description |
|---|---|---|
|
- |
Constructor. Pass in the Step name and the project name it belongs to. |
|
|
Gets basic Step information and outputs it to the |
|
|
Gets Step parameters by a JSON array of property names. |
|
|
Sets Step parameters in batch through a JSON string. |
|
|
Runs this Step independently (from the beginning up to this Step). |
|
|
Gets Step output data of the specified port ( |
ErrorStatus Structure
All SDK methods return ErrorStatus, which contains the following fields:
struct ErrorStatus {
std::string code; // Error code (for example, "SUCCESS" or "-E_FILE_IO_ERROR")
std::string description; // Error description
bool ok() const; // Whether successful (code == "SUCCESS")
};
Common Error Codes
| Error code | Meaning |
|---|---|
|
Operation succeeded |
|
Internal error (for example, the project service is not registered) |
|
File I/O error (path does not exist, save failed, and so on) |
|
Invalid parameter (empty parameter or incorrect format) |
|
Version incompatible |
|
Permission denied |
|
Solution not opened |
|
Incorrect solution username or password |
|
Project not found |
|
Project is running, so this operation cannot be performed |
|
The number of running project tasks exceeds the upper limit |
|
Step not found |
|
Step property name does not exist, or property value type does not match |
|
Specified parameter recipe name does not exist |
|
Global variable does not exist |
|
Global variable type mismatch |
Global Functions
| Function signature | Description |
|---|---|
|
Initializes the SDK. You can pass in the path to a JSON configuration file. If omitted, the default configuration is used. This must be called first when the program starts. |
|
Uninitializes the SDK and releases all resources. This must be called before the program exits. |
|
Starts the Vision service through the SDK. |
|
Closes the Vision service that is started through the SDK. |