ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

g_object_unref: assertion 'G_IS_OBJECT (object)' failed Attempt to unlock mutex that was not locked

asked 2020-04-25 11:10:59 -0500

N.N.Huy gravatar image

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)
    cv::imshow("view", cv_bridge::toCvShare(msg, "bgr8")->image);
  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;
  image_transport::ImageTransport it(nh);
  image_transport::Subscriber sub = it.subscribe("camera/image", 1, imageCallback);



Can you help me to solve this ? Thanks in advances!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-04-26 00:33:21 -0500

N.N.Huy gravatar image

Hello i fixed the error. The source code in the website couldn't run. - Instead of using cv::startWindowThread();, we should use waitKey(); - They forget to add the size parameter in cv::namedWindow("view"); too. => cv::namedWindow("view", CV_WINDOW_AUTOSIZE);

edit flag offensive delete link more


Hi, I got the same issue after using the waitkey(). It gave an error stating Assertion 'G_IS_OBJECT (object)' failed. I found that the waitkey(0) causes that error. I am using lidar_camera_calibration ROS for my lidar camera calibration. Would like to get some help. Thanks.

DJ gravatar image DJ  ( 2020-06-12 06:26:44 -0500 )edit

Actually, i am just a beginner and i don't have many experiences in this. You could make a new topic to ask someone with more insight than me could help :) !

N.N.Huy gravatar image N.N.Huy  ( 2020-06-22 23:26:09 -0500 )edit

@DJ, you replaced cv::startWindowThread() by cv::waitkey(0) ? you should use cv::waitkey(1) instead.

I had the same issue and I found some info on the stackoverflow link bellow. Basically the number between the parenthesis cv::waitkey is a time in millisecond for the program to wait. And if set to 0, then it wait forever (until you press a key).

iad-AR gravatar image iad-AR  ( 2021-02-13 13:43:43 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-04-25 11:10:59 -0500

Seen: 3,389 times

Last updated: Apr 26 '20