forked from IntelRealSense/realsense-ros
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from abhijitmajumdar/por_upstream_sync
Por upstream sync v2.2.3
- Loading branch information
Showing
13 changed files
with
315 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import rospy | ||
from sensor_msgs.msg import Image as msg_Image | ||
from cv_bridge import CvBridge, CvBridgeError | ||
import sys | ||
import os | ||
|
||
class ImageListener: | ||
def __init__(self, topic): | ||
self.topic = topic | ||
self.bridge = CvBridge() | ||
self.sub = rospy.Subscriber(topic, msg_Image, self.imageDepthCallback) | ||
|
||
def imageDepthCallback(self, data): | ||
try: | ||
cv_image = self.bridge.imgmsg_to_cv2(data, data.encoding) | ||
pix = (data.width/2, data.height/2) | ||
sys.stdout.write('%s: Depth at center(%d, %d): %f(mm)\r' % (self.topic, pix[0], pix[1], cv_image[pix[1], pix[0]])) | ||
sys.stdout.flush() | ||
except CvBridgeError as e: | ||
print(e) | ||
return | ||
|
||
def main(): | ||
topic = '/camera/depth/image_rect_raw' | ||
listener = ImageListener(topic) | ||
rospy.spin() | ||
|
||
if __name__ == '__main__': | ||
node_name = os.path.basename(sys.argv[0]).split('.')[0] | ||
rospy.init_node(node_name) | ||
main() |
Oops, something went wrong.