g_object_unref: assertion 'G_IS_OBJECT (object)' failed Attempt to unlock mutex that was not locked
Hello evryone, i am following this tutorial to create my image subscriber link text, using image_transport, however, i meet this problem when i run my subscriber.
(view:19049): GLib-GObject-CRITICAL **: 22:58:39.962: g_object_unref: assertion 'G_IS_OBJECT (object)' failed Attempt to unlock mutex that was not locked Aborted (core dumped) This is my source code:
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <cv_bridge/cv_bridge.h>
void imageCallback(const sensor_msgs::ImageConstPtr& msg)
{
try
{
cv::imshow("view", cv_bridge::toCvShare(msg, "bgr8")->image);
cv::waitKey(30);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("Could not convert from '%s' to 'bgr8'.", msg->encoding.c_str());
}
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "image_listener");
ros::NodeHandle nh;
cv::namedWindow("view");
cv::startWindowThread();
image_transport::ImageTransport it(nh);
image_transport::Subscriber sub = it.subscribe("camera/image", 1, imageCallback);
ros::spin();
cv::waitKey(0);
cv::destroyWindow("view");
}
Can you help me to solve this ? Thanks in advances!