ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

cv::imshow runtime error: "QObject::startTimer: Timers cannot be started from another thread"

asked 2017-02-19 05:37:46 -0600

shosh gravatar image

I am using set of nodelets, and running them from one launch file. When I load them as standalone nodelets, I don't see any issue. but when I load them by one manager, I encountered an issue with cv::imshow function. my launch file:

<launch>
<node pkg="nodelet" type="nodelet" name="manager_nodelet"  args="manager"/>
<node pkg="nodelet" type="nodelet" name="my_camera" args="standalone my_camera/NodeletCamera" output="screen"/>
  <node pkg="nodelet" type="nodelet" name="my_nodelet1" args="load my_proj/SNodelet1 manager_nodelet" output="screen"/> 
  <node pkg="nodelet" type="nodelet" name="my_nodelet2" args="load my_proj/SNodelet2 manager_nodelet" output="screen" />
  <node pkg="nodelet" type="nodelet" name="my_viewer" args="load my_proj/SNodeletViewer manager_nodelet"/>
  <node pkg="nodelet" type="nodelet" name="my_sample" args="load my_proj/SNodeletSample manager_nodelet"/>  
</launch>

The error I get is: "QObject::startTimer: Timers cannot be started from another thread"

I have a call to cv::imshow in a function gui.cpp file:

void GUI::showResult()
{
    cv::namedWindow(m_name,cv::WINDOW_AUTOSIZE);
    cv::imshow(m_window_name, m_img);
}

SNodeletViewer calls this function. I get the error after several calls to this function. when I get the error - the cpu usage is over then 100%. If I remove the calling to cv::namedWindow and cv::imshow - all works well.

any idea what can be the issue with calling cv::imshow from nodelet that loaded by nodelet manager? and what is the solution?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-06-21 07:58:23 -0600

Avio gravatar image

For everybody facing the same issue, the answer is in one of the comments to this question.

If I move the creation of the named window(s) so that it happens in the callback function instead of in the Python object __init__ method then imshow and waitKey work as expected and the frame data is displayed in the window.

I can confirm that this workaround, albeit ugly, works as it should (I'm also trying to make camshift.py work).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-02-19 05:37:46 -0600

Seen: 2,518 times

Last updated: Jun 21 '18