36 #include <boost/format.hpp> 42 srv_(priv_nh), it_(node)
53 int major, minor, build;
55 ROS_INFO(
"Loaded uEye SDK %s.", version);
57 ROS_WARN(
"Loaded uEye SDK %d.%d.%d. Expecting %s.", major, minor, build, version);
62 if (num_cameras > 0) {
63 if (num_cameras == 1) {
66 ROS_INFO(
"Found %d uEye cameras.", num_cameras);
76 if (priv_nh.
getParam(
"serialNo",
id)) {
78 ROS_ERROR(
"Failed to open uEye camera with serialNo: %u.",
id);
82 }
else if (priv_nh.
getParam(
"deviceId",
id)) {
84 ROS_ERROR(
"Failed to open uEye camera with deviceId: %u.",
id);
91 ROS_ERROR(
"Failed to open uEye camera with cameraId: %u.",
id);
99 dynamic_reconfigure::Server<monoConfig>::CallbackType
f = boost::bind(&
CameraNode::reconfig,
this, _1, _2);
120 if (path.length() == 0) {
125 unsigned int length = path.length();
127 if (path.c_str()[length - 1] ==
'/') {
128 path = path.substr(0, length - 1);
142 switch (config.trigger) {
143 case mono_TGR_HARDWARE_RISING:
146 case mono_TGR_HARDWARE_FALLING:
156 config.trigger = mono_TGR_AUTO;
163 switch (config.color) {
165 case mono_COLOR_MONO8:
168 case mono_COLOR_MONO16:
174 case mono_COLOR_YCbCr:
177 case mono_COLOR_BGR5:
180 case mono_COLOR_BGR565:
183 case mono_COLOR_BGR8:
186 case mono_COLOR_BGRA8:
189 case mono_COLOR_BGRY8:
192 case mono_COLOR_RGB8:
195 case mono_COLOR_RGBA8:
198 case mono_COLOR_RGBY8:
230 if (!config.auto_gain) {
251 if (!config.auto_exposure) {
256 if (
zoom_ != config.zoom) {
278 ROS_INFO(
"New camera info received");
279 sensor_msgs::CameraInfo &info = req.camera_info;
286 if (info.width != width || info.height != height) {
288 rsp.status_message = (boost::format(
"Camera_info resolution %ix%i does not match current video " 289 "setting, camera running at resolution %ix%i.") % info.width % info.height
290 % width % height).str();
291 ROS_ERROR(
"%s", rsp.status_message.c_str());
296 std::stringstream ini_stream;
298 rsp.status_message =
"Error formatting camera_info for storage.";
301 std::string ini = ini_stream.str();
302 std::fstream param_file;
304 param_file.open(filename.c_str(), std::ios::in | std::ios::out | std::ios::trunc);
306 if (param_file.is_open()) {
307 param_file << ini.c_str();
314 rsp.status_message =
"file write failed";
318 ROS_ERROR(
"%s", rsp.status_message.c_str());
329 std::fstream param_file;
330 param_file.open(MyPath.c_str(), std::ios::in);
332 if (param_file.is_open()) {
333 param_file.read(buffer, 12800);
338 std::string camera_name;
340 ROS_INFO(
"Loaded calibration for camera '%s'", camera_name.c_str());
342 ROS_WARN(
"Failed to load intrinsics for camera from file");
356 sensor_msgs::CameraInfoPtr msg(
new sensor_msgs::CameraInfo(
msg_camera_info_));
359 sensor_msgs::ImagePtr msg_image(
new sensor_msgs::Image());
364 msg_image->is_bigendian =
false;
365 msg_image->step = size / msg_image->height;
366 msg_image->data.resize(size);
367 memcpy(msg_image->data.data(), frame, size);
374 sensor_msgs::CameraInfoPtr info;
375 sensor_msgs::ImagePtr img =
processFrame(frame, size, info);
image_transport::ImageTransport it_
unsigned int getHardwareGain()
void publish(const sensor_msgs::Image &image, const sensor_msgs::CameraInfo &info) const
void setHardwareGain(int *gain)
static const char * colorModeToString(uEyeColor mode)
sensor_msgs::ImagePtr processFrame(const char *frame, size_t size, sensor_msgs::CameraInfoPtr &info)
unsigned int getCameraSerialNo() const
uint32_t getNumSubscribers() const
void setAutoGain(bool *enable)
void timerCallback(const ros::TimerEvent &event)
const char * getCameraName() const
bool setTriggerMode(TriggerMode mode)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool setCameraInfo(sensor_msgs::SetCameraInfo::Request &req, sensor_msgs::SetCameraInfo::Response &rsp)
bool getGainBoost() const
void setHardwareGamma(bool *enable)
CameraPublisher advertiseCamera(const std::string &base_topic, uint32_t queue_size, bool latch=false)
bool getAutoExposure() const
dynamic_reconfigure::Server< monoConfig > srv_
image_transport::CameraPublisher pub_stream_
void setAutoExposure(bool *enable)
bool openCameraDevId(unsigned int id)
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
void setGainBoost(bool *enable)
bool writeCalibrationIni(std::ostream &out, const std::string &camera_name, const sensor_msgs::CameraInfo &cam_info)
int getNumberOfCameras() const
void startVideoCapture(CamCaptureCB)
void handlePath(std::string &path)
int getPixelClock() const
void publishImage(const char *frame, size_t size)
void setPixelClock(int *MHz)
CameraNode(ros::NodeHandle node, ros::NodeHandle private_nh)
ROSLIB_DECL std::string getPath(const std::string &package_name)
sensor_msgs::CameraInfo msg_camera_info_
void setColorMode(uEyeColor mode)
bool getParam(const std::string &key, std::string &s) const
void setFrameRate(double *rate)
void reconfig(monoConfig &config, uint32_t level)
bool openCameraSerNo(unsigned int serial_number)
static std::string configFileName(const Camera &cam)
ROSCPP_DECL void shutdown()
void setExposure(double *time_ms)
bool parseCalibrationIni(const std::string &buffer, std::string &camera_name, sensor_msgs::CameraInfo &cam_info)
uEyeColor getColorMode() const
static bool checkVersion(int &major, int &minor, int &build, const char *&expected)
bool getHardwareGamma() const
ros::ServiceServer srv_cam_info_
bool openCameraCamId(unsigned int id)