5.16. sail.bm_image

bm_image是BMCV中的基本结构,封装了一张图像的主要信息,是后续BMImage和BMImageArray的内部元素。

接口形式:
def width(self) -> int

返回值说明:

  • width : int

返回图像的宽。

接口形式:
def height(self) -> int

返回值说明:

  • height : int

返回图像的高。

接口形式:
def format(self) -> sail.Format

返回值说明:

  • format : sail.Format

返回图像的格式。

接口形式:
def dtype(self) -> sail.ImgDtype

返回值说明:

  • dtype : sail.ImgDtype

返回图像的数据格式。

示例代码:
import sophon.sail as sail

if __name__ == '__main__':
    tpu_id = 0
    handle = sail.Handle(tpu_id)
    image_name = "your_image.jpg"
    decoder = sail.Decoder(image_name,True,tpu_id)
    BMimg = decoder.read(handle)# here is a sail.BMImage
    bmimg = BMimg.data()# here is a sail.bm_image
    print(bmimg.width(),bmimg.height(),bmimg.format(),bmimg.dtype())