7#ifndef nnReconstructor_hpp
8#define nnReconstructor_hpp
11#include <cuda_runtime_api.h>
17#include <mx/improc/eigenCube.hpp>
18#include <mx/improc/eigenImage.hpp>
20#include "../../libMagAOX/libMagAOX.hpp"
21#include "../../magaox_git_version.h"
23using namespace nvinfer1;
28 if (
severity <= Severity::kWARNING) {
29 std::cout << msg << std::endl;
135 mx::app::appConfigurator &
_config );
179 std::ifstream file(
filename, std::ios::binary);
181 std::cout <<
"Error opening " <<
filename << std::endl;
184 file.seekg(0, std::ios::end);
187 file.seekg(0, std::ios::beg);
197 std::cout <<
"Failed to createInferRuntime\n";
202 std::cout <<
"Failed to deserialize CUDA engine.\n";
204 std::cout <<
"Deserialized CUDA engine.\n";
211 std::cout <<
"Number of IO Tensors: " <<
numIOTensors << std::endl;
225 std::cout <<
"Tensor input dimensions: " <<
inputC <<
"x" <<
inputH <<
"x" <<
inputW << std::endl;
226 std::cout <<
"Tensor output dimensions: " <<
outputSize << std::endl;
277 std::cout <<
"setupConfig()" << std::endl;
280 config.add(
"parameters.dataDirs",
282 "parameters.dataDirs",
288 "The path to the directory with the onnx model." );
290 config.add(
"parameters.engineDirs",
292 "parameters.engineDirs",
298 "The path to the directory with the TRT engine." );
300 config.add(
"parameters.onnxFileName",
302 "parameters.onnxFileName",
308 "Name of the Neural Net ONNX file" );
310 config.add(
"parameters.engineName",
312 "parameters.engineName",
318 "Name of the TRT engine." );
319 config.add(
"parameters.rebuildEngine",
321 "parameters.rebuildEngine",
327 "If true the engine will be rebuild." );
329 config.add(
"parameters.imageNorm",
331 "parameters.imageNorm",
337 "Normalization term for the preprocessed images." );
339 config.add(
"parameters.modalNorm",
341 "parameters.modalNorm",
347 "Normalization term for the modal coefficients." );
349 config.add(
"parameters.channel",
351 "parameters.channel",
357 "The output channel." );
359 config.add(
"parameters.m_pupPix",
361 "parameters.m_pupPix",
367 "Number of pixels across a PWFS pupil." );
369 config.add(
"parameters.pup_offset1_x",
371 "parameters.pup_offset1_x",
377 "Horizontal offset to the top left of the closest set op PWFS pupils." );
379 config.add(
"parameters.pup_offset1_y",
381 "parameters.pup_offset1_y",
387 "Vertical offset to the top left of the closest set op PWFS pupils." );
389 config.add(
"parameters.pup_offset2_x",
391 "parameters.pup_offset2_x",
397 "Horizontal offset to the top left of the furthest set op PWFS pupils." );
399 config.add(
"parameters.pup_offset2_y",
401 "parameters.pup_offset2_y",
407 "Vertical offset to the top left of the furthest set op PWFS pupils." );
413 std::cout <<
"loadConfigImpl()" << std::endl;
434 std::cout <<
"Debug configuration loading: " << std::endl;
435 std::cout <<
"dataDirs: " <<
dataDirs << std::endl;
436 std::cout <<
"engineDirs: " <<
engineDirs << std::endl;
437 std::cout <<
"onnxFileName: " <<
onnxFileName << std::endl;
438 std::cout <<
"engineName: " <<
engineName << std::endl;
439 std::cout <<
"rebuildEngine: " <<
rebuildEngine << std::endl;
440 std::cout <<
"imageNorm: " <<
imageNorm << std::endl;
441 std::cout <<
"modalNorm: " <<
modalNorm << std::endl;
444 std::cout <<
"m_pupPix: " <<
m_pupPix << std::endl;
445 std::cout <<
"pup_offset1_x: " <<
pup_offset1_x << std::endl;
446 std::cout <<
"pup_offset1_y: " <<
pup_offset1_y << std::endl;
447 std::cout <<
"pup_offset2_x: " <<
pup_offset2_x << std::endl;
448 std::cout <<
"pup_offset2_y: " <<
pup_offset2_y << std::endl;
512 std::cout <<
"allocate()" << std::endl;
513 static_cast<void>(
dummy );
525 std::cout <<
"Close shmims" << std::endl;
531 std::cout <<
"Open shmims" << std::endl;
543 std::cout <<
"Done!" << std::endl;
563 static_cast<void>(
dummy );
595 std::cout <<
"HOWDY" << std::endl;
void log(Severity severity, const char *msg) noexcept override
The base-class for MagAO-X applications.
stateCodes::stateCodeT state()
Get the current state code.
static int log(const typename logT::messageT &msg, logPrioT level=logPrio::LOG_DEFAULT)
Make a log entry.
std::mutex m_indiMutex
Mutex for locking INDI communications.
int appStartup()
Startup function.
uint32_t m_width
The width of the images in the stream.
int setupConfig(mx::app::appConfigurator &config)
Setup the configuration system.
int updateINDI()
Update the INDI properties for this device controller.
int appLogic()
Checks the shmimMonitor thread.
uint32_t m_height
The height of the images in the stream.
int appShutdown()
Shuts down the shmimMonitor thread.
int loadConfig(mx::app::appConfigurator &config)
load the configuration system results
float realT
Floating point type in which to do all calculations.
void create_engine_context()
size_t m_pwfsWidth
The width of the image.
void cleanup_engine_memory()
void cleanup_engine_context()
friend class nnReconstructor_test
unsigned long frame_counter
virtual int appShutdown()
Shutdown the app.
size_t m_pwfsHeight
The height of the image.
virtual void setupConfig()
nnReconstructor()
Default c'tor.
int loadConfigImpl(mx::app::appConfigurator &_config)
Implementation of loadConfig logic, separated for testing.
int allocate(const dev::shmimT &dummy)
uint32_t m_modevalHeight
The height of the shmim.
uint8_t m_pwfsDataType
The ImageStreamIO type code.
virtual void loadConfig()
virtual int appStartup()
Startup function.
size_t m_modevalTypeSize
The size of the type, in bytes.
std::string m_modevalChannel
IExecutionContext * context
virtual int appLogic()
Implementation of the FSM for nnReconstructor.
void load_engine(const std::string filename)
int processImage(void *curr_src, const dev::shmimT &dummy)
size_t m_pwfsTypeSize
The size of the type, in bytes.
void prepare_engine_memory()
uint8_t m_modevalDataType
The ImageStreamIO type code.
std::vector< char > engineData
~nnReconstructor() noexcept
D'tor, declared and defined for noexcept.
uint32_t m_modevalWidth
The width of the shmim.
dev::shmimMonitor< nnReconstructor > shmimMonitorT
@ OPERATING
The device is operating, other than homing.
std::unique_lock< std::mutex > lock(m_indiMutex)
static constexpr logPrioT LOG_NOTICE
A normal but significant condition.