Loading
 
Support Support Home » APIs » XiAPINET

xiAPI.NET


xiAPI.NET stands for XIMEA Application Programming Interface for Dot Net - Microsoft Visual C#.
It is a new common interface for all XIMEA cameras, and represents a simplified version of generic M3API.

Architecture

API a is software interface between the camera operating system driver and application. xiAPI.NET run-time is based on xiCam class implemented in xiAPI.NET.dll calling the m3api.dll.

Installation

To add xiAPI.NET support:
  • Install Microsoft .NET Framework 3.5
  • install XIMEA Windows Software Package to PC or CURRERA.
  • When choosing components make sure: API and Examples are checked.
  • We recommend to use Microsoft Visual Studio 2008 or later version for application development.

Sample

.NET Sample code - See this section with various .NET examples.
After installation of XIMEA Windows Software Package - the sample project is installed in directory XIMEA/Examples/xiAPI.NET.

Here follows a sample code which captures ten images from the camera and saves them as .bmp files.
Exposure time is set 2 ms and gain is set to 5 dB.

// Sample for XIMEA API.NET 

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Drawing;
using xiApi.NET;
namespace xiApi.NET_example
{
class Program
{
  static void Main(string[] args)
  {
    xiCam myCam = new xiCam();

    try
    {
      // Initialize first camera
      myCam.OpenDevice(0);

      // Set device exposure to 2 milliseconds
      int exposure_us = 2000;
      myCam.SetParam(PRM.EXPOSURE, exposure_us);

      // Set device gain to 5 decibels
      float gain_db = 5;
      myCam.SetParam(PRM.GAIN, gain_db);

      // Set image output format to monochrome 8 bit
      myCam.SetParam(PRM.IMAGE_DATA_FORMAT, IMG_FORMAT.MONO8);

      //Start acquisition
      myCam.StartAcquisition();

      // Capture images
      Bitmap myImage;
      int timeout = 1000;
      for (int i = 0; i < 10; i++)
      {
        myCam.GetImage(out myImage, timeout );
        string fName = string.Format("image{0}.bmp", i);
        myImage.Save(fName);
      }
      // Stop acquisition
      myCam.StopAcquisition();
    }

    catch (System.ApplicationException appExc)
    {
      // Show handled error
      Console.WriteLine(appExc.Message);
      System.Console.ReadLine();
      myCam.CloseDevice();
    }

    finally
    {
      myCam.CloseDevice();
    }
  }
} // end of Program
} // end of namespace xiApi.NET_example

Interface

The core of xiAPI.NET are the following functions, which allow to control most of the camera functionality.

// open interface
xiCam.OpenDevice(int DevId);

// set parameter
myCam.SetParam(PRM paramName, int paramVal);
myCam.SetParam(PRM paramName, float paramVal);

// get parameter
myCam.GetParam(PRM paramName, out int paramVal);
myCam.GetParam(PRM paramName, out float paramVal);
myCam.GetParam(PRM paramName, out string paramVal);

// get next image from buffer
myCam.GetImage(out myImage);

// close interface
xiCam.CloseDevice();

Offline Processing

xiAPI.NET allows to process already captured and stored images using Offline Processing. Please read more at xiAPI.NET Offline Processing.

Documentation

xiAPI.NET Manual
Accessing xiAPI.NET pixel data in .NET Bitmap