Create a MATLAB “Hello World” Application With Reference to Zivid .NET API

Introduction

This tutorial shows how to create a MATLAB application for Zivid using our Zivid .NET API reference.

Requirements

Note

The MATLAB version tested with Zivid cameras is R2019a.

Instructions

Step by step instructions to create and run your script are provided with screenshots below.

Create a new project

Launch MATLAB, then click NewFunction.

Copy the following code and save it as zividApplication.m

function application = zividApplication(folder)

    if nargin < 1
        folder = [getenv('ZIVID_INSTALL_FOLDER'),'\bin'];
    end

    global ZIVID_APPLICATION

    if isempty(ZIVID_APPLICATION)
        addpath(folder);
        NET.addAssembly([folder,'\ZividCoreNET.dll']);
        NET.addAssembly([folder,'\ZividVisualizationNET.dll']);
        import Zivid.*;
        import Zivid.NET.CaptureAssistant.*;
        import Zivid.NET.HandEye.*;
        ZIVID_APPLICATION = Zivid.NET.Application;
    end

    application = ZIVID_APPLICATION;

end

Click NewScript, then copy the following code and save it as ZividHelloWorld.m

%% Create Zivid application
zivid = zividApplication;

%% Connect to camera
cam = zivid.ConnectCamera;
disp('Hello World!');

%% Disconnect from camera
camera.Disconnect;

Run the program

Press F5 key on your keyboard to run the program (ZividHelloWorld.m).

MATLAB Hello World script

To continue developing with Zivid and MATLAB, check out Zivid MATLAB Samples.