This example can be found in Development\exposure\exposure.cpp.
This example shows how to adjust exposure settings using the PST SDK. It shows how to change exposure settings based on frame rate and the available exposure range for a certain PST Tracker at a certain frame rate.
#ifdef WIN32
#include <windows.h>
#endif
static void Exithandler(int sig);
#ifdef WIN32
BOOL WINAPI ConsoleHandler(DWORD CEvent)
{
Exithandler(CEvent);
return TRUE;
}
#endif
#include <memory>
#include <iostream>
static bool running = true;
static const uint32_t numberOfSamplesToGrab = 1000;
{
{
static uint32_t samplesGrabbed = 0;
if (samplesGrabbed++ >= numberOfSamplesToGrab)
running = false;
}
} listener;
std::shared_ptr<PSTech::pstsdk::Tracker> pst;
static void Exithandler(int sig)
{
pst->Shutdown();
}
int main(int argc, char *argv[])
{
#ifdef WIN32
SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE);
#else
signal(SIGTERM, Exithandler);
signal(SIGKILL, Exithandler);
signal(SIGQUIT, Exithandler);
signal(SIGINT, Exithandler);
#endif
try
{
pst = std::make_shared<PSTech::pstsdk::Tracker>();
std::cout << "Running PST Server version " << pst->GetVersionInfo() << "\n";
pst->AddTrackerListener(&listener);
pst->Start();
std::cout << "System check: " << (int)pst->Systemcheck() << "\n\n";
std::cout << "***************************\n\n";
pst->SetFramerate(30);
std::cout << "Frame rate set to " << pst->GetFramerate() << "\n";
double min, max;
pst->GetExposureRange(min, max);
std::cout << "Exposure range: " << min << " s - " << max << " s\n";
std::cout << "Set exposure to " << max << "\n";
pst->SetExposure(max);
std::cout << "Check new exposure: " << pst->GetExposure() << " s\n\n";
std::cout << "***************************\n\n";
std::cout << "Set frame rate to 60 Hz\n";
pst->SetFramerate(60);
std::cout << "Frame rate set to " << pst->GetFramerate() << "\n";
std::cout << "Check exposure: " << pst->GetExposure() << " s\n";
pst->GetExposureRange(min, max);
std::cout << "New exposure range " << min << " s - " << max << " s\n\n";
std::cout << "***************************\n\n";
double exposureHalf = min + (max - min) / 2.0;
std::cout << "Set exposute half way: " << exposureHalf << " s\n";
pst->SetExposure(exposureHalf);
std::cout << "New exposure: " << pst->GetExposure() << " s\n\n";
std::cout << "***************************\n\n";
while (running)
{
Sleep(100);
}
}
{
}
pst->Shutdown();
std::cout << "Press enter to continue...\n";
std::cin.get();
return 0;
}