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

py-faster-rcnn network detection runs on CPU through ROS callback function

asked 2016-08-03 06:45:58 -0500

WillAndrew gravatar image

updated 2016-08-03 10:56:47 -0500

Hi there,

I'm trying to test my trained py-faster-rcnn network for object detection through ROS. I have a node running with many similarities to Included in the class are commands to execute the network detection on the GPU (given below), however, looking at recall times (~26s) and the system profiler it's fairly clear that the network is running on the CPU. Is there a way to get around this?

cfg.GPU_ID = 0

Interestingly, if I run normally (not through ROS), it executes on the GPU in ~2s

UPDATE: after some more detective work, it appears that it is an issue with calling CNN detection within a callback function. Any suggestions? (Other people seem to be experiencing a similar problem - Callback with GPU processing)

Thanks, Will

edit retag flag offensive close merge delete


I don't know anything about caffe, but I do know that rospy runs callbacks in a separate thread from the main loop. Perhaps that helps?

ahendrix gravatar image ahendrix  ( 2016-08-03 11:07:28 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2016-08-04 05:27:15 -0500

WillAndrew gravatar image

Solved the issue by having the callback function change a global variable which is checked by the main loop/thread as follows:

while not rospy.is_shutdown():
    if run_test_img == True:

A bit hacky but it does the job.

edit flag offensive delete link more


Hi Will. I am also trying to implement faster-rcnn inside the ROS framework. I want to run the demo as a ROS node and pass images on ROS topic. I know how to pass images over a ROS topic but was wondering if there are any dependancy issues when I try to integrate faster rcnn within ROS?

uzair gravatar image uzair  ( 2016-09-19 17:46:30 -0500 )edit

answered 2017-01-24 03:47:07 -0500

sjsingh gravatar image

Add these lines in your callback function somewhere at the top


This works seamlessly. But it doesn't make much sense.

edit flag offensive delete link more


Why doesn't it make much sense?

gvdhoorn gravatar image gvdhoorn  ( 2017-01-24 04:39:48 -0500 )edit

Question Tools

1 follower


Asked: 2016-08-03 06:45:58 -0500

Seen: 1,007 times

Last updated: Aug 04 '16