Complete the code to initialize a ROS node for object detection.
import rospy def main(): rospy.[1]('object_detection_node') if __name__ == '__main__': main()
In ROS, rospy.init_node() initializes a node with a given name.
Complete the code to subscribe to the camera image topic in ROS.
from sensor_msgs.msg import Image rospy.Subscriber('[1]', Image, image_callback)
The color image topic is usually /camera/color/image_raw for object detection.
Fix the error in the callback function to convert ROS Image message to OpenCV image.
from cv_bridge import CvBridge bridge = CvBridge() def image_callback(msg): cv_image = bridge.[1](msg, desired_encoding='bgr8')
The correct method to convert ROS Image messages to OpenCV images is imgmsg_to_cv2.
Fill both blanks to publish detected bounding boxes and labels in ROS.
from visualization_msgs.msg import MarkerArray publisher = rospy.Publisher('[1]', MarkerArray, queue_size=10) publisher.[2](marker_array)
The topic /object_markers is commonly used for visualization markers, and publish() sends messages.
Fill all three blanks to create a dictionary of detected objects with labels and confidence scores.
detected_objects = [1]: [2] for [3] in detections if [3]['score'] > 0.5
This dictionary comprehension maps each detected object obj to its label and score if the score is above 0.5.
