MathWorks® is the leading developer and supplier of software for technical computing and Model-Based Design.
The MATLAB® product family provides a flexible environment for solving complex imaging problems in a wide range of applications including scientific imaging, medicine and biotechnology, aerospace and defense, security, and machine vision.
Image Acquisition Toolbox™ enables users to acquire images and video directly from cameras into MATLAB and Simulink. Image Processing Toolbox™ and Computer Vision System Toolbox™ products provide algorithms and tools for building image processing, video processing, and computer vision applications.
Recent API Software Packages are fully supported and tested with Matlab versions released in the last 2 years. The backward compatibility has not been tested for all features and camera models in older Matlab versions.
export GENICAM_GENTL64_PATH=/opt/XIMEA/lib/
" to your ~/.bashrc file to enable GenTLGENICAM_GENTL64_PATH=/opt/XIMEA/lib/ ./Matlab
*The Mathworks Image Acquisition Toolbox Support Package for GenICam Interface is currently not compatible with the GenICam interface on macOS. As a result, XIMEA cameras cannot be used with MATLAB on macOS.
For more information or assistance, please contact MathWorks directly.
The Image Acquisition Tool is a graphical interface for rapid hardware configuration, image acquisition and live video previewing.
The preview window, as shown here, reflects adjustments made to the XIMEA camera properties and provides a quick start in the development of image processing systems.
The toolbox has a comprehensive set of functions for command line programming of tasks such as device connection, image data acquisition, to adjust acquisition parameters and more.
The code below shows how to connect to a XIMEA camera to acquire data:
% Access an image acquisition device vidobj = videoinput('gentl', 1, 'BGRA8Packed'); src=getselectedsource(vidobj); src.AEAGEnable = 'True'; % List the video input object's configurable properties.vidobj.FramesPerTrigger = 50; % Open the preview window preview(vidobj); % Data acquisition start(vidobj); stop(vidobj); % Cleanup the image acquisition object and the MATLAB® workspace delete(vidobj); clear vidobj;
Visit the Image Acquisition Toolbox support page.
\XIMEA\API\xiAPI
to the folder of the .NET version you are using (e.g. to \XIMEA\API\xiAPI.NET.Framework.4.7.2
)\XIMEA\API\xiAPI.NET.Framework.4.7.2
like in the following sample)After importing the xiAPI.NET shared library you can implement an application with the xiAPI.NET API.
Here is a xiAPI.NET example for Matlab. Path to xiApi.NET depends on what .NET version you are using.
More extensive sample showing work with RGB or 16-bit image formats can be downloaded here: xiAPINET_Matlab_sample.m.
imaqreset; NET.addAssembly('C:\XIMEA\API\xiAPI.NET.Framework.4.7.2\xiApi.NETX64.dll'); % Path to the xiApi.NET library myCam=xiApi.NET.xiCam; % Initialize camera OpenDevice(myCam,0); myCam.SetParam(xiApi.NET.PRM.EXPOSURE ,10000); % Set exposure time myCam.SetParam(xiApi.NET.PRM.IMAGE_DATA_FORMAT, xiApi.NET.IMG_FORMAT.RAW8); % Set image format StartAcquisition(myCam); H=myCam.GetParam(xiApi.NET.PRM.HEIGHT); W=myCam.GetParam(xiApi.NET.PRM.WIDTH); myCam.SetParam(xiApi.NET.PRM.BUFFER_POLICY , xiApi.NET.BUFF_POLICY.SAFE); NetArray=NET.createArray('System.Byte',W*H); GetImageByteArray(myCam,NetArray,1000); img=transpose(reshape(uint8(NetArray),W,H)); % img is ready to process as MATLAB uint8 image matrix imshow(img); StopAcquisition(myCam); CloseDevice(myCam); delete(myCam); clear myCam;