7#include <neoapi/neoapi.hpp>
8#include <tabulate/table.hpp>
18 IRSOL_LOG_INFO(
"Configuring camera for manual trigger via software events");
20 {
"AcquisitionMode", {
"SingleFrame"}},
21 {
"TriggerSource", {
"Software"}}});
26 {
"ExposureAuto", {
"Off"}},
27 {
"ExposureMode", {
"Timed"}},
35 auto setPixelFormat =
setParam(
"PixelFormat",
"Mono12");
37 setPixelFormat ==
"Mono12",
"Pixel format is not 'Mono12', but is %s", setPixelFormat.c_str());
55 {
"BinningVerticalMode", {
"Sum"}},
56 {
"BinningHorizontal", {1}},
57 {
"BinningHorizontalMode", {
"Sum"}}});
70 {
"BinningVerticalMode", {
"Average"}},
71 {
"BinningHorizontal", {2}},
72 {
"BinningHorizontalMode", {
"Average"}}});
81 auto info =
m_cam.GetInfo();
82 const auto model = info.GetModelName();
83 const auto camId = info.GetId();
84 const auto serial = info.GetSerialNumber();
85 const auto tlType = info.GetTLType();
86 const auto vendor = info.GetVendorName();
87 const auto usb3VisionGuid = info.GetUSB3VisionGUID();
88 const auto usbPortId = info.GetUSBPortID();
89 const auto gevIpAddress = info.GetGevIpAddress();
90 const auto gevSubnetMask = info.GetGevSubnetMask();
91 const auto gevGateway = info.GetGevGateway();
92 const auto gevMacAddress = info.GetGevMACAddress();
94 tabulate::Table camInfo;
95 camInfo.add_row({
"Name",
"Value"});
96 camInfo.add_row({
"Camera Model Name", model.c_str()});
97 camInfo.add_row({
"Camera ID", camId.c_str()});
98 camInfo.add_row({
"Camera Serial Number", serial.c_str()});
99 camInfo.add_row({
"Camera Transport Layer Type", tlType.c_str()});
100 camInfo.add_row({
"Camera Vendor Name", vendor.c_str()});
101 camInfo.add_row({
"Camera USB3 Vision GUID", usb3VisionGuid.c_str()});
102 camInfo.add_row({
"Camera USB Port ID", usbPortId.c_str()});
103 camInfo.add_row({
"Camera GEV IP Address", gevIpAddress.c_str()});
104 camInfo.add_row({
"Camera GEV Subnet Mask", gevSubnetMask.c_str()});
105 camInfo.add_row({
"Camera GEV Gateway", gevGateway.c_str()});
106 camInfo.add_row({
"Camera GEV MAC Address", gevMacAddress.c_str()});
107 camInfo.add_row({
"Is connectable", info.IsConnectable() ?
"true" :
"false"});
109 camInfo.column(0).format().font_align(tabulate::FontAlign::right);
110 return camInfo.str();
116 static const char*
const FEATURE_NAMES[] = {
"AcquisitionMode",
117 "BinningHorizontalMode",
119 "BinningVerticalMode",
121 "DeviceTemperatureStatus",
141 tabulate::Table featureInfo;
142 featureInfo.add_row({
"Feature",
"Value"});
144 for(
const auto featureName : FEATURE_NAMES) {
145 std::string featureValue =
getParam(featureName);
146 featureInfo.add_row({featureName, featureValue});
148 featureInfo.column(0).format().font_align(tabulate::FontAlign::right);
149 return featureInfo.str();
162 int maxWidth = getParam<int>(
"WidthMax");
163 int maxHeight = getParam<int>(
"HeightMax");
166 {{
"Width", {maxWidth}}, {
"Height", {maxHeight}}, {
"OffsetX", {0}}, {
"OffsetY", {0}}});
172 auto exposureInMicroSeconds = getParam<int64_t>(
"ExposureTime");
173 return std::chrono::microseconds(exposureInMicroSeconds);
180 auto exposureInMicroseconds =
181 std::chrono::duration_cast<std::chrono::microseconds>(exposure).count();
182 auto setExposureInMicroseconds =
183 setParam(
"ExposureTime",
static_cast<int64_t
>(exposureInMicroseconds));
193 NeoAPI::NeoString neoParam(param.c_str());
194 auto feature =
m_cam.GetFeature(neoParam);
195 return NeoAPI::NeoString(feature).c_str();
196 }
catch(
const std::exception& e) {
206 std::scoped_lock<std::mutex> lock(
m_camMutex);
207 for(
const auto& [param,
value] : params) {
209 [¶m,
this](
auto&& arg) {
210 using U = std::decay_t<
decltype(arg)>;
212 setParamNonThreadSafe<U>(param, arg);
223 NeoAPI::NeoString neoParam(param.c_str());
224 auto feature =
m_cam.GetFeature(neoParam);
226 }
catch(
const std::exception& e) {
227 IRSOL_LOG_ERROR(
"Failed to trigger camera with parameter '{}': {}", param, e.what());
234 std::scoped_lock<std::mutex> lock(
m_camMutex);
242 if(timeout.has_value()) {
244 "User provided a custom timeout of capturing camera of {}",
246 actualTimeout = *timeout;
252 uint32_t timeoutMs =
static_cast<uint32_t
>(
253 std::chrono::duration_cast<std::chrono::milliseconds>(actualTimeout).count());
254 auto image =
m_cam.GetImage(timeoutMs);
255 if(image.IsEmpty() || image.GetSize() == 0) {
Assertion macros and utilities based on the PPK_ASSERT library.
High-level wrapper around the NeoAPI camera for synchronized access.
std::string cameraStatusAsString() const
Get current camera status.
image_t captureImage(std::optional< irsol::types::duration_t > timeout=std::nullopt)
Capture a single image from the camera.
std::mutex m_camMutex
Mutex to protect access to camera parameters and image acquisition.
void trigger(const std::string ¶m)
Trigger a camera feature (e.g., software trigger).
static Interface HalfResolution()
Factory method to create a camera interface using half sensor resolution.
T setParam(const std::string ¶m, T value)
Set a camera parameter of arbitrary type T.
T getParam(const std::string ¶m) const
Retrieve a camera parameter of arbitrary type T.
NeoAPI::Image image_t
Alias for the image type returned by the NeoAPI.
NeoAPI::Cam & getNeoCam()
Access the underlying NeoAPI camera instance.
std::string cameraInfoAsString() const
Get human-readable camera information.
irsol::types::duration_t setExposure(irsol::types::duration_t exposure)
Set the exposure time of the camera.
Interface(NeoAPI::Cam cam=irsol::utils::loadDefaultCamera())
Constructs the Interface by loading the default camera.
static constexpr irsol::types::duration_t DEFAULT_EXPOSURE_TIME
Default exposure time (2 milliseconds) used to initialize the camera.
Interface & operator=(Interface &&other)
Move assignment operator.
void resetSensorArea()
Reset the sensor area to the full sensor dimensions.
void setMultiParam(const std::unordered_map< std::string, camera_param_t > ¶ms)
Set multiple parameters in one call.
static Interface FullResolution()
Factory method to create a camera interface using full sensor resolution.
NeoAPI::Cam m_cam
Internal camera instance from NeoAPI.
irsol::types::duration_t getExposure() const
Get the current exposure time from the camera.
irsol::types::duration_t m_CachedExposureTime
#define IRSOL_ASSERT_ERROR
Error-level assertion macro.
#define IRSOL_ASSERT_FATAL
Fatal-level assertion macro.
#define IRSOL_LOG_INFO(...)
Logs an info-level message using the default logger.
#define IRSOL_LOG_ERROR(...)
Logs an error-level message using the default logger.
#define IRSOL_LOG_WARN(...)
Logs a warning-level message using the default logger.
#define IRSOL_LOG_DEBUG(...)
Logs a debug-level message using the default logger.
#define IRSOL_LOG_TRACE(...)
Logs a trace-level message using the default logger.
High-level wrapper around NeoAPI camera control for the irsol library.
Logging utilities and configuration for the irsol library.
clock_t::duration duration_t
Alias for a duration of time as defined by clock_t.
NeoAPI::Cam loadDefaultCamera()
Loads the default camera device.
std::string durationToString(irsol::types::duration_t dr)
Converts a duration to a human-readable string.
General utility functions used throughout the irsol library.