This sample program, PXR_ROI_CS, illustrates the use of the Imagenation PXR800 with
the new programming language C#. It shows you how to use the Region Of Interest (ROI) controls in the PXR800.
Setting the ROI in an image is the same as cropping the image. The PXR800 gives you the ability to specify not only the size of the
image but also the upper left hand corner. It lets you define the rectangular portion of the image you are interested in and only
DMA that much data to your buffer.
The ROI functions are:
GetROI()
SetROI()
You may have already noticed that SetROI() is used in all of the samples in the function ResetPXR() to
set the initial Region Of Interest as follows:
// set the region of interest, ROI, to a default value
dwROILeft = 0;
dwROITop = 0;
dwROIWidth = dwImageX;
dwROIHeight = dwImageY;
PXR.SetROI(hFG,
dwROILeft,
dwROITop,
dwROIWidth,
dwROIHeight,
IW_WAIT);
The values for dwROILeft and dwROIWidth must be divisible by 4.
The values for dwROITop and dwROIHeight must be divisible by 2.
Whether you use our sample as a starting point or not, you will need the interface file contained in
this package if you want to work in C#.
This is what you need for C# development:
In order to develop a C# application for the PXR800, you
need to have an interface file that redefines all of the PXR800 functions and links the new definitions
to the existing PXR800 DLLs.
This is what we are giving you in this package:
The interface file containing the following three types of data:
| 1. | The DLL function redefinitions - Redefines all the functions that
are explained in the the PXR800 Frame Grabber User's Guide and contained in the PXR800 DLLs. |
2. | Global variable definitions – A set of common static variable names used by the PXR800 API. |
3. | Classes - Some useful class functions for initializing libraries, displaying images, and reading and writing BMP files.
You may want to use these functions as your beginning class library to avoid building one from scratch.
|
A sample C# program that illustrates the following concepts:
| 1. | Library initialization - Proper initialization of the PXR800 libraries. |
2. | Display - Done by getting a pointer to the acquired image using the
PXR800 FrameBuffer() function and then creating a bitmap by calling the Bitmap() function. |
3. | Continuous image update - Uses a timer to cause the image window to be continuously updated.
|
4. | Set ROI - Set the Region Of Interest (ROI) for the displayed frame.
|
This is how you use it:
Download this package into a directory where you want to work.
Unzip it into that same directory. Build the sample and execute it to make sure it works. Then modify it for your
application. If you are building a new C# application, you might want to start with our sample code and
classes. If you already have an application that you are porting, you may just want to use our interface
file.