NET Sample code¶
Look up table (LUT) example¶
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
{
myCam.OpenDevice(0);
int exposure_us = 2000;
myCam.SetParam(PRM.EXPOSURE, exposure_us);
float gain_db = 5;
myCam.SetParam(PRM.GAIN, gain_db);
myCam.SetParam(PRM.IMAGE_DATA_FORMAT, IMG_FORMAT.MONO8);
int maxIndex, minIndex;
int maxValue, minValue;
maxIndex = myCam.GetParamInt(PRM.LUT_INDEX_MAX);
minIndex = myCam.GetParamInt(PRM.LUT_INDEX_MIN);
maxValue = myCam.GetParamInt(PRM.LUT_VALUE_MAX);
minValue = myCam.GetParamInt(PRM.LUT_VALUE_MIN);
Console.WriteLine("max index {0} \n", maxIndex);
Console.WriteLine("max value {0} \n", maxValue);
for (int i = 0; i < maxIndex; i++)
{
myCam.SetParam(PRM.LUT_INDEX, i);
myCam.SetParam(PRM.LUT_VALUE, maxValue - i);
}
myCam.SetParam(PRM.LUT_EN, 1);
myCam.StartAcquisition();
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);
}
myCam.StopAcquisition();
}
catch (System.ApplicationException appExc)
{
Console.WriteLine(appExc.Message);
System.Console.ReadLine();
myCam.CloseDevice();
}
finally
{
myCam.CloseDevice();
}
}
}
}