draw_utils.py 文件源码

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

项目:pybot 作者: spillai 项目源码 文件源码
def publish_image_t(pub_channel, im, jpeg=False, flip_rb=True): 
    global g_viz_pub
    out = image_t()

    # Populate appropriate fields
    h,w = im.shape[:2]
    c = 3
    out.width, out.height = w, h
    out.row_stride = w*c
    out.utime = 1

    # Propagate encoded/raw data, 
    image = cv2.cvtColor(im, cv2.COLOR_GRAY2BGR) if im.ndim == 2 else im
    if flip_rb and im.ndim == 3: 
        rarr, barr = image[:,:,2].copy(), image[:,:,0].copy()
        image[:,:,0], image[:,:,2] = rarr, barr

    # Propagate appropriate encoding 
    if jpeg: 
        out.pixelformat = image_t.PIXEL_FORMAT_MJPEG
    else: 
        out.pixelformat = image_t.PIXEL_FORMAT_RGB

    out.data = cv2.imencode('.jpg', image)[1] if jpeg else image.tostring()
    out.size = len(out.data)
    out.nmetadata = 0

    # Pub
    g_viz_pub.lc.publish(pub_channel, out.encode())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号