API Reference

You are currently viewing the documentation for a pre-release version (2.2.0). To access documentation for other versions, click the "Switch Version" button located in the upper-right corner of the page.

■ If you're unsure about the version of the product you are using, please contact Mech-Mind Technical Support for assistance.

Mech-Vision SDK provides the following core classes to manage the full lifecycle of solutions, projects, and Steps.

Core Class Overview

Class Description

Solution

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.

Project

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.

Step

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.

ErrorStatus

A unified error status structure that includes an error code (code) and description (description) for the operation result, and provides the ok() method to determine whether the operation succeeds.

Solution Class

Common Methods

Method signature Return value Description

open(path, username, password)

ErrorStatus

Opens the solution at the specified path. username and password are optional (leave empty when access control is not enabled).

close(discardChanges=true)

ErrorStatus

Closes the opened solution. When discardChanges=true, the solution is forcibly closed and unsaved changes are discarded.

save()

ErrorStatus

Saves the current solution.

rename(name)

ErrorStatus

Renames the solution (and its solution directory). Keep a short interval between two rename operations.

getInfo(info)

ErrorStatus

Gets basic solution information and outputs it to the SolutionInfo structure.

getAllProjectInfos(projectInfos)

ErrorStatus

Gets information for all projects in the solution and outputs it to vector<ProjectInfo>.

SolutionInfo Structure

struct SolutionInfo {
    std::string name;       // Solution name
    std::string path;       // Absolute path of the solution directory
    std::string version;    // Solution version
    bool hasChanges;        // Whether there are unsaved changes
    bool isRunning;         // Whether it is currently running
};

Project Class

Common Methods

Method signature Return value Description

Project(name)

-

Constructor. Pass in the project name.

getInfo(info)

ErrorStatus

Gets basic project information and outputs it to the ProjectInfo structure.

save()

ErrorStatus

Saves the project.

run(state, requestId, projectResult)

ErrorStatus

Runs the project. state can be OutputFinished (wait until output Steps finish) or Finished (wait until the whole project finishes).

stopRun()

ErrorStatus

Stops the running project.

getOutput(outputJson)

ErrorStatus

Gets project output data (JSON string).

pinStepOutput(stepPorts)

ErrorStatus

Pins output data of specified Step ports to prevent data loss after project execution finishes.

setRunningChangedCallback(cb)

void

Registers a callback for project running-state changes (triggered when the project starts/ends).

setCaptureFinishedCallback(cb)

void

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
};

ProjectResult Structure

struct ProjectResult {
    std::string projectName; // Project name
    std::string requestId;   // Unique identifier for this run
    int64_t jobId;           // Project run task ID
    std::string outputJson;  // Output data in JSON format (pick point pose and so on)
};

Step Class

Common Methods

Method signature Return value Description

Step(name, projectName)

-

Constructor. Pass in the Step name and the project name it belongs to.

getInfo(info)

ErrorStatus

Gets basic Step information and outputs it to the StepInfo structure.

getPropertiesJson(namesJson, propsJson)

ErrorStatus

Gets Step parameters by a JSON array of property names. namesJson uses a format such as ["threshold"].

setPropertiesJson(propsJson)

ErrorStatus

Sets Step parameters in batch through a JSON string.

run(requestId, stepResult)

ErrorStatus

Runs this Step independently (from the beginning up to this Step).

getOutput(portIndex, stepOutput)

ErrorStatus

Gets Step output data of the specified port (Project::pinStepOutput() must be called first to pin the port).

StepInfo Structure

struct StepInfo {
    std::string guid; // Step GUID
    std::string name; // Step name
};

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

E_SUCCESS

Operation succeeded

E_INTERNAL

Internal error (for example, the project service is not registered)

E_FILEIO

File I/O error (path does not exist, save failed, and so on)

E_INVALID_PARAM

Invalid parameter (empty parameter or incorrect format)

E_NOT_COMPATIBLE

Version incompatible

E_PERMISSION_DENIED

Permission denied

E_SOLUTION_NOT_FOUND

Solution not opened

E_SOLUTION_LOGIN_FAILED

Incorrect solution username or password

E_PROJECT_NOT_FOUND

Project not found

E_PROJECT_RUNNING

Project is running, so this operation cannot be performed

E_PROJECT_EXEC_INSTANCE_OVERFLOW

The number of running project tasks exceeds the upper limit

E_STEP_NOT_FOUND

Step not found

E_STEP_INVALID_PROPERTY

Step property name does not exist, or property value type does not match

E_RECIPE_NAME_NOT_FOUND

Specified parameter recipe name does not exist

E_GLOBAL_VARIABLE_NOT_FOUND

Global variable does not exist

E_GLOBAL_VARIABLE_TYPE_MISMATCH

Global variable type mismatch

Global Functions

Function signature Description

void initialize(configFilePath={})

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.

void uninitialize()

Uninitializes the SDK and releases all resources. This must be called before the program exits.

bool startServer(serverPath={})

Starts the Vision service through the SDK.

bool closeServer()

Closes the Vision service that is started through the SDK.

Is this page helpful?

You can give a feedback in any of the following ways:

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.