createBitMap.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('ar_kinect')
00004 import rospy
00005 import cv
00006 import cv2
00007 import numpy as np
00008 from nav_msgs.msg import OccupancyGrid, MapMetaData
00009 
00010 def callback(data):
00011     #Darstellung Array in Bitmap-Datei
00012     # cv.CV_32UC1
00013     #        || |
00014     #        || |____ Anzahl der Kanaele, entspricht Anzahl der parallel uebergebenen Matritzen. 
00015     #        ||
00016     #        ||______ U .. Unsigned, F ... Float, S ... Signed - Datentyp der Elemente der Matrix.     
00017     #        |_______ Anzahl der Pixel mit welchem ein Element der Matrix dargestellt wird (8, 16, 32, oder 64).
00018     #
00019     mat = cv.CreateMat(data.info.height, data.info.width, cv.CV_64FC1)
00020     for y in range(data.info.height):
00021         for x in range(data.info.width):
00022             if data.data[y*data.info.width+x] == 0:
00023                 mat[y,x] = 255
00024             else:
00025                 mat[y,x] = data.data[y*data.info.width+x]
00026           
00027     a = np.asarray(mat)
00028     params = list()
00029     params.append(cv2.cv.CV_IMWRITE_PXM_BINARY)
00030     params.append(0)
00031     cv2.imwrite("/home/janina/ros_workspace/Testbild.pbm", a, params)
00032 
00033     
00034 if __name__ == '__main__':
00035     rospy.init_node('createBitMap', anonymous=True)
00036     rospy.Subscriber('occ_grid_map', OccupancyGrid, callback)
00037     rospy.spin()


biped_robin_navigation
Author(s): Johannes Mayr, Johannes Mayr
autogenerated on Mon Jan 6 2014 11:09:45