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 xiAPI.
API a is the 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 xiapi32.dll on 32bit Windows operating systems and xiAPI.NETX64.dll calling the xiapi64.dll on 64bit Windows operating systems.
.NET Sample code - See this section with various .NET examples.
After installation of the XIMEA Windows Software Package - the sample project is installed in the directory XIMEA/Examples/xiAPI.NET.
Here follows a sample code that 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
The core of xiAPI.NET are the following functions, which allow the control of 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();
xiAPI.NET allows to process of already captured and stored images using Offline Processing.
Please read more at xiAPI.NET Offline Processing.
xiAPI.NET Manual
Accessing xiAPI.NET pixel data in .NET Bitmap