Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can you tell me how to use the object detector details, Thanks you. #6

Open
wt2excellent opened this issue Sep 7, 2024 · 1 comment

Comments

@wt2excellent
Copy link

No description provided.

@Bradgers
Copy link

Bradgers commented Oct 24, 2024

Sorry for the late reply. You can use a LiDAR-based 3D detector (such as the model in OpenPCDet) and then publish the detection results using ROS. The code is as follows:

from std_msgs.msg import Float64MultiArray
from sensor_msgs.msg import PointCloud2
import ros_numpy

# publisher
detect3d_pub  = rospy.Publisher("/detect3d", Float64MultiArray)

# specify your detector
detector = YOUR_DETECTOR()


def get_boxes(databin):
    result = detector.detect(databin) # [[type, x, y, z, l, w, h, yaw, score], ...,[type, x, y, z, l, w, h, yaw, score]]
    return result


def Callback_pcvelo(msg):
    assert isinstance(msg, PointCloud2)
    # receive pointcloud data
    points = ros_numpy.numpify(msg)
    frame_timestamp = msg.header.stamp.to_sec()
    # get detection results
    result = np.array(get_boxes(points))
    result_1d = np.array(result).reshape(-1)
    data_send = np.array([frame_timestamp] + list(result_1d)) # [timestamp, [type, x, y, z, l, w, h, yaw, score], ...,[type, x, y, z, l, w, h, yaw, score]]
    # publish detection results
    detect3d_pub.publish(Float64MultiArray(data=data_send))
    

if __name__ == "__main__":
    # subscribe to the point cloud topic
    sub_pcvelo = rospy.Subscriber("velodyne_points", PointCloud2, Callback_pcvelo)
    rospy.spin()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants