Ask Your Question

TypeError: Your input type is not a numpy array

asked 2020-09-11 05:50:21 -0500

skzeng gravatar image

#!/usr/bin/env python import cv2 import os import numpy as np import rospy from std_msgs.msg import Header from sensor_msgs.msg import Image, PointCloud2 import sensor_msgs.point_cloud2 as pcl2 from cv_bridge import CvBridge

DATA_PATH = '/home/skzeng/catkin_kitti/src/kitti2/data/kitti/RawDate/2011_09_26/2011_09_26_drive_0005_sync/'

if __name__ == "__main__": frame = 0 rospy.init_node('kitti_node',anonymous=True) cam_pub = rospy.Publisher('kitti_cam', Image, queue_size=10) pcl_pub = rospy.Publisher('kitti_point_cloud', PointCloud2, queue_size=10) bridge = CvBridge()

rate = rospy.Rate(10)

while not rospy.is_shutdown():
    img = cv2.imread(os.path.join(DATA_PATH, 'image_02/data/%010d.png'%frame))

    point_cloud = np.fromfile(os.path.join(DATA_PATH, 'velodyne_points/data/%010d.bin'%frame),dtype=np.float32).reshape(-1,4)
    header = Header()
    header.stamp =
    header.frame_id = 'map'
    pcl_pub.publish(pcl2.create_cloud_xyz32(header, point_cloud[:,:3]))
    rospy.loginfo("camera image published")
    frame += 1
    frame %= 154
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-09-15 21:59:47 -0500

Josh Whitley gravatar image

What you have posted is not a question, it's badly-formatted Python code and an error. Please create a new post and ask an actual question along with details of your environment that are asked for in the template.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2020-09-11 05:50:21 -0500

Seen: 291 times

Last updated: Sep 15 '20