14 if (
pCam_->IsInitialized()) {
16 pCam_->EndAcquisition();
40 ImagePtr pResultImage;
45 if (pResultImage->IsIncomplete()) {
47 ROS_WARN_STREAM(
"Image incomplete with image status " << pResultImage->GetImageStatus() <<
"!");
55 frameID_ = pResultImage->GetFrameID();
58 frameID_ = pResultImage->GetFrameID();
67 catch(Spinnaker::Exception &e){
68 ROS_FATAL_STREAM(e.what()<<
"\n Likely reason is that slaves are not triggered. Check GPIO cables\n");
95 catch(Spinnaker::Exception &e){
104 ImagePtr convertedImage;
106 convertedImage = pImage->Convert(PixelFormat_BGR8);
108 convertedImage = pImage->Convert(PixelFormat_Mono8);
109 unsigned int XPadding = convertedImage->GetXPadding();
110 unsigned int YPadding = convertedImage->GetYPadding();
111 unsigned int rowsize = convertedImage->GetWidth();
112 unsigned int colsize = convertedImage->GetHeight();
116 img = Mat(colsize + YPadding, rowsize + XPadding, CV_8UC3, convertedImage->GetData(), convertedImage->GetStride());
118 img = Mat(colsize + YPadding, rowsize + XPadding, CV_8UC1, convertedImage->GetData(), convertedImage->GetStride());
127 pCam_->BeginAcquisition();
133 if (
pCam_->GetNumImagesInUse())
134 ROS_WARN_STREAM(
"Some images still currently in use! Use image->Release() before deinitializing.");
137 pCam_->EndAcquisition();
143 INodeMap & nodeMap =
pCam_->GetNodeMap();
146 CEnumerationPtr ptr = nodeMap.GetNode(setting.c_str());
147 if (!IsAvailable(ptr) || !IsWritable(ptr))
148 ROS_FATAL_STREAM(
"Unable to set " << setting <<
" to " << value <<
" (enum retrieval). Aborting...");
151 CEnumEntryPtr ptrValue = ptr->GetEntryByName(value.c_str());
152 if (!IsAvailable(ptrValue) || !IsReadable(ptrValue))
153 ROS_FATAL_STREAM(
"Unable to set " << setting <<
" to " << value <<
" (entry retrieval). Aborting...");
156 int64_t valueToSet = ptrValue->GetValue();
159 ptr->SetIntValue(valueToSet);
167 INodeMap & nodeMap =
pCam_->GetNodeMap();
169 CIntegerPtr ptr = nodeMap.GetNode(setting.c_str());
170 if (!IsAvailable(ptr) || !IsWritable(ptr)) {
171 ROS_FATAL_STREAM(
"Unable to set " << setting <<
" to " << val <<
" (ptr retrieval). Aborting...");
181 INodeMap & nodeMap =
pCam_->GetNodeMap();
183 CFloatPtr ptr = nodeMap.GetNode(setting.c_str());
184 if (!IsAvailable(ptr) || !IsWritable(ptr)) {
185 ROS_FATAL_STREAM(
"Unable to set " << setting <<
" to " << val <<
" (ptr retrieval). Aborting...");
195 INodeMap & nodeMap =
pCam_->GetNodeMap();
197 CBooleanPtr ptr = nodeMap.GetNode(setting.c_str());
198 if (!IsAvailable(ptr) || !IsWritable(ptr)) {
199 ROS_FATAL_STREAM(
"Unable to set " << setting <<
" to " << val <<
" (ptr retrieval). Aborting...");
210 CIntegerPtr ptrHeight=
pCam_->GetNodeMap().GetNode(
"Height");
211 CIntegerPtr ptrWidth=
pCam_->GetNodeMap().GetNode(
"Width");
212 if (!IsAvailable(ptrWidth) || !IsWritable(ptrWidth)){
216 int64_t widthMax = ptrWidth->GetMax();
219 ptrWidth->SetValue(width);
222 if (!IsAvailable(ptrHeight) || !IsWritable(ptrHeight)){
226 int64_t heightMax = ptrHeight->GetMax();
231 ptrHeight->SetValue(height);
235 CEnumerationPtr ptrADC =
pCam_->GetNodeMap().GetNode(
"AdcBitDepth");
236 if (!IsAvailable(ptrADC) || !IsWritable(ptrADC)){
241 CEnumEntryPtr ptrADCA = ptrADC->GetEntryByName(bitDep);
242 int currDepth=ptrADCA->GetValue();
243 ptrADC->SetIntValue(currDepth);
249 INodeMap & sNodeMap =
pCam_->GetTLStreamNodeMap();
250 CIntegerPtr StreamNode = sNodeMap.GetNode(
"StreamDefaultBufferCount");
251 int64_t bufferCount = StreamNode->GetValue();
252 if (!IsAvailable(StreamNode) || !IsWritable(StreamNode)){
256 StreamNode->SetValue(numBuf);
261 CBooleanPtr ptrISPEn=
pCam_->GetNodeMap().GetNode(
"IspEnable");
262 if (!IsAvailable(ptrISPEn) || !IsWritable(ptrISPEn)){
263 ROS_FATAL_STREAM(
"Unable to set ISP Enable (node retrieval; camera " <<
"). Aborting...");
266 ptrISPEn->SetValue(
"True");
270 CBooleanPtr ptrAcquisitionFrameRateEnable=
pCam_->GetNodeMap().GetNode(
"AcquisitionFrameRateEnable");
271 if (!IsAvailable(ptrAcquisitionFrameRateEnable) || !IsWritable(ptrAcquisitionFrameRateEnable)){
272 ROS_FATAL_STREAM(
"Unable to set frameRateEnable (node retrieval; camera " <<
"). Aborting...");
276 ptrAcquisitionFrameRateEnable->SetValue(
"True");
280 CEnumerationPtr ptrPixelFormat =
pCam_->GetNodeMap().GetNode(formatPic);
281 if ( !IsWritable(ptrPixelFormat)){
285 CEnumEntryPtr ptrPixelEnt = ptrPixelFormat->GetEntryByName(
"RGB8Packed");
286 if (!IsAvailable(ptrPixelEnt) || !IsReadable(ptrPixelEnt)){
290 int64_t colorNum = ptrPixelEnt->GetValue();
292 ptrPixelFormat->SetIntValue(colorNum);
298 INodeMap & nodeMap =
pCam_->GetNodeMap();
300 CCommandPtr ptr = nodeMap.GetNode(
"TriggerSoftware");
301 if (!IsAvailable(ptr) || !IsWritable(ptr))
310 INodeMap& nodeMap =
pCam_->GetNodeMap();
312 CFloatPtr ptrNodeValue = nodeMap.GetNode(node_string.c_str());
314 if (IsAvailable(ptrNodeValue)){
316 return ptrNodeValue->GetMax();
325 INodeMap& nodeMap =
pCam_->GetTLDeviceNodeMap();
326 CStringPtr ptrNodeValue = nodeMap.GetNode(node_string.c_str());
327 if (IsReadable(ptrNodeValue)){
328 return string(ptrNodeValue->GetValue());
340 CFloatPtr ptrExpTest =
pCam_->GetNodeMap().GetNode(
"AutoExposureTargetGreyValue");
342 if (!IsAvailable(ptrExpTest) || !IsReadable(ptrExpTest)){
343 ROS_FATAL_STREAM(
"Unable to set exposure " <<
"). Aborting..." << endl << endl);
346 ptrExpTest->SetValue(90.0);
347 ROS_INFO_STREAM(
"target grey mode Time: "<<ptrExpTest->GetValue()<<endl);
352 CFloatPtr ptrExpTest=
pCam_->GetNodeMap().GetNode(
"ExposureTime");
353 if (!IsAvailable(ptrExpTest) || !IsReadable(ptrExpTest)){
354 ROS_FATAL_STREAM(
"Unable to set exposure " <<
"). Aborting..." << endl << endl);
357 float expTime=ptrExpTest->GetValue();
362 int actualBinningX = (
pCam_ ->SensorWidth())/(
pCam_ ->Width());
363 int actualBinningY = (
pCam_ ->SensorHeight())/(
pCam_ ->Height());
364 if (binningDesired == actualBinningX)
return true;
369 if ( (
pCam_ ->SensorWidth()) != calibrationWidth )
370 ROS_WARN_STREAM(
" Looks like your calibration is not done at full Sensor Resolution for cam_id = "<<
get_id()<<
" , Sensor_Width = "<<(
pCam_ ->SensorWidth()) <<
" given cameraInfo params:width = "<<calibrationWidth);
371 if ( (
pCam_ ->SensorHeight()) != calibrationHeight )
372 ROS_WARN_STREAM(
" Looks like your calibration is not done at full Sensor Resolution for cam_id = "<<
get_id()<<
" , Sensor_Height= "<<(
pCam_ ->SensorHeight()) <<
" given cameraInfo params:height = "<<calibrationHeight);
void adcBitDepth(gcstring bitDep)
bool verifyBinning(int binningDesired)
void setFloatValue(string, float)
uint64_t GET_NEXT_IMAGE_TIMEOUT_
void setResolutionPixels(int width, int height)
void setBufferSize(int numBuf)
double getFloatValueMax(string node_string)
#define ROS_FATAL_STREAM(args)
#define ROS_ASSERT_MSG(cond,...)
void setBoolValue(string, bool)
#define ROS_WARN_STREAM_COND(cond, args)
void setEnumValue(string, string)
#define ROS_WARN_STREAM(args)
#define ROS_DEBUG_STREAM(args)
void calibrationParamsTest(int calibrationWidth, int calibrationHeight)
void setPixelFormat(gcstring formatPic)
#define ROS_INFO_STREAM(args)
string getTLNodeStringValue(string node_string)
void targetGreyValueTest()
void setIntValue(string, int)
ROSCPP_DECL void shutdown()
Mat convert_to_mat(ImagePtr)