Corner detection using opencv and ROS
Hi guys,
I have implemented an algorithm that uses the opencv2 Harris corner detector. I have a few questions, but first let me explain my system: I have copied the opencv2 Harris corner detector and placed it in a callback function in which messages of type sensor_msgs::ImageConstPtr& msg
are passed to it. I then instantiate a cv_bridge::CvImagePtr
object and call it cv_ptr
, the message (msg
) is then copied to cv_ptr
using the cv_bridge
. I then declare Mat dst, dst_norm, dst_norm_scaled
and a number of operations are performed and the final image (with the corners detected) is stored in dst_norm_scaled
. When rosmake
and then roslaunch
it works, and I am able to view the dst_norm_scaled
using cv::imshow
. However I have a number of concerns:
1- If I want to transfer this back to a ROS type image, image_pub_.publish(cv_ptr->toImageMsg());
is used, however, my corner detected image is stored in dst_norm_scaled
now, so how do I convert and publish this?
2- I tried to use a second cv_bridge::CvImagePtr
object I called cv_ptr2
in which I can use instead of dst_norm_scale
and then publish it using image_pub_.publish(cv_ptr2->toImageMsg())
, and although rosmake
was successful, the process died and threw an exception. I guess only 1 cv_ptr
is allowed to be used?
3- In my program, although the corners are detected, if I move the camera too quickly there becomes a lag and sometimes the image shown becomes black for a couple of seconds. I am currently using ros::spin()
in my main function.
If there are any additional information you would like me to explain, please let me know. I really appreciate your help.
Regards,
Khalid