7 #include "PlusConfigure.h" 11 #include "igtlOSUtil.h" 12 #if CV_MAJOR_VERSION > 3 13 #include "opencv2/calib3d.hpp" 15 #include "opencv2/imgproc.hpp" 17 #include "opencv2/imgcodecs.hpp" 38 os << indent <<
"Shutter: " <<
Shutter << std::endl;
39 os << indent <<
"ExposureTime: " <<
ExposureTime << std::endl;
41 os << indent <<
"HSSpeed: " <<
HSSpeed[0] <<
HSSpeed[1] << std::endl;
42 os << indent <<
"VSSpeedIndex: " <<
VSSpeedIndex << std::endl;
46 os << indent <<
"ReadMode: " <<
m_ReadMode << std::endl;
47 os << indent <<
"TriggerMode: " <<
m_TriggerMode << std::endl;
49 os << indent <<
"CoolerMode: " <<
CoolerMode << std::endl;
65 LOG_TRACE(
"vtkPlusAndorVideoSource::ReadConfiguration");
68 long totalCameras = 0;
70 unsigned availableCamerasResult =
checkStatus(GetAvailableCameras(&totalCameras),
"GetAvailableCameras");
71 if(availableCamerasResult == DRV_SUCCESS)
75 LOG_ERROR(
"Unable to find any Andor cameras devices installed.");
85 const char * shutterString = deviceConfig->GetAttribute(
"Shutter");
88 Shutter = static_cast<vtkPlusAndorVideoSource::ShutterMode>(std::atoi(shutterString));
92 Shutter = vtkPlusAndorVideoSource::ShutterMode::FullyAuto;
95 const char * acquisitionModeString = deviceConfig->GetAttribute(
"AcquisitionMode");
96 if(acquisitionModeString)
98 m_AcquisitionMode = static_cast<vtkPlusAndorVideoSource::AcquisitionMode>(std::atoi(acquisitionModeString));
105 const char * readModeString = deviceConfig->GetAttribute(
"ReadMode");
108 m_ReadMode = static_cast<vtkPlusAndorVideoSource::ReadMode>(std::atoi(readModeString));
112 m_ReadMode = vtkPlusAndorVideoSource::ReadMode::Image;
115 const char * triggerModeString = deviceConfig->GetAttribute(
"TriggerMode");
116 if(triggerModeString)
118 m_TriggerMode = static_cast<vtkPlusAndorVideoSource::TriggerMode>(std::atoi(triggerModeString));
122 m_TriggerMode = vtkPlusAndorVideoSource::TriggerMode::Internal;
125 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
float,
ExposureTime, deviceConfig);
126 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
int,
PreAmpGainIndex, deviceConfig);
127 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
int,
CoolerMode, deviceConfig);
128 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
int,
CoolTemperature, deviceConfig);
129 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
int,
SafeTemperature, deviceConfig);
130 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
int,
VSSpeedIndex, deviceConfig);
131 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
int,
HorizontalBins, deviceConfig);
132 XML_READ_SCALAR_ATTRIBUTE_OPTIONAL(
int,
VerticalBins, deviceConfig);
141 deviceConfig->GetVectorAttribute(
"HSSpeed", 2,
HSSpeed);
142 deviceConfig->GetVectorAttribute(
"OutputSpacing", 3,
OutputSpacing);
163 deviceConfig->SetIntAttribute(
"Shutter", this->
Shutter);
164 deviceConfig->SetFloatAttribute(
"ExposureTime", this->
ExposureTime);
165 deviceConfig->SetIntAttribute(
"PreAmpGainIndex", this->
PreAmpGainIndex);
167 deviceConfig->SetIntAttribute(
"ReadMode", this->
m_ReadMode);
168 deviceConfig->SetIntAttribute(
"TriggerMode", this->
m_TriggerMode);
169 deviceConfig->SetIntAttribute(
"CoolerMode", this->
CoolerMode);
170 deviceConfig->SetIntAttribute(
"CoolTemperature", this->
CoolTemperature);
171 deviceConfig->SetIntAttribute(
"SafeTemperature", this->
SafeTemperature);
172 deviceConfig->SetIntAttribute(
"VSSpeedIndex", this->
VSSpeedIndex);
173 deviceConfig->SetIntAttribute(
"HorizontalBins", this->
HorizontalBins);
174 deviceConfig->SetIntAttribute(
"VerticalBins", this->
VerticalBins);
178 deviceConfig->SetVectorAttribute(
"HSSpeed", 2,
HSSpeed);
179 deviceConfig->SetVectorAttribute(
"OutputSpacing", 3,
OutputSpacing);
182 deviceConfig->SetAttribute(
"FlatCorrection",
flatCorrection.c_str());
198 LOG_ERROR(
"No output channels defined for vtkPlusAndorVideoSource. Cannot proceed.");
209 std::ostringstream versionString;
211 char SDKVersion[256];
212 checkStatus(GetVersionInfo(AT_SDKVersion, SDKVersion,
sizeof(SDKVersion)),
"GetVersionInfo");
213 versionString <<
"Andor SDK version: " << SDKVersion << std::ends;
215 return versionString.str();
240 long totalCameras = 0;
242 unsigned availableCamerasResult =
checkStatus(GetAvailableCameras(&totalCameras),
"GetAvailableCameras");
243 if(availableCamerasResult == DRV_SUCCESS)
245 if(totalCameras == 0)
247 LOG_ERROR(
"Unable to find any Andor cameras devices installed.");
252 unsigned initializeResult =
checkStatus(Initialize(
""),
"Initialize");
253 if(initializeResult != DRV_SUCCESS)
258 char headModel[_MAX_PATH];
259 unsigned headModelResult =
checkStatus(GetHeadModel(headModel),
"GetHeadModel");
260 if(headModelResult == DRV_SUCCESS)
262 LOG_INFO(
"Andor Camera Model: " << headModel);
266 unsigned cameraSNResult =
checkStatus(GetCameraSerialNumber(&serialNumber),
"GetCameraSerialNumber");
267 if(cameraSNResult == DRV_SUCCESS)
269 LOG_INFO(
"Andor Camera Serial Number: " << serialNumber);
274 int MinTemp, MaxTemp;
275 unsigned result =
checkStatus(GetTemperatureRange(&MinTemp, &MaxTemp),
"GetTemperatureRange");
276 if(result == DRV_SUCCESS)
278 LOG_INFO(
"The temperature range for the connected Andor Camera is: " << MinTemp <<
" and " << MaxTemp);
283 this->SafeTemperature = MaxTemp;
287 LOG_ERROR(
"Requested temperature for Andor camera is out of range");
309 for(
unsigned i = 0;
i <
port.size();
i++)
311 port[
i]->SetPixelType(VTK_UNSIGNED_SHORT);
312 port[
i]->SetImageType(US_IMG_BRIGHTNESS);
313 port[
i]->SetOutputImageOrientation(US_IMG_ORIENT_MF);
314 port[
i]->SetInputImageOrientation(US_IMG_ORIENT_MF);
317 LOG_INFO(
"Andor source initialized. ID: " <<
port[
i]->GetId());
324 LOG_TRACE(
"vtkPlusAndorVideoSource::InternalConnect");
327 LOG_ERROR(
"Andor camera failed to initialize.");
341 LOG_ERROR(
"Standard data sources are not defined, and unable to retrieve the video source in the capturing device.");
344 BLIRaw.push_back(aSource);
360 LOG_DEBUG(
"Disconnecting from Andor");
382 checkStatus(FreeInternalMemory(),
"FreeInternalMemory");
384 unsigned result =
checkStatus(ShutDown(),
"ShutDown");
385 if(result == DRV_SUCCESS)
387 LOG_INFO(
"Andor camera shut down successfully.");
415 for(
unsigned i = 0;
i <
BLIRaw.size();
i++)
436 std::ostringstream spacingStream;
437 spacingStream << this->
OutputSpacing[0] * horizontalBins <<
" ";
438 spacingStream << this->
OutputSpacing[1] * verticalBins <<
" ";
441 this->
CustomFields[
"ElementSpacing"].first = FRAMEFIELD_FORCE_SERVER_SEND;
442 this->
CustomFields[
"ElementSpacing"].second = spacingStream.str();
443 LOG_DEBUG(
"Adjusted spacing: " << spacingStream.str());
449 this->
CustomFields[
"ExposureTime"].first = FRAMEFIELD_FORCE_SERVER_SEND;
451 this->
CustomFields[
"HorizontalBins"].first = FRAMEFIELD_FORCE_SERVER_SEND;
453 this->
CustomFields[
"VerticalBins"].first = FRAMEFIELD_FORCE_SERVER_SEND;
457 this->
CustomFields[
"Temperature"].first = FRAMEFIELD_FORCE_SERVER_SEND;
460 std::ostringstream transformStream;
461 float transformValue;
462 for(
unsigned i = 0;
i < 15;
i++)
469 this->
CustomFields[
"ImageToReferenceTransform"].first = FRAMEFIELD_FORCE_SERVER_SEND;
470 this->
CustomFields[
"ImageToReferenceTransform"].second = transformStream.str();
471 this->
CustomFields[
"ImageToReferenceTransformStatus"].first = FRAMEFIELD_FORCE_SERVER_SEND;
472 this->
CustomFields[
"ImageToReferenceTransformStatus"].second =
"OK";
485 std::vector<double> spacing = { 0.0, 0.0, 1.0 };
558 checkStatus(StartAcquisition(),
"StartAcquisition");
559 unsigned result =
checkStatus(::WaitForAcquisition(),
"WaitForAcquisition");
560 if(result != DRV_SUCCESS)
562 LOG_ERROR(
"Acquisition failed or cancelled.");
565 this->
currentTime = vtkIGSIOAccurateTimer::GetSystemTime();
579 for(
unsigned i = 0;
i < ds.size();
i++)
584 1, US_IMG_BRIGHTNESS, 0,
591 LOG_WARNING(
"Error adding item to AndorCamera video source " << ds[
i]->GetSourceId());
595 LOG_INFO(
"Success adding item to AndorCamera video source " << ds[
i]->GetSourceId());
603 std::vector<cv::Point> badIndicesXY;
606 std::map<uint, int> badPixelCount;
607 for (
int i = 0;
i < badIndicesXY.size();
i++)
609 uint resolutionCellIndexX = badIndicesXY[
i].x / binning;
610 uint resolutionCellIndexY = badIndicesXY[
i].y / binning;
611 uint resolutionCellIndex =
frameSize[1] * resolutionCellIndexY + resolutionCellIndexX;
612 badPixelCount[resolutionCellIndex] += 1;
615 std::vector<uint> resolutionCellsToCorrect;
616 for (
auto const& bpc : badPixelCount)
618 if (binning * binning / bpc.second < 5)
620 resolutionCellsToCorrect.push_back(bpc.first);
634 std::vector<uint> resolutionCellsToCorrect =
cellsToCorrect[binning];
635 uint resolutionCellIndexX, resolutionCellIndexY;
636 std::vector<uint> valuesForMedian, correctedCells;
640 int numCellsToCorrect = resolutionCellsToCorrect.size();
641 for (uint cell : resolutionCellsToCorrect)
644 resolutionCellIndexY = cell /
frameSize[0];
645 startX = resolutionCellIndexX - 1;
646 endX = resolutionCellIndexX + 1;
647 startY = resolutionCellIndexY - 1;
648 endY = resolutionCellIndexY + 1;
649 if (startX < 0) { startX = 0; }
650 if (startY < 0) { startY = 0; }
654 for (uint
x = startX;
x <= endX;
x++)
656 for (uint
y = startY;
y <= endY;
y++)
658 if (std::find(resolutionCellsToCorrect.begin(), resolutionCellsToCorrect.end(),
frameSize[0] *
y +
x) != resolutionCellsToCorrect.end())
660 if (std::find(correctedCells.begin(), correctedCells.end(),
frameSize[0] *
y +
x) != correctedCells.end())
662 valuesForMedian.push_back(cvIMG.at<ushort>(
y,
x));
667 valuesForMedian.push_back(cvIMG.at<ushort>(
y,
x));
672 sort(valuesForMedian.begin(), valuesForMedian.end());
673 if (valuesForMedian.size() % 2 == 0)
675 medianValue = (valuesForMedian[valuesForMedian.size() / 2 - 1] + valuesForMedian[valuesForMedian.size() / 2]) / 2;
679 medianValue = valuesForMedian[valuesForMedian.size() / 2];
682 cvIMG.at<ushort>(resolutionCellIndexY, resolutionCellIndexX) = medianValue;
683 correctedCells.push_back(cell);
684 valuesForMedian.clear();
697 cv::Mat medianImage, diffImage, medianPixels;
700 cv::medianBlur(floatImage, medianImage, kernelSize);
701 cv::subtract(floatImage, medianImage, diffImage);
702 cv::Mat cosmicInd = (diffImage > 50) & (diffImage > 4 * medianImage);
703 cv::Mat notCosmicInd = ~cosmicInd;
704 cosmicInd.convertTo(cosmicInd, floatImage.type());
705 notCosmicInd.convertTo(notCosmicInd, floatImage.type());
710 medianImage.convertTo(medianImage, floatImage.type());
711 cv::multiply(notCosmicInd, floatImage, floatImage);
712 cv::multiply(cosmicInd, medianImage, medianPixels);
713 floatImage += medianPixels;
721 LOG_INFO(
"Applied bad pixel correction");
724 cvIMG.convertTo(floatImage, CV_32FC1);
730 <<
" does not match the current frame size " <<
frameSize[0] <<
" x " <<
frameSize[1]);
735 LOG_INFO(
"Applied constant bias+dark correction");
741 LOG_INFO(
"Applied cosmic ray correction");
746 LOG_INFO(
"Applied lens distortion correction");
756 <<
" does not match the current frame size " <<
frameSize[0] <<
" x " <<
frameSize[1]);
762 LOG_INFO(
"Applied multiplicative flat correction");
765 result.convertTo(cvIMG, CV_16UC1);
773 LOG_ERROR(
"An acquisition thread is already running!");
800 device->
Threader->TerminateThread(tempID);
814 device->
Threader->TerminateThread(tempID);
823 LOG_ERROR(
"An acquisition thread is already running!");
851 device->
Threader->TerminateThread(tempID);
865 device->
Threader->TerminateThread(tempID);
874 LOG_ERROR(
"An acquisition thread is already running!");
901 device->
Threader->TerminateThread(tempID);
910 LOG_INFO(
"Applied bad pixel correction");
916 device->
Threader->TerminateThread(tempID);
925 if ((result != DRV_SUCCESS) && (result != DRV_IDLE))
927 LOG_ERROR(
"Unable to abort acquisition.");
944 throw "Bad pixel image empty!";
949 <<
" does not match the detector size " <<
x <<
" x " <<
y);
954 LOG_ERROR(
"Could not load bad pixel image from file: " << badPixelFilePath);
968 throw "Bias+dark correction image empty!";
973 <<
" does not match the current frame size " <<
frameSize[0] <<
" x " <<
frameSize[1]);
979 LOG_ERROR(
"Could not load bias+dark correction image from file: " << biasDarkFilePath);
996 throw "Flat correction image empty!";
1001 <<
" does not match the detector size " <<
x <<
" x " <<
y);
1004 double maxVal = 0.0;
1015 LOG_ERROR(
"Could not load flat correction image from file: " << flatFilePath);
1025 cv::Mat resizedImage;
1027 cv::resize(
cvFlatCorrection, resizedImage, cv::Size(
x / binning,
y / binning) , 0, 0, cv::INTER_CUBIC);
1045 if (status == DRV_SUCCESS)
1050 LOG_ERROR(
"SetShutter failed with the given closing time.");
1058 if (status == DRV_SUCCESS)
1063 LOG_ERROR(
"SetShutter failed with the given opening time.");
1093 if(status != DRV_SUCCESS)
1095 LOG_ERROR(
"SetImage failed while changing horizontal bins.");
1108 if(status != DRV_SUCCESS)
1110 LOG_ERROR(
"SetImage failed while changing vertical bins.");
1121 if(status != DRV_SUCCESS)
1123 LOG_ERROR(
"SetHSSpeed command failed.");
1136 if(status != DRV_SUCCESS)
1138 LOG_ERROR(
"GetHSSpeed command failed.");
1146 unsigned status =
checkStatus(::SetVSSpeed(index),
"SetVSSpeed");
1147 if(status != DRV_SUCCESS)
1149 LOG_ERROR(
"SetVSSpeed command failed.");
1167 if(status != DRV_SUCCESS)
1169 LOG_ERROR(
"GetVSSpeed command failed.");
1178 unsigned status =
checkStatus(::SetPreAmpGain(this->PreAmpGainIndex),
"SetPreAmpGain");
1179 if(status == DRV_P1INVALID)
1181 LOG_ERROR(
"Index out of range.");
1198 if(status != DRV_SUCCESS)
1200 LOG_ERROR(
"GetPreAmpGain command failed.");
1276 std::copy(std::begin(intrinsics), std::end(intrinsics), this->
cameraIntrinsics);
1283 std::array<double, 9> returnIntrinsics;
1285 return returnIntrinsics;
1298 std::array<double, 4> returnCoefficients;
1300 return returnCoefficients;
1332 if (coolerStatus == 0)
1338 LOG_INFO(
"Cooler is already on. Setting temperature to configured " << this->
CoolTemperature <<
" °C.");
1342 else if(coolerState ==
false && coolerStatus == 1)
1353 int coolerStatus = 1;
1355 if(result == DRV_SUCCESS)
1357 return bool(coolerStatus);
1365 unsigned result =
checkStatus(CoolerON(),
"CoolerON");
1366 if(result == DRV_SUCCESS)
1368 LOG_INFO(
"Temperature controller switched ON.");
1372 LOG_ERROR(
"CoolerON command failed to execute.");
1379 unsigned result =
checkStatus(CoolerOFF(),
"CoolerOFF");
1380 if(result == DRV_SUCCESS)
1382 LOG_INFO(
"Temperature controller switched OFF.");
1385 LOG_ERROR(
"CoolerOFF command failed to execute.");
1393 if(result == DRV_SUCCESS)
1398 LOG_INFO(
"Cooler mode set to 1. If the cooler is ON, temperature will be maintained on Shutdown, otherwise Camera will return to ambient temperature.");
1402 LOG_INFO(
"Cooler mode set to 0. Camera will return to ambient temperature on ShutDown.");
1406 LOG_ERROR(
"SetCoolerMode command failed to execute.");
1419 unsigned result =
checkStatus(SetTemperature(coolTemp),
"SetTemperature");
1420 if(result != DRV_SUCCESS)
1422 LOG_ERROR(
"SetCoolTemperature command failed.");
1463 return status == DRV_ACQUIRING;
1475 double startOfWait = vtkIGSIOAccurateTimer::GetSystemTime();
1479 igtl::Sleep(sleepQuantumMilliseconds);
1480 now = vtkIGSIOAccurateTimer::GetSystemTime();
1482 while (now < startOfWait + maximumWaitTimeInSeconds && Threader->IsThreadActive(this->
threadID));
1496 if(returnStatus == DRV_SUCCESS)
1498 return returnStatus;
1500 else if(returnStatus == DRV_NOT_INITIALIZED)
1502 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1503 <<
"; Driver is not initialized.");
1505 else if(returnStatus == DRV_ACQUIRING)
1507 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1508 <<
"; Not allowed. Currently acquiring data.");
1510 else if(returnStatus == DRV_P1INVALID)
1512 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1513 <<
"; Parameter 1 not valid.");
1515 else if(returnStatus == DRV_P2INVALID)
1517 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1518 <<
"; Parameter 2 not valid.");
1520 else if(returnStatus == DRV_P3INVALID)
1522 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1523 <<
"; Parameter 3 not valid.");
1525 else if(returnStatus == DRV_P4INVALID)
1527 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1528 <<
"; Parameter 4 not valid.");
1530 else if(returnStatus == DRV_P5INVALID)
1532 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1533 <<
"; Parameter 5 not valid.");
1535 else if(returnStatus == DRV_P6INVALID)
1537 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1538 <<
"; Parameter 6 not valid.");
1540 else if(returnStatus == DRV_P7INVALID)
1542 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1543 <<
"; Parameter 7 not valid.");
1545 else if(returnStatus == DRV_ERROR_ACK)
1547 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1548 <<
"; Unable to communicate with card.");
1550 else if(returnStatus == DRV_TEMP_OFF)
1552 LOG_INFO(
"Cooler is OFF. Current temperature is " << this->
CurrentTemperature <<
" °C");
1554 else if(returnStatus == DRV_TEMPERATURE_STABILIZED)
1558 else if(returnStatus == DRV_TEMPERATURE_NOT_REACHED)
1560 LOG_INFO(
"Cooling down, current temperature is " << this->
CurrentTemperature <<
" °C");
1562 else if(returnStatus == DRV_TEMP_DRIFT)
1564 LOG_INFO(
"Temperature had stabilised but has since drifted. Current temperature is " << this->
CurrentTemperature <<
" °C");
1566 else if(returnStatus == DRV_TEMP_NOT_STABILIZED)
1568 LOG_INFO(
"Temperature reached but not stabilized. Current temperature is " << this->
CurrentTemperature <<
" °C");
1570 else if(returnStatus == DRV_VXDNOTINSTALLED)
1572 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1573 <<
"; VxD not loaded.");
1575 else if(returnStatus == DRV_INIERROR)
1577 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1578 <<
"; Unable to load DETECTOR.INI.");
1580 else if(returnStatus == DRV_COFERROR)
1582 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1583 <<
"; Unable to load *.COF.");
1585 else if(returnStatus == DRV_FLEXERROR)
1587 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1588 <<
"; Unable to load *.RBF.");
1590 else if(returnStatus == DRV_ERROR_FILELOAD)
1592 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1593 <<
"; Unable to load *.COF or *.RBF files.");
1595 else if(returnStatus == DRV_USBERROR)
1597 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1598 <<
"; Unable to detect USB device or not USB 2.0.");
1600 else if(returnStatus == DRV_ERROR_NOCAMERA)
1602 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1603 <<
"; No camera found.");
1605 else if(returnStatus == DRV_GENERAL_ERRORS)
1607 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1608 <<
"; An error occured while obtaining the number of available cameras.");
1610 else if(returnStatus == DRV_INVALID_MODE)
1612 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1613 <<
"; Invalid mode or mode not available.");
1615 else if(returnStatus == DRV_ERROR_PAGELOCK)
1617 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1618 <<
"; Unable to allocate memory.");
1620 else if(returnStatus == DRV_INVALID_FILTER)
1622 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1623 <<
"; Filter not available for current acquisition.");
1625 else if(returnStatus == DRV_BINNING_ERROR)
1627 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1628 <<
"; Range not a multiple of horizontal binning.");
1630 else if(returnStatus == DRV_SPOOLSETUPERROR)
1632 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1633 <<
"; Error with spool settings.");
1635 else if(returnStatus == DRV_IDLE)
1637 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1638 <<
"; The system is not currently acquiring.");
1640 else if(returnStatus == DRV_NO_NEW_DATA)
1642 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1643 <<
"; There is no new data yet.");
1645 else if(returnStatus == DRV_ERROR_CODES)
1647 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1648 <<
"; Problem communicating with camera.");
1650 else if(returnStatus == DRV_LOAD_FIRMWARE_ERROR)
1652 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1653 <<
"; Error loading firmware.");
1655 else if(returnStatus == DRV_NOT_SUPPORTED)
1657 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1658 <<
"; Feature not supported.");
1660 else if(returnStatus == DRV_RANDOM_TRACK_ERROR)
1662 LOG_ERROR(
"Failed AndorSDK operation: " << functionName
1663 <<
"; Invalid combination of tracks.");
1667 LOG_WARNING(
"Possible failed AndorSDK operation: " << functionName
1668 <<
"; Unknown return code " << returnStatus <<
"returned.");
1671 return returnStatus;
bool IsAcquisitionThreadRunning()
std::vector< uint16_t > rawFrame
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
unsigned int GetCCDStatus()
PlusStatus TurnCoolerON()
PlusStatus InternalStopRecording() override
virtual PlusStatus InternalConnect()
std::string saveCorrectionPath
Class for acquiring images from Andor cameras.
igsioFieldMapType CustomFields
vtkPlusAndorVideoSource::ShutterMode effectiveShutter
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_WRITING(deviceConfig, rootConfigElement)
AcquisitionMode GetAcquisitionMode()
int effectiveShutterOpeningTimeMilliseconds
vtkPlusAndorVideoSource::ShutterMode Shutter
PlusStatus SetHorizontalBins(int bins)
TriggerMode m_TriggerMode
double distortionCoefficients[4]
int ShutterOpeningTimeMilliseconds
PlusStatus SetAcquisitionMode(AcquisitionMode acquisitionMode)
void AdjustSpacing(int horizontalBins, int verticalBins)
static void * AcquireGrayscaleFrameThread(vtkMultiThreader::ThreadInfo *info)
PlusStatus SetDistortionCoefficients(std::array< double, 4 > coefficients)
std::array< float, 16 > imageToReferenceTransform
void ResizeFlatCorrectionImage(int binning)
bool RequirePortNameInDeviceSetConfiguration
std::string to_string(ClariusAvailability avail)
void PrepareAcquisition()
PlusStatus SetExposureTime(float exposureTime)
static void * AcquireBLIFrameThread(vtkMultiThreader::ThreadInfo *info)
void ApplyCosmicRayCorrection(int binning, cv::Mat &floatImage)
PlusStatus SetShutter(ShutterMode shutter)
int GetCurrentTemperature(float *temperature)
bool InitializeCoolerState
void AddFrameToDataSource(DataSourceArray &ds)
vtkStandardNewMacro(vtkPlusAndorVideoSource)
PlusStatus SetBiasDarkCorrectionImage(const std::string biasDarkFilePath)
PlusStatus GetVideoSourcesByPortName(const char *aPortName, std::vector< vtkPlusDataSource * > &sources)
double cameraIntrinsics[9]
unsigned int checkStatus(unsigned int returnStatus, std::string functionName)
PlusStatus InitializeAndorCamera()
virtual std::string GetSdkVersion()
PlusStatus SetInitializeCoolerState(bool InitializeCoolerState)
PlusStatus SetUseCosmicRayCorrection(bool UseCosmicRayCorrection)
PlusStatus StartGrayscaleFrameAcquisition(int binning, int vsSpeed, int hsSpeed, float exposureTime, int shutterCloseTime=0, int shutterOpenTime=0)
AcquisitionMode m_AcquisitionMode
std::string flatCorrection
virtual PlusStatus Disconnect()
void AdjustBuffers(int horizontalBins, int verticalBins)
std::vector< double > GetSpacing()
cv::Mat cvCameraIntrinsics
PlusStatus GetFirstActiveOutputVideoSource(vtkPlusDataSource *&aVideoSource)
void CorrectBadPixels(int binning, cv::Mat &cvIMG)
std::map< int, CellIndices > cellsToCorrect
PlusStatus SetTriggerMode(TriggerMode triggerMode)
unsigned long FrameNumber
PlusStatus SetCameraIntrinsics(std::array< double, 9 > intrinsics)
PlusStatus SetVerticalBins(int bins)
PlusStatus SetSafeTemperature(int safeTemp)
PlusStatus SetFrameFieldImageToReferenceTransform(std::array< float, 16 > transform)
int effectiveShutterClosingTimeMilliseconds
cv::Mat cvDistortionCoefficients
std::map< int, resizedFlatImage > cvResizedFlatCorrection
virtual PlusStatus WriteConfiguration(vtkXMLDataElement *config)
PlusStatus SetVSSpeedIndex(int index)
int ShutterClosingTimeMilliseconds
void SetCustomFrameFields()
std::array< double, 9 > GetCameraIntrinsics()
std::array< double, 4 > GetDistortionCoefficients()
PlusStatus TurnCoolerOFF()
DataSourceArray BLICorrected
PlusStatus AbortAcquisition()
PlusStatus SetRequireCoolTemp(bool RequireCoolTemp)
PlusStatus SetCoolerMode(int mode)
std::vector< uint > CellIndices
void InitializePort(DataSourceArray &port)
#define XML_FIND_DEVICE_ELEMENT_REQUIRED_FOR_READING(deviceConfig, rootConfigElement)
std::string badPixelCorrection
PlusStatus AcquireFrame()
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
bool GetUseCosmicRayCorrection()
bool GetUseFrameCorrections()
bool WaitForAcquisitionWithTimeout(double maximumWaitTimeInSeconds, int sleepQuantumMilliseconds=10)
PlusStatus SetShutterOpeningTimeMilliseconds(int openingTime)
static void * AcquireCorrectionFrameThread(vtkMultiThreader::ThreadInfo *info)
TriggerMode GetTriggerMode()
vtkPlusAndorVideoSource()
virtual PlusStatus NotifyConfigured()
virtual bool IsRecording() const
~vtkPlusAndorVideoSource()
bool StartThreadForInternalUpdates
virtual PlusStatus ReadConfiguration(vtkXMLDataElement *config)
virtual PlusStatus InternalDisconnect()
std::vector< vtkPlusDataSource * > DataSourceArray
PlusStatus InternalStartRecording() override
vtkMultiThreader * Threader
void ApplyFrameCorrections(int binning)
cv::Mat cvBiasDarkCorrection
PlusStatus SetBadPixelCorrectionImage(const std::string badPixelFilePath)
ChannelContainer OutputChannels
PlusStatus SetPreAmpGainIndex(int preAmpGainIndex)
DataSourceArray GrayCorrected
Direction vectors of rods y
bool UseCosmicRayCorrection
PlusStatus SetHSSpeed(int type, int index)
void FindBadCells(int binning)
PlusStatus SetShutterClosingTimeMilliseconds(int closingTime)
PlusStatus SetCoolTemperature(int coolTemp)
PlusStatus StartBLIFrameAcquisition(int binning, int vsSpeed, int hsSpeed, float exposureTime, int shutterCloseTime=0, int shutterOpenTime=0)
PlusStatus SetCoolerState(bool coolerState)
bool GetRequireCoolTemp()
PlusStatus SetReadMode(ReadMode setReadMode)
PlusStatus StartCorrectionFrameAcquisition(std::string correctionFilePath, ShutterMode shutter, int binning, int vsSpeed, int hsSpeed, float exposureTime, int shutterCloseTime=0, int shutterOpenTime=0)
PlusStatus SetFlatCorrectionImage(const std::string flatFilePath)
PlusStatus SetUseFrameCorrections(bool UseFrameCorrections)
std::string biasDarkCorrection
Interface to a 3D positioning tool, video source, or generalized data stream.