AxsunOCTCapture  3.0.0.0
Captures and buffers streamed imaged data from the Axsun Ethernet/PCIe DAQ and displays or retrieves images to a client application on request.
AxsunOCTCapture_C_example.c

This is example source code showing how to use the image capture functionality of AxsunOCTCapture in a ANSI C client application.

// AxsunOCTCapture_C_example.c : This file contains the 'main' function. Program execution begins and ends there.
//
#include "AxsunOCTCapture.h" // for all AxsunOCTCapture functions, structs, enums, typedefs
#include <stdio.h> // for printf(); not related to AxsunOCTCapture functionality
#include <windows.h> // for loop timer Sleep function; not related to AxsunOCTCapture functionality
#include <conio.h> // for console keyboard interaction; not related to AxsunOCTCapture functionality
#define PCIEMODE // comment this line out for Ethernet interface, leave uncommented for PCIe interface
int main()
{
printf("Welcome to the AxsunOCTCapture Example Console Application (ANSI C version).\n");
// declare local variables
AOChandle session = NULL;
AxErr retval = NO_AxERROR;
char message[512];
uint32_t imaging, last_packet, last_frame, last_image, dropped_packets, frames_since_sync, returned_image_number, required_buffer_size;
int32_t height, width;
AxDataType data_type;
uint8_t force_trig, trig_too_fast;
// create a capture session with 100 MB main image buffer
if (retval = axStartSession(&session, 100)) goto axerror;
// select capture interface for this session
#ifdef PCIEMODE
if (retval = axSelectInterface(session, PCI_EXPRESS)) goto axerror;
#else
if (retval = axSelectInterface(session, GIGABIT_ETHERNET)) goto axerror;
#endif
// print message describing current capture interface status
if (retval = axGetMessage(session, message)) goto axerror;
printf(message); printf("\n");
// setup OpenGL-based rendering
if (retval = axSetupDisplay(session, 0, 0, 0, 1024, 512, NULL)) goto axerror;
// NOTE: before proceeding with this program:
// TURN ON LASER EMISSION using AxsunOCTControl or AxsunOCTControl_LW API, or OCT Host or Hardware Control Tool GUI
// FOR GIGABIT_ETHERNET INTERFACE, need to set DAQ Imaging On mode using AxsunOCTControl or AxsunOCTControl_LW API, or OCT Host or Hardware Control Tool GUI
#ifdef PCIEMODE
// FOR PCIe INTERFACE,
if (retval = axImagingCntrlPCIe(session, -1)) goto axerror; // set DAQ Imaging On mode (live)
if (retval = axPipelineMode(session, EIGHT_BIT)) goto axerror; // set pipeline mode to 8-bit processed data
#endif
int32_t counter = 0;
while (!_kbhit()) { // display loop until a key is pressed (this function in conio.h)
// get Main Image Buffer status
if (retval = axGetStatus(session, &imaging, &last_packet, &last_frame, &last_image, &dropped_packets, &frames_since_sync)) goto axerror;
if (imaging) {
// get image info on most recent image enqueued
if (retval = axGetImageInfoAdv(session, -1, &returned_image_number, &height, &width, &data_type, &required_buffer_size, &force_trig, &trig_too_fast)) {
// print error details
printf("axGetImageInfo() returned %d ", retval);
axGetErrorString(retval, message);
printf(message); printf("\n");
}
else {
// if no errors, display the image
retval = axDisplayImage(session, returned_image_number, &returned_image_number, &height, &width);
// and print some statistics to the console (every 25th iteration)
if (!(counter % 25)) {
printf("Image number: %d, Width: %d, Dropped Packets: %d", returned_image_number, width, dropped_packets);
if (force_trig) printf(" *** TRIGGER TOO SLOW, FORCE TRIGGERED ***");
if (trig_too_fast) printf(" *** TRIGGER TOO FAST ***");
printf("\n");
}
}
}
else {
if (!(counter % 50)) { // print every 50th iteration
printf("Imaging is off. Turn on laser emission and set DAQ to Imaging On mode.\n");
}
}
// increment loop counter
counter++;
// loop timer for approximately 30 fps update rate (this function in windows.h)
Sleep(33);
}
#ifdef PCIEMODE
// FOR PCIe INTERFACE, set DAQ Imaging Off mode (idle)
if (retval = axImagingCntrlPCIe(session, 0)) goto axerror;
#endif
axerror:
// if we got here because of an error, print error code description
if (retval) {
printf("Error %: ", retval);
axGetErrorString(retval, message);
printf(message); printf("\n");
}
printf("Quitting...\n\n");
// stop the capture session
axStopSession(session);
}