5.17. sail.Bmcv
5.17.1. __init__
- Interface:
def __init__(self, handle: sail.Handle)
Parameters: * handle : sail.Handle
Handle instance
5.17.2. bm_image_to_tensor
Convert image to tensor.
- Interface:
def bm_image_to_tensor(self, image: sail.BMImage | sail.BMImageArray ) -> sail.Tensor
Parameters: * image : sail.BMImage | sail.BMImageArray
BMImage/BMImageArray instance
Returns: Return sail.Tensor instance
- Interface:
def bm_image_to_tensor(self, image: sail.BMImage | sail.BMImageArray, tensor: sail.Tensor)
Parameters: * image : sail.BMImage | sail.BMImageArray
BMImage/BMImageArray instance
tensor : sail.Tensor
Tensor instance
5.17.3. tensor_to_bm_image
Convert tensor to image.
- Interface:
def tensor_to_bm_image(self, tensor: sail.Tensor, bgr2rgb: bool = False) -> sail.BMImage
Parameters: * tensor : sail.Tensor
Tensor instance
bgr2rgb : bool
Swap color channel, default: False
Returns: Return BMImage instance
- Interface:
def tensor_to_bm_image(self, tensor: sail.Tensor, img: sail.BMImage | sail.BMImageArray, bgr2rgb: bool = False)
Parameters: * tensor : sail.Tensor
Tensor instance
img : sail.BMImage
BMImage instance
bgr2rgb : bool
Swap color channel, default: False
5.17.4. crop_and_resize
Crop then resize an image or an image array.
- Interface:
def crop_and_resize(self, input: sail.BMImage, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int, resize_w: int, resize_h: int, resize_alg: bmcv_resize_algorithm = BMCV_INTER_NEAREST )->sail.BMImage
Parameters: * input : sail.BMImage
Input image
crop_x0 : int
Start point x of the crop window
crop_y0 : int
Start point y of the crop window
crop_w : int
Width of the crop window
crop_h : int
Height of the crop window
resize_w : int
Target width
resize_h : int
Target height
resize_alg : bmcv_resize_algorithm
Resize algorithm, default is BMCV_INTER_NEAREST
Returns:
output : sail.BMImage
Output image
- Interface:
def crop_and_resize(self, input: sail.BMImageArray, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int, resize_w: int, resize_h: int, resize_alg: bmcv_resize_algorithm = BMCV_INTER_NEAREST )-> sail.BMImageArray
Parameters: * input : sail.BMImageArray
Input image array
crop_x0 : int
Start point x of the crop window
crop_y0 : int
Start point y of the crop window
crop_w : int
Width of the crop window
crop_h : int
Height of the crop window
resize_w : int
Target width
resize_h : int
Target height
resize_alg : bmcv_resize_algorithm
Resize algorithm, default is BMCV_INTER_NEAREST
Returns: * output : sail.BMImageArray
Output image array
5.17.5. crop
Crop an image or an image array with given window.
- Interface:
def crop(self, input: sail.BMImage, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int)-> sail.BMImage
Parameters: * input : sail.BMImage
Input image
crop_x0 : int
Start point x of the crop window
crop_y0 : int
Start point y of the crop window
crop_w : int
Width of the crop window
crop_h : int
Height of the crop window
Returns:
output : sail.BMImage
Output image
- Interface:
def crop(self, input, crop_x0, crop_y0, crop_w, crop_h):
Parameters: * input : sail.BMImageArray
Input image array
crop_x0 : int
Start point x of the crop window
crop_y0 : int
Start point y of the crop window
crop_w : int
Width of the crop window
crop_h : int
Height of the crop window
Returns:
output : sail.BMImageArray
Output image array
5.17.6. resize
Resize an image or an image array
- Interface:
def resize(self, input: sail.BMImage, resize_w: int, resize_h: int, resize_alg: bmcv_resize_algorithm = BMCV_INTER_NEAREST)-> sail.BMImage
Parameters: * input : sail.BMImage
Input image
resize_w : int
Target width
resize_h : int
Target height
resize_alg : bmcv_resize_algorithm
Resize algorithm, default is BMCV_INTER_NEAREST
Returns:
output : sail.BMImage
Output image
- Interface:
def resize(self, input: sail.BMImageArray, resize_w: int, resize_h: int, resize_alg: bmcv_resize_algorithm = BMCV_INTER_NEAREST)-> sail.BMImageArray
Parameters: * input : sail.BMImageArray
Input image array
resize_w : int
Target width
resize_h : int
Target height
resize_alg : bmcv_resize_algorithm
Resize algorithm, default is BMCV_INTER_NEAREST
Returns:
output : sail.BMImageArray
Output image array
5.17.7. vpp_crop_and_resize
Crop then resize an image or an image array using vpp
- Interface:
def vpp_crop_and_resize(self, input: sail.BMImage, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int, resize_w: int, resize_h: int)-> sail.BMImage
Parameters: * input : sail.BMImage
Input image
crop_x0 : int
Start point x of the crop window
crop_y0 : int
Start point y of the crop window
crop_w : int
Width of the crop window
crop_h : int
Height of the crop window
resize_w : int
Target width
resize_h : int
Target height
Returns:
output : sail.BMImage
Output image
- Interface:
def vpp_crop_and_resize(self, input: sail.BMImageArray, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int, resize_w: int, resize_h: int)-> sail.BMImageArray
Parameters: * input : sail.BMImageArray
Input image array
crop_x0 : int
Start point x of the crop window
crop_y0 : int
Start point y of the crop window
crop_w : int
Width of the crop window
crop_h : int
Height of the crop window
resize_w : int
Target width
resize_h : int
Target height
Returns:
output : sail.BMImageArray
Output image array
5.17.8. vpp_crop_and_resize_padding
Crop then resize an image or an image array using vpp.
- Interface:
def vpp_crop_and_resize_padding(self, input: sail.BMImage, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int, resize_w: int, resize_h: int, padding: PaddingAtrr)-> sail.BMImage
Parameters:
input : sail.BMImage
Input image
crop_x0 : int
Start point x of the crop window
crop_y0 : int
Start point y of the crop window
crop_w : int
Width of the crop window
crop_h : int
Height of the crop window
resize_w : int
Target width
resize_h : int
Target height
padding : PaddingAtrr
padding info
Returns: * output : sail.BMImage
Output image
- Interface:
def vpp_crop_and_resize_padding(self, input: sail.BMImageArray, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int, resize_w: int, resize_h: int, padding: PaddingAtrr)-> sail.BMImageArray
Parameters:
input : sail.BMImageArray
Input image array
crop_x0 : int
Start point x of the crop window
crop_y0 : int
Start point y of the crop window
crop_w : int
Width of the crop window
crop_h : int
Height of the crop window
resize_w : int
Target width
resize_h : int
Target height
padding : PaddingAtrr
padding info
Returns: * output : sail.BMImageArray
Output image array
5.17.9. vpp_crop
Crop an image or an image array with given window using vpp.
- Interface:
def vpp_crop(self, input: sail.BMImage, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int)-> sail.BMImage
Parameters: * input : sail.BMImage
Input image
crop_x0 : int
Start point x of the crop window
crop_y0 : int
Start point y of the crop window
crop_w : int
Width of the crop window
crop_h : int
Height of the crop window
Returns: * output : sail.BMImage
Output image
- Interface:
def vpp_crop(self, input: sail.BMImageArray, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int)-> sail.BMImageArray
Parameters: * input : sail.BMImageArray
Input image array
crop_x0 : int
Start point x of the crop window
crop_y0 : int
Start point y of the crop window
crop_w : int
Width of the crop window
crop_h : int
Height of the crop window
Returns: * output : sail.BMImageArray
Output image array
5.17.10. vpp_resize
Resize an image or an image array with interpolation of INTER_NEAREST using vpp.
- Interface:
def vpp_resize(self, input: sail.BMImage, resize_w: int, resize_h: int)-> sail.BMImage
Parameters:
input : sail.BMImage
Input image
resize_w : int
Target width
resize_h : int
Target height
Returns:
output : sail.BMImage
Output image
- Interface:
def vpp_resize(self, input: sail.BMImageArray, resize_w: int, resize_h: int)-> sail.BMImageArray
Parameters:
input : sail.BMImageArray
Input image array
resize_w : int
Target width
resize_h : int
Target height
Returns:
output : sail.BMImageArray
Output image array
- Interface:
def vpp_resize(self, input: sail.BMImage, output: sail.BMImage, resize_w: int, resize_h: int)
Parameters:
input : sail.BMImage
Input image
output : sail.BMImage
Output image
resize_w : int
Target width
resize_h : int
Target height
- Interface:
def vpp_resize(self, input: sail.BMImageArray, output: sail.BMImageArray, resize_w: int, resize_h: int)
Parameters:
input : sail.BMImageArray
Input image
output : sail.BMImageArray
Output image
resize_w : int
Target width
resize_h : int
Target height
5.17.11. vpp_resize_padding
Resize an image or an image array with interpolation of INTER_NEAREST using vpp.
- Interface:
def vpp_resize_padding(self, input: sail.BMImage, resize_w: int, resize_h: int, padding: PaddingAtrr)-> sail.BMImage
Parameters:
input : sail.BMImage
Input image
resize_w : int
Target width
resize_h : int
Target height
padding : PaddingAtrr
padding info
Returns:
output : sail.BMImage
Output image
- Interface:
def vpp_resize_padding(self, input: sail.BMImageArray, resize_w: int, resize_h: int, padding: PaddingAtrr)-> sail.BMImageArray
Parameters:
input : sail.BMImageArray
Input image
resize_w : int
Target width
resize_h : int
Target height
padding : PaddingAtrr
padding info
Returns:
output : sail.BMImageArray
Output image
5.17.12. warp
Applies an affine transformation to an image or an image array.
- Interface:
def warp(self, input: sail.BMImage, matrix: 2d list)-> sail.BMImage
Parameters:
input : sail.BMImage
Input image
matrix: 2d list
2x3 transformation matrix
Returns:
output : sail.BMImage
Output image
- Interface:
def warp(self, input: sail.BMImageArray, matrix: 2d list)-> sail.BMImageArray
Parameters:
input : sail.BMImageArray
Input image array
matrix: 2d list
2x3 transformation matrix
Returns:
output : sail.BMImageArray
Output image array
5.17.13. convert_to
Applies a linear transformation to an image or an image array.
- Interface:
def convert_to(self, input: sail.BMImage, alpha_beta: tuple)-> sail.BMImage
Parameters:
input : sail.BMImage
Input image
alpha_beta: tuple
(a0, b0), (a1, b1), (a2, b2) factors
Returns:
output : sail.BMImage
Output image
- Interface:
def convert_to(self, input: sail.BMImageArray, alpha_beta: tuple)-> sail.BMImageArray
Parameters:
input : sail.BMImageArray
Input image array
alpha_beta: tuple
(a0, b0), (a1, b1), (a2, b2) factors
Returns:
output : sail.BMImageArray
Output image array
- Interface:
def convert_to(self, input: sail.BMImage, output: sail.BMImage, alpha_beta: tuple)
Parameters:
input : sail.BMImage
Input image
output : sail.BMImage
Output image
alpha_beta: tuple
(a0, b0), (a1, b1), (a2, b2) factors
- Interface:
def convert_to(self, input: sail.BMImageArray, output: sail.BMImageArray, alpha_beta: tuple):
Parameters:
input : sail.BMImageArray
Input image array
output : sail.BMImageArray
Output image array
alpha_beta: tuple
(a0, b0), (a1, b1), (a2, b2) factors
5.17.14. yuv2bgr
Convert an image or an image array from YUV to BGR.
- Interface:
def yuv2bgr(self, input: sail.BMImage)-> sail.BMImage
Parameters:
input : sail.BMImage
Input image
Returns:
output : sail.BMImage
Output image
- Interface:
def yuv2bgr(self, input: sail.BMImageArray)-> sail.BMImageArray
Parameters:
input : sail.BMImageArray
Input image array
Returns:
output : sail.BMImageArray
Output image array
5.17.15. rectangle
Draw a rectangle on input image.
- Interface:
def rectangle(self, image: sail.BMImage, x0: int, y0: int, w: int, h: int, color: tuple, thickness: int = 1)-> int
Parameters:
image : sail.BMImage
Input image
x0 : int
Start point x of rectangle
y0 : int
Start point y of rectangle
w : int
Width of rectangle
h : int
Height of rectangle
color : tuple
Color of rectangle
thickness : int
Thickness of rectangle, default: 1
Returns:
process_status : int
0 for success and others for failure
5.17.16. imwrite
Save the image to the specified file.
- Interface:
def imwrite(self, file_name: str, image: sail.BMImage)-> int
Parameters:
file_name : str
Name of the file
output : sail.BMImage
Image to be saved
Returns:
process_status : int
0 for success and others for failure
5.17.17. get_handle
Get Handle instance.
- Interface:
def get_handle(self)-> sail.Handle
Returns:
handle: sail.Handle
Handle instance
5.17.18. crop_and_resize_padding
Crop then resize an image.
- Interface:
def crop_and_resize_padding(self, input: sail.BMImage, crop_x0: int, crop_y0: int, crop_w: int, crop_h: int, resize_w: int, resize_h: int, padding: PaddingAtrr, resize_alg: bmcv_resize_algorithm = BMCV_INTER_NEAREST )-> sail.BMImage
Parameters:
input : sail.BMImage
Input image
crop_x0 : int
Start point x of the crop window
crop_y0 : int
Start point y of the crop window
crop_w : int
Width of the crop window
crop_h : int
Height of the crop window
resize_w : int
Target width
resize_h : int
Target height
padding : PaddingAtrr
padding info
resize_alg : bmcv_resize_algorithm
Resize algorithm, default is BMCV_INTER_NEAREST
Returns:
output : sail.BMImage
Output image
5.17.19. rectangle_
Draw a rectangle on input image.
- Interface:
def rectangle_(self, image: sail.bm_image, x0: int, y0: int, w: int, h: int, color: tuple, thickness: int = 1)-> int
Parameters:
image : sail.bm_image
Input image
x0 : int
Start point x of rectangle
y0 : int
Start point y of rectangle
w : int
Width of rectangle
h : int
Height of rectangle
color : tuple
Color of rectangle
thickness : int
Thickness of rectangle
Returns:
process_status : int
0 for success and others for failure
5.17.20. imwrite_
Save the image to the specified file.
- Interface:
def imwrite_(self, file_name: str, image: sail.bm_image)-> int
Parameters:
file_name : str
Name of the file
output : sail.bm_image
Image to be saved
Returns:
process_status : int
0 for success and others for failure
5.17.21. convert_format
Convert input to output format or convert an image to BGR PLANAR format.
- Interface:
def convert_format(self, input: sail.BMImage, output: sail.BMImage)
Parameters:
input : sail.BMImage
BMimage instance
output : sail.BMImage
output image
- Interface:
def convert_format(self, input: sail.BMImage)-> sail.BMImage
Parameters:
input : sail.BMImage
BMimage instance
Returns:
output : sail.BMImage
output image
5.17.22. vpp_convert_format
Convert input to output format or convert an image to BGR PLANAR format using vpp.
- Interface:
def vpp_convert_format(self, input: sail.BMImage, output: sail.BMImage)
Parameters:
input : sail.BMImage
BMimage instance
output : sail.BMImage
output image
- Interface:
def vpp_convert_format(self, input):
Parameters:
input : sail.BMImage
BMimage instance
Returns:
output : sail.BMImage
output image
5.17.23. putText
Draws a text on the image
- Interface:
def putText(self, input: sail.BMImage, text: str, x: int, y: int, color: tuple, fontScale: float, thickness: int)-> int
Parameters:
input : sail.BMImage
BMimage instance
text: str
Text to write on an image.
x: int
Start point x
y: int
Start point y
color : tuple
Color of text
fontScale : float
Size of font
thickness : int
Thickness of text
Returns:
process_status : int
0 for success and others for failure
5.17.24. putText_
Draws a text on the image
- Interface:
def putText_(self, input, text, x, y, color, fontScale, thickness):
Parameters:
input : sail.bm_image
bm_image instance
text: str
Text to write on an image.
x: int
Start point x
y: int
Start point y
color : tuple
Color of text
thickness : int
Thickness of text
Returns:
process_status : int
0 for success and others for failure
5.17.25. image_add_weighted
Calculates the weighted sum of two images
- Interface:
def image_add_weighted(self, input0: sail.BMImage, alpha: float, input1: float, beta: float, gamma: float, output: BMImage)
Parameters:
input0 : sail.BMImage
BMimage instance.
alpha : float
alpha instance.
input1 : sail.BMImage
BMImage instance.
beta: float
beta instance.
gamma: float
gamma instance.
output: BMImage
result BMImage, output = input1 * alpha + input2 * beta + gamma.
- Interface:
def image_add_weighted(self, input0: sail.BMImage, alpha: float, input1: sail.BMImage, beta: float, gamma: float)-> BMImage
Parameters:
input0 : sail.BMImage
BMimage instance.
alpha : float
alpha instance.
input1 : sail.BMImage
BMImage instance.
beta: float
beta instance.
gamma: float
gamma instance.
Returns:
output: BMImage
result BMImage, output = input1 * alpha + input2 * beta + gamma.
5.17.26. image_copy_to
Copy the input to the output.
- Interface:
def image_copy_to(self, input: BMImage|BMImageArray, output: BMImage|BMImageArray, start_x: int, start_y: int)
Parameters:
input: BMImage|BMImageArray
Input image or image array.
output: BMImage|BMImageArray
Output image or image array.
start_x: int
Point start x.
start_y: int
Point start y.
5.17.27. image_copy_to_padding
Copy the input to the output width padding.
- Interface:
def image_copy_to_padding(self, input: BMImage|BMImageArray, output: BMImage|BMImageArray, padding_r: int, padding_g: int, padding_b: int, start_x: int, start_y: int)
Parameters:
input: BMImage|BMImageArray
Input image or image array.
output: BMImage|BMImageArray
Output image or image array.
padding_r: int
r value for padding.
padding_g: int
g value for padding.
padding_b: int
b value for padding.
start_x: int
point start x.
start_y: int
point start y.
5.17.28. nms
Do nms use tpu.
- Interface:
def nms(self, input: [float, float, float, float, float], threshold: float)-> numpy.ndarray[Any, numpy.dtype[numpy.float32]]
Parameters:
input: [float, float, float, float, float]
input proposal array, shape must be (self, n,5) n<56000, proposal:[left,top,right,bottom,score].
threshold: float
nms threshold.
Returns:
return nms result, numpy.ndarray[Any, numpy.dtype[numpy.float32]]
5.17.29. drawPoint
Draw Point on input image.
- Interface:
def drawPoint(self, image: BMImage, center: Tuple[int, int], color: Tuple[int, int, int], radius: int) -> int:
Parameters:
image: BMImage
Input image
center: Tuple[int, int]
center of point, (point_x, point_y)
color: Tuple[int, int, int],
color of drawn, (b,g,r)
radius: int
Radius of drawn
5.17.30. drawPoint_
Draw Point on input image.
- Interface:
def drawPoint_(self, image: bm_image, center: Tuple[int, int], color: Tuple[int, int, int], radius: int) -> int:
Parameters:
image: bm_image
Input image
center: Tuple[int, int]
center of point, (point_x, point_y)
color: Tuple[int, int, int]
color of drawn, (b,g,r)
radius: int
Radius of drawn
5.17.31. warp_perspective
Applies a perspective transformation to an image.
- Interface:
def warp_perspective(input: BMImage, coordinate: [[int,int],[int,int],[int,int],[int,int]], output_width: int, output_height: int, format: bm_image_format_ext = FORMAT_BGR_PLANAR, dtype: bm_image_data_format_ext = DATA_TYPE_EXT_1N_BYTE, use_bilinear: int = 0 ) -> BMImage:
Parameters:
input: BMImage
Input image
coordinate: [[int,int],[int,int],[int,int],[int,int]]
- Original coordinate, like(left_top.x, left_top.y), (right_top.x, right_top.y),
(left_bottom.x, left_bottom.y), (right_bottom.x, right_bottom.y)
output_width: int
Output width
output_height: int
Output height
format : bm_image_format_ext
Output image format, Only FORMAT_BGR_PLANAR,FORMAT_RGB_PLANAR
dtype: bm_image_data_format_ext
Output image dtype, Only DATA_TYPE_EXT_1N_BYTE,DATA_TYPE_EXT_4N_BYTE
use_bilinear: int
Bilinear use flag.
Returns:
Output image
5.17.32. get_bm_data_type
Convert bm_image_data_format_ext to bm_data_type_t
- Interface:
def get_bm_data_type(self, format: bm_image_data_format_ext) -> bm_data_type_t:
5.17.33. get_bm_image_data_format
Convert bm_data_type_t to bm_image_data_format_ext
- Interface:
def get_bm_image_data_format(self, dtype: bm_data_type_t) -> bm_image_data_format_ext:
5.17.34. imdecode
Load image from system memory
- Interface:
def imdecode(self, data_bytes: bytes) -> BMImage:
Parameters:
data_bytes: bytes
image data bytes in system memory
Returns:
return decoded image
5.17.35. fft
1d or 2d fft (only real part, or real part and imaginary part)
- Interface:
def fft(self, forward: bool, input_real: Tensor)-> list[Tensor]:
Parameters:
forward: bool
positive transfer
input_real: Tensor
input tensor
Returns:
return list[Tensor], The real and imaginary part of output
- Interface:
def fft(self, forward: bool, input_real: Tensor, input_imag: Tensor) -> list[Tensor]:
Parameters:
forward: bool
positive transfer
input_real: Tensor
input tensor real part
input_imag: Tensor
input tensor imaginary part
Returns:
return list[Tensor], The real and imaginary part of output