tlight_node.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:yolo_light 作者: chrisgundling 项目源码 文件源码
def updateImage(self, img):
        arr = self.bridge.imgmsg_to_cv2(img,"bgr8") 
        # Uncomment following two lines for CompressedImage topic
        #np_arr = np.fromstring(img.data, np.uint8)
        #arr = cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
        if self.image_lock.acquire(True):
            self.img = arr
            if self.model is None:
                self.model = self.get_model()
            self.img_out, self.boxes = self.predict(self.model, self.img)
            self.img_out = np.asarray(self.img_out[0,:,:,:])
            for box in self.boxes:
                if 'traffic light' in box['label']:
                    cv2.rectangle(self.img_out,(box['topleft']['x'], 
                                                box['topleft']['y']), 
                                                (box['bottomright']['x'], 
                                                box['bottomright']['y']), 
                                                (255,0,0), 6)
                    cv2.putText(self.img_out, box['label'], 
                               (box['topleft']['x'], 
                               box['topleft']['y'] - 12), 0, 0.6, (255,0,0) ,6//3)

            print(self.img_out.shape)
            self.image_lock.release()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号