5 #include <opencv2/opencv.hpp> 37 double currentCamTime =
static_cast<double>(imgInfo->GetCameraTimestamp()) / 1000000.0;
38 UINT32 seq = imgInfo->GetImageID();
41 UINT32 srcWidth, srcHeight;
43 img.GetPixelType(srcPixelType);
44 img.GetSize(srcWidth, srcHeight);
46 UINT32 lineSize = img.GetLineSize();
49 cv::Mat cvImage(srcHeight, srcWidth,
config_.SmartekPipeline ? CV_8UC4 : CV_8UC1, (
void *) img.GetRawData(), lineSize);
54 msg->header.seq = seq;
59 cameraInfo_.header.stamp = msg->header.stamp;
60 cameraInfo_.header.seq = msg->header.seq;
61 cameraInfo_.header.frame_id = msg->header.frame_id;
62 cameraInfo_.width = srcWidth;
63 cameraInfo_.height = srcHeight;
73 std::stringstream outStream;
74 UINT32 part1, part2, part3, part4;
76 part1 = ((ipAddress >> 24) & 0xFF);
77 part2 = ((ipAddress >> 16) & 0xFF);
78 part3 = ((ipAddress >> 8) & 0xFF);
79 part4 = ((ipAddress) & 0xFF);
81 outStream << part1 <<
"." << part2 <<
"." << part3 <<
"." << part4;
83 return outStream.str();
106 gige::InitGigEVisionAPI();
107 gige::IGigEVisionAPI gigeVisionApi = gige::GetGigEVisionAPI();
108 gige::InitImageProcAPI();
112 if (!gigeVisionApi->IsUsingKernelDriver()) {
113 ROS_WARN(
"!!! Warning: Smartek Filter Driver not loaded.");
121 ROS_INFO(
"Beginning device discovery...");
122 gigeVisionApi->FindAllDevices(3.0);
123 gige::DevicesList devices = gigeVisionApi->GetAllDevices();
125 if (devices.size() > 0) {
130 for(
int i = 0; i < devices.size(); i++)
132 m_device_ = devices[i];
137 m_device_ = devices[0];
144 if (m_device_ != NULL && m_device_->Connect()) {
145 UINT32 address = m_device_->GetIpAddress();
147 ROS_INFO_STREAM(
"Device serial number: " << m_device_->GetSerialNumber());
150 m_device_->SetStringNodeValue(
"TriggerMode",
"Off");
152 m_device_->SetStringNodeValue(
"AcquisitionMode",
"Continuous");
155 m_device_->SetIntegerNodeValue(
"TLParamsLocked", 1);
156 m_device_->CommandNodeExecute(
"AcquisitionStart");
158 double currentExposure, currentGain, currentAcquisitionFramerate;
159 m_device_->GetFloatNodeValue(
"ExposureTime", currentExposure);
160 ROS_INFO(
"Exposure: %.2lf", currentExposure);
162 m_device_->GetFloatNodeValue(
"Gain", currentGain);
163 ROS_INFO(
"Gain: %.2lf", currentGain);
165 m_device_->GetFloatNodeValue(
"AcquisitionFrameRate", currentAcquisitionFramerate);
166 ROS_INFO(
"Acquisition framerate: %.2lf", currentAcquisitionFramerate);
168 ROS_INFO(
"Timesync %s",
config_.EnableTimesync ?
"enabled" :
"disabled");
177 pcameraInfoManager_ = std::make_unique<camera_info_manager::CameraInfoManager>(
np_, m_device_->GetSerialNumber());
196 m_device_->CommandNodeExecute(
"AcquisitionStop");
197 m_device_->SetIntegerNodeValue(
"TLParamsLocked", 0);
199 m_device_->SetFloatNodeValue(
"ExposureTime", config.ExposureTime);
200 m_device_->SetFloatNodeValue(
"Gain", config.Gain);
202 m_device_->SetFloatNodeValue(
"AcquisitionFrameRate", config.AcquisitionFramerate);
204 ROS_INFO(
"New exposure: %.2lf", config.ExposureTime);
205 ROS_INFO(
"New gain: %.2lf", config.Gain);
206 ROS_INFO(
"New acquisition framerate: %.2lf", config.AcquisitionFramerate);
207 ROS_INFO(
"Timesync %s", config.EnableTimesync ?
"enabled" :
"disabled");
210 if(config.EnableTimesync && !
config_.EnableTimesync) {
215 m_device_->SetIntegerNodeValue(
"TLParamsLocked", 1);
216 m_device_->CommandNodeExecute(
"AcquisitionStart");
226 bool status =
m_device_->CommandNodeExecute(
"AcquisitionStop");
227 status =
m_device_->SetIntegerNodeValue(
"TLParamsLocked", 0);
235 gige::ExitImageProcAPI();
236 gige::ExitGigEVisionAPI();
241 bool gotImage =
false;
277 int main(
int argc,
char **argv) {
void publish(const sensor_msgs::Image &image, const sensor_msgs::CameraInfo &info) const
image_transport::CameraPublisher cameraPublisher_
std::unique_ptr< image_transport::ImageTransport > pimageTransport_
std::unique_ptr< TimestampSynchronizer > ptimestampSynchronizer_
void reconfigure_callback(Config &config, uint32_t level)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
gige::IImageBitmap m_colorPipelineBitmap_
void initTimestampSynchronizer()
gige::IImageInfo m_imageInfo_
dynamic_reconfigure::Server< Config > reconfigureServer_
gige::IAlgorithm m_colorPipelineAlg_
gige::IResults m_colorPipelineResults_
gige::IImageProcAPI m_imageProcApi_
int main(int argc, char **argv)
std::string serialNumber_
sensor_msgs::CameraInfo cameraInfo_
void publishGigeImage(const gige::IImageBitmapInterface &img, const gige::IImageInfo &imgInfo)
smartek_camera::SmartekCameraConfig Config
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
gige::IParams m_colorPipelineParams_
std::unique_ptr< camera_info_manager::CameraInfoManager > pcameraInfoManager_
#define ROS_INFO_STREAM(args)
ROSCPP_DECL void shutdown()
ROS driver for the Smartek camera.
#define ROS_ERROR_STREAM(args)
ROSCPP_DECL void spinOnce()
dynamic_reconfigure::Server< Config >::CallbackType reconfigureCallback_
static std::string IpAddrToString(UINT32 ipAddress)
TimestampSynchronizer::Options defaultTimesyncOptions_
sensor_msgs::ImagePtr toImageMsg() const