image_proc not working as expected
Hello everyone,
I'm trying to use image_proc
to rectify my image, coming from a folder.
Here is my launch file:
<launch>
<group ns="calibration">
<rosparam command="load" file="/home/george/GOPRO/chessboard/calibrationdata/cal.yml"/>
<!-- <node pkg="green_eye" name="camera_info_pub" type="camera_info_pub" output="screen" /> -->
</group>
<node pkg="green_eye" name="file_monitor" type="file_monitor" output="screen"/>
<node pkg="green_eye" name="image_processor" type="image_processor" output="screen"/>
<group ns="camera">
<node pkg="image_proc" name="image_proc" type="image_proc" output="screen"/>
<node pkg="image_view" name="image_raw" type="image_view" output="screen">
<remap from="image" to="image_raw" />
</node>
<node pkg="image_view" name="image_mono" type="image_view" output="screen">
<remap from="image" to="image_mono" />
</node>
<node pkg="image_view" name="image_rect" type="image_view" output="screen">
<remap from="image" to="image_rect" />
</node>
</group>
</launch>
The file_monitor
node checks for new images in a folder and publishes the image path.
image_processor
reads that path and uses openCV
to read the image and publish it to the /camera/image_raw
node.
It also stamps and publishes the CameraInfo
topic in the /camera/camera_info
path.
From there on, I expect image_proc
to do its job, but it fails.
While the image_raw
and image_mono
topics are visible by the image_view
, image_rect
always stays grey (in fact it is never published).
I also get the following warning (not actually pasted exactly)
[image_transport] Topics '/camera/image_mono' and '/camera/camera_info' do not appear to be synchronized. In the last 10s:
Image messages received: 4
CameraInfo messages received: 4
Synchronized pairs: 0
image_mono
seems to be a product of image_proc
, but not actually a topic I publish myself, which lags image_raw
by some 10s of ms and is displayed correctly. However, image_raw
should be the only input of image_proc
that I have to stamp.
Thus, I don't know why this warning should appear, or whether it affects my result.
Any ideas welcome, Thanks in advance!
Edit -------------------------------------------------------------------------------------------------------------------------
I managed to have the intended result with the cv::undistort
API, but the solution is less modular and I'm not sure whether the result is as sound as the well-documented image_proc
, so I'll leave this open.
Edit 2 ----------------------------------------------------------------------------------------------------------------------
Here is the code which I use to fill the camera_info
message, having the converted .yaml
file loaded in the parameter server:
pub_img_raw = it.advertise("/camera/image_raw",1);
pub_cfg = n.advertise<sensor_msgs::CameraInfo>("/camera/camera_info",1);
sensor_msgs::CameraInfo cfg;
XmlRpc::XmlRpcValue list;
int i;
cfg.header.frame_id = "camera";
double temp;
ros::param::get("/calibration/image_height", temp);
cfg.height = (uint)temp;
ros::param::get("/calibration/image_width", temp);
cfg.width = (uint)temp;
ros::param::get("/calibration/distortion_model", cfg.distortion_model);
ros::param::get("/calibration/distortion_coefficients/data", list);
cfg.D.clear();
for (i=0;i<5;i++) {
cfg.D.push_back((double)list[i]);
}
ros::param::get("/calibration/camera_matrix/data", list);
for (i=0;i<9;i++) {
cfg.K[i] = list[i];
}
ros::param::get("/calibration/rectification_matrix/data", list);
for (i=0;i<9;i++) {
cfg.R[i] = list[i];
}
ros::param::get("/calibration/projection_matrix/data", list);
for (i=0;i<12;i++) {
cfg.P[i] = list ...
I just realized that the warning comes from
image_transport
, notimage_proc
, so one less thing to worry about. But the fact thatimage_rect
is never published is still a problem.image_transport
is used withinimage_proc
so it is likely that this is indeed a thing to worry about :)