This is example source code showing how to use the polling-based image capture functionality of AxsunOCTCapture in a C++ client application (Windows OS).
#include <iostream>
#include <chrono>
#include <thread>
#include <conio.h>
#include <windows.h>
using namespace std::chrono_literals;
class AxsunOCTCapture {
private:
public:
AxsunOCTCapture(int32_t capacity) {
if (
auto retval =
axStartSession(&session_, capacity); retval != AxErr::NO_AxERROR)
throw retval; }
AOChandle operator()() {
if (session_)
return session_;
else throw AxErr::CAPTURE_SESSION_NOT_SETUP; }
};
int main() {
char message[512];
try {
std::cout << "Welcome to the AxsunOCTCapture Example Console Application (C++ version).\n";
AxsunOCTCapture AOC(500);
#ifdef PCIEMODE
#else
#endif
if (
auto retval =
axGetMessage(AOC(), message); retval != AxErr::NO_AxERROR)
throw retval;
std::cout << message << '\n';
if (
auto retval =
axSetupDisplay(AOC(), 0, 0, 0, 1024, 512, 0); retval != AxErr::NO_AxERROR)
throw retval;
#ifdef PCIEMODE
if (
auto retval =
axImagingCntrlPCIe(AOC(), -1); retval != AxErr::NO_AxERROR)
throw retval;
#endif
uint32_t imaging, last_packet, last_frame, last_image, dropped_packets, frames_since_sync;
int32_t counter = 0;
#ifdef _WIN32
while (!_kbhit()) {
MSG msg;
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
#else
while (1) {
#endif // WIN32
if (
auto retval =
axGetStatus(AOC(), &imaging, &last_packet, &last_frame, &last_image, &dropped_packets, &frames_since_sync); retval != AxErr::NO_AxERROR)
throw retval;
if (imaging) {
if (
auto retval =
axGetImageInfo(AOC(), MOST_RECENT_IMAGE, &info); retval != AxErr::NO_AxERROR) {
std::cout << "axGetImageInfo() returned " << static_cast<int32_t>(retval) << " " << message << '\n';
}
else {
prefs.which_window = 1;
retval =
axRequestImage(AOC(), info.image_number, prefs, 0,
nullptr, &info);
if (!(counter % 25)) {
std::cout << "Image number: " << info.image_number << ", Width: " << info.width <<", Dropped Packets: " << dropped_packets;
if (info.force_trig) std::cout << " *** TRIGGER TOO SLOW, FORCE TRIGGERED ***";
if (info.trig_too_fast) std::cout << " *** TRIGGER TOO FAST ***";
std::cout << '\n';
}
}
}
else {
if (!(counter % 50)) {
std::cout << "Imaging is off. Turn on laser emission and set DAQ to Imaging On mode.\n";
}
}
counter++;
std::this_thread::sleep_for(20ms);
}
#ifdef PCIEMODE
if (
auto retval =
axImagingCntrlPCIe(AOC(), 0); retval != AxErr::NO_AxERROR)
throw retval;
#endif
std::this_thread::sleep_for(1s);
}
std::cout << "ERROR: " << message << '\n';
}
catch (...) {
std::cout << "***** UNKNOWN ERROR. Program terminating.\n";
}
std::cout << "Quitting...\n\n";
}