A wrapper around Simd Library API. More...
Public Member Functions | |
def | Init (dir="") |
Initializes Simd.Lib class (loads Simd Library binaries). More... | |
str | Version () |
Gets version of Simd Library. More... | |
str | CpuDesc (Simd.CpuDesc type) |
Gets string with CPU description. More... | |
int | CpuInfo (Simd.CpuInfo type) |
Gets information about CPU. More... | |
str | SysInfo () |
Gets string with CPU and Simd Library description. More... | |
str | PerformanceStatistic () |
Gets string with internal Simd Library performance statistics. More... | |
ctypes.c_void_p | Allocate (int size, int align) |
Allocates aligned memory block. More... | |
def | Free (ctypes.c_void_p ptr) |
Frees aligned memory block. More... | |
int | Align (int size, int align) |
Gets aligned size. More... | |
int | Alignment () |
Gets alignment required for the most productive work of Simd Library. More... | |
def | Release (ctypes.c_void_p context) |
Releases context created with using of Simd Library API. More... | |
int | GetThreadNumber () |
Gets number of threads used by Simd Library to parallelize some algorithms. More... | |
def | SetThreadNumber (int threadNumber) |
Sets number of threads used by Simd Library to parallelize some algorithms. More... | |
def | ClearMmx () |
Clears MMX registers. More... | |
bool | GetFastMode () |
Gets current CPU Flush-To-Zero (FTZ) and Denormals-Are-Zero (DAZ) flags. More... | |
def | SetFastMode (bool fast) |
Sets current CPU Flush-To-Zero (FTZ) and Denormals-Are-Zero (DAZ) flags. More... | |
ctypes.c_uint32 | Crc32 (ctypes.c_void_p src, int size) |
Gets 32-bit cyclic redundancy check (CRC32) for current data. More... | |
def | Crc32c (ctypes.c_void_p src, int size) |
Gets 32-bit cyclic redundancy check (CRC32c) for current data. More... | |
def | AbsGradientSaturatedSum (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Puts to destination 8-bit gray image saturated sum of absolute gradient for every point of source 8-bit gray image. More... | |
def | BgraToBgr (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Converts 32-bit BGRA image to 24-bit BGR image. More... | |
def | BgraToGray (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Converts 32-bit BGRA image to 8-bit gray image. More... | |
def | BgraToRgb (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Converts 32-bit BGRA image to 24-bit RGB image. More... | |
def | BgraToRgba (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Converts 32-bit BGRA image to 32-bit RGBA image and back. More... | |
def | BgraToYuv420p (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p y, int yStride, ctypes.c_void_p u, int uStride, ctypes.c_void_p v, int vStride, yuvType=Simd.YuvType.Bt601) |
Converts 32-bit BGRA image to YUV420P. More... | |
def | BgrToBgra (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride, alpha=255) |
Converts 24-bit BGR to 32-bit BGRA image image. More... | |
def | BgrToGray (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Converts 24-bit BGR image to 8-bit gray image. More... | |
def | BgrToRgb (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Converts 24-bit BGR image to 24-bit RGB image and back. More... | |
def | BgrToYuv420p (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p y, int yStride, ctypes.c_void_p u, int uStride, ctypes.c_void_p v, int vStride, yuvType=Simd.YuvType.Bt601) |
Converts 24-bit BGR image to YUV420P. More... | |
def | DeinterleaveUv (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p u, int uStride, ctypes.c_void_p v, int vStride) |
Deinterleaves 16-bit UV interleaved image into separated 8-bit U and V planar images. More... | |
def | Copy (ctypes.c_void_p src, int srcStride, int width, int height, int pixelSize, ctypes.c_void_p dst, int dstStride) |
Copies an image. More... | |
def | FillPixel (ctypes.c_void_p dst, int stride, int width, int height, array.array('B') pixel) |
Fills image by value of given pixel. More... | |
def | GrayToBgra (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride, alpha=255) |
Converts 8-bit gray to 32-bit BGRA (32-bit RGBA) image. More... | |
def | GrayToBgr (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Converts 8-bit gray image to 24-bit BGR (24-bit RGB) image and back. More... | |
def | GrayToY (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Converts 8-bit gray image to 8-bit Y-plane of YUV image. More... | |
bool | ImageSaveToFile (ctypes.c_void_p src, int stride, int width, int height, Simd.PixelFormat format, Simd.ImageFile file, int quality, str path) |
Saves an image to file in given image file format. More... | |
def | ImageLoadFromFile (str path, Simd.PixelFormat desiredFormat) |
Loads an image from file. More... | |
def | InterleaveUv (ctypes.c_void_p u, int uStride, ctypes.c_void_p v, int vStride, int width, int height, ctypes.c_void_p uv, int uvStride) |
Interleaves separate 8-bit U and V planar images into 16-bit UV interleaved image. More... | |
def | RgbToBgra (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride, alpha=255) |
Converts 24-bit RGB to 32-bit BGRA image image. More... | |
def | RgbToGray (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Converts 24-bit RGB image to 8-bit gray image. More... | |
def | RgbaToGray (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Converts 32-bit RGBA image to 8-bit gray image. More... | |
ctypes.c_void_p | ResizerInit (int srcX, int srcY, int dstX, int dstY, int channels, Simd.ResizeChannel type, Simd.ResizeMethod method) |
Creates resize context. More... | |
def | ResizerRun (ctypes.c_void_p resizer, ctypes.c_void_p src, int srcStride, ctypes.c_void_p dst, int dstStride) |
Performs image resizing. More... | |
def | SynetSetInput (ctypes.c_void_p src, int width, int height, int stride, Simd.PixelFormat srcFormat, array.array('f') lower, array.array('f') upper, ctypes.c_void_p dst, int channels, Simd.TensorFormat dstFormat) |
Sets image to the input of neural network of Synet Framework. More... | |
ctypes.c_void_p | WarpAffineInit (int srcW, int srcH, int srcS, int dstW, int dstH, int dstS, channels, array.array('f') mat, Simd.WarpAffineFlags flags, array.array('B') border) |
Creates wrap affine context. More... | |
def | WarpAffineRun (ctypes.c_void_p context, ctypes.c_void_p src, ctypes.c_void_p dst) |
Performs warp affine for current image. More... | |
def | YToGray (ctypes.c_void_p src, int srcStride, int width, int height, ctypes.c_void_p dst, int dstStride) |
Converts 8-bit Y-plane of YUV image to 8-bit gray image. More... | |
def | Yuv420pToBgr (ctypes.c_void_p y, int yStride, ctypes.c_void_p u, int uStride, ctypes.c_void_p v, int vStride, int width, int height, ctypes.c_void_p dst, int dstStride, yuvType=Simd.YuvType.Bt601) |
Converts YUV420P image to 24-bit BGR. More... | |
def | Yuv420pToBgra (ctypes.c_void_p y, int yStride, ctypes.c_void_p u, int uStride, ctypes.c_void_p v, int vStride, int width, int height, ctypes.c_void_p dst, int dstStride, alpha=255, yuvType=Simd.YuvType.Bt601) |
Converts YUV420P image to 32-bit BGRA. More... | |
def | Yuv420pToRgb (ctypes.c_void_p y, int yStride, ctypes.c_void_p u, int uStride, ctypes.c_void_p v, int vStride, int width, int height, ctypes.c_void_p dst, int dstStride, yuvType=Simd.YuvType.Bt601) |
Converts YUV420P image to 24-bit RGB. More... | |
Detailed Description
A wrapper around Simd Library API.
Member Function Documentation
◆ Init()
def Init | ( | dir = "" | ) |
Initializes Simd.Lib class (loads Simd Library binaries).
- Note
- This method must be called before any using of this class.
- Parameters
-
dir - a directory with Simd Library binaries (Simd.dll or libSimd.so). By default it is empty string. That means that binaries will be searched in the directory with current Python file.
◆ Version()
str Version | ( | ) |
Gets version of Simd Library.
- Returns
- A string with version.
◆ CpuDesc()
str CpuDesc | ( | Simd.CpuDesc | type | ) |
Gets string with CPU description.
- Parameters
-
type - a type of CPU description.
- Returns
- A string with system description.
◆ CpuInfo()
int CpuInfo | ( | Simd.CpuInfo | type | ) |
Gets information about CPU.
- Parameters
-
type - a type of CPU information.
- Returns
- integer value of given CPU parameter.
◆ SysInfo()
str SysInfo | ( | ) |
Gets string with CPU and Simd Library description.
- Returns
- string with CPU and Simd Library description.
◆ PerformanceStatistic()
str PerformanceStatistic | ( | ) |
Gets string with internal Simd Library performance statistics.
- Note
- Simd Library must be built with switched on SIMD_PERF flag.
- Returns
- string with internal Simd Library performance statistics.
◆ Allocate()
ctypes.c_void_p Allocate | ( | int | size, |
int | align | ||
) |
Allocates aligned memory block.
- Note
- The memory allocated by this function is must be deleted by function Simd.Lib.Free.
- Parameters
-
size - an original size. align - a required alignment.
- Returns
- return a pointer to allocated memory.
◆ Free()
def Free | ( | ctypes.c_void_p | ptr | ) |
Frees aligned memory block.
- Note
- This function frees a memory allocated by function Simd.Lib.Allocate.
- Parameters
-
ptr - a pointer to the memory to be deleted.
◆ Align()
int Align | ( | int | size, |
int | align | ||
) |
Gets aligned size.
- Parameters
-
size - an original size. align - a required alignment.
- Returns
- return an aligned size.
◆ Alignment()
int Alignment | ( | ) |
Gets alignment required for the most productive work of Simd Library.
- Returns
- return a required alignment.
◆ Release()
def Release | ( | ctypes.c_void_p | context | ) |
Releases context created with using of Simd Library API.
- Parameters
-
context - a context to be released.
◆ GetThreadNumber()
int GetThreadNumber | ( | ) |
Gets number of threads used by Simd Library to parallelize some algorithms.
- Returns
- thread number used by Simd Library.
◆ SetThreadNumber()
def SetThreadNumber | ( | int | threadNumber | ) |
Sets number of threads used by Simd Library to parallelize some algorithms.
- Parameters
-
threadNumber - number used by Simd Library.
◆ ClearMmx()
def ClearMmx | ( | ) |
Clears MMX registers.
Clears MMX registers (runs EMMS instruction). It is x86 specific functionality.
◆ GetFastMode()
bool GetFastMode | ( | ) |
Gets current CPU Flush-To-Zero (FTZ) and Denormals-Are-Zero (DAZ) flags.
It is used in order to process subnormal numbers.
- Returns
- current 'fast' mode.
◆ SetFastMode()
def SetFastMode | ( | bool | fast | ) |
Sets current CPU Flush-To-Zero (FTZ) and Denormals-Are-Zero (DAZ) flags.
It is used in order to process subnormal numbers.
- Parameters
-
fast - a value of 'fast' mode to set.
◆ Crc32()
ctypes.c_uint32 Crc32 | ( | ctypes.c_void_p | src, |
int | size | ||
) |
Gets 32-bit cyclic redundancy check (CRC32) for current data.
Calculation is performed for polynomial 0xEDB88320.
- Parameters
-
src - a pointer to data. size - a size of the data.
- Returns
- 32-bit cyclic redundancy check (CRC32).
◆ Crc32c()
def Crc32c | ( | ctypes.c_void_p | src, |
int | size | ||
) |
Gets 32-bit cyclic redundancy check (CRC32c) for current data.
Calculation is performed for polynomial 0x1EDC6F41 (Castagnoli-crc).
- Parameters
-
src - a pointer to data. size - a size of the data.
- Returns
- 32-bit cyclic redundancy check (CRC32c).
◆ AbsGradientSaturatedSum()
def AbsGradientSaturatedSum | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Puts to destination 8-bit gray image saturated sum of absolute gradient for every point of source 8-bit gray image.
- Parameters
-
src - a pointer to pixels data of input 8-bit gray image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 8-bit gray image. dstStride - a row size of output image in bytes.
◆ BgraToBgr()
def BgraToBgr | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Converts 32-bit BGRA image to 24-bit BGR image.
Also it can be used for 32-bit RGBA to 24-bit RGB conversion.
- Parameters
-
src - a pointer to pixels data of input 32-bit BGRA (or 32-bit RGBA) image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 24-bit BGR (or 24-bit RGB) image. dstStride - a row size of output image in bytes.
◆ BgraToGray()
def BgraToGray | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Converts 32-bit BGRA image to 8-bit gray image.
- Parameters
-
src - a pointer to pixels data of input 32-bit BGRA. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 8-bit gray image. dstStride - a row size of output image in bytes.
◆ BgraToRgb()
def BgraToRgb | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Converts 32-bit BGRA image to 24-bit RGB image.
Also it can be used for 32-bit RGBA to 24-bit BGR conversion.
- Parameters
-
src - a pointer to pixels data of input 32-bit BGRA (or 32-bit RGBA) image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 24-bit RGB (or 24-bit BGR) image. dstStride - a row size of output image in bytes.
◆ BgraToRgba()
def BgraToRgba | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Converts 32-bit BGRA image to 32-bit RGBA image and back.
- Parameters
-
src - a pointer to pixels data of input 32-bit BGRA (or 32-bit RGBA) image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 32-bit RGBA (or 32-bit BGRA) image. dstStride - a row size of output image in bytes.
◆ BgraToYuv420p()
def BgraToYuv420p | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | y, | ||
int | yStride, | ||
ctypes.c_void_p | u, | ||
int | uStride, | ||
ctypes.c_void_p | v, | ||
int | vStride, | ||
yuvType = Simd.YuvType.Bt601 |
|||
) |
Converts 32-bit BGRA image to YUV420P.
The input BGRA and output Y images must have the same width and height. The output U and V images must have the same width and height (half size relative to Y component).
- Parameters
-
src - a pointer to pixels data of input 32-bit BGRA image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. y - a pointer to pixels data of output 8-bit image with Y color plane. yStride - a row size of the y image. u - a pointer to pixels data of output 8-bit image with U color plane. uStride - a row size of the u image. v - a pointer to pixels data of output 8-bit image with V color plane. vStride - a row size of the v image. yuvType - a type of output YUV image (see descriprion of Simd.YuvType).
◆ BgrToBgra()
def BgrToBgra | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride, | ||
alpha = 255 |
|||
) |
Converts 24-bit BGR to 32-bit BGRA image image.
Also it can be used for 24-bit RGB to 32-bit RGBA conversion.
- Parameters
-
src - a pointer to pixels data of input 24-bit BGR (or 24-bit RGB) image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 32-bit BGRA (or 32-bit RGBA) image. dstStride - a row size of output image in bytes. alpha - a value of alpha channel. By default it is equal to 255.
◆ BgrToGray()
def BgrToGray | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Converts 24-bit BGR image to 8-bit gray image.
- Parameters
-
src - a pointer to pixels data of input 24-bit BGR. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 8-bit gray image. dstStride - a row size of output image in bytes.
◆ BgrToRgb()
def BgrToRgb | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Converts 24-bit BGR image to 24-bit RGB image and back.
- Parameters
-
src - a pointer to pixels data of input 24-bit BGR (or 24-bit RGB) image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 24-bit RGB (or 24-bit BGR) image. dstStride - a row size of output image in bytes.
◆ BgrToYuv420p()
def BgrToYuv420p | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | y, | ||
int | yStride, | ||
ctypes.c_void_p | u, | ||
int | uStride, | ||
ctypes.c_void_p | v, | ||
int | vStride, | ||
yuvType = Simd.YuvType.Bt601 |
|||
) |
Converts 24-bit BGR image to YUV420P.
The input BGR and output Y images must have the same width and height. The output U and V images must have the same width and height (half size relative to Y component).
- Parameters
-
src - a pointer to pixels data of input 24-bit BGR image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. y - a pointer to pixels data of output 8-bit image with Y color plane. yStride - a row size of the y image. u - a pointer to pixels data of output 8-bit image with U color plane. uStride - a row size of the u image. v - a pointer to pixels data of output 8-bit image with V color plane. vStride - a row size of the v image. yuvType - a type of output YUV image (see descriprion of Simd.YuvType).
◆ DeinterleaveUv()
def DeinterleaveUv | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | u, | ||
int | uStride, | ||
ctypes.c_void_p | v, | ||
int | vStride | ||
) |
Deinterleaves 16-bit UV interleaved image into separated 8-bit U and V planar images.
All images must have the same width and height. This function used for NV12 to YUV420P conversion.
- Parameters
-
src - a pointer to pixels data of input 16-bit UV image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. u - a pointer to pixels data of output 8-bit image with U color plane. uStride - a row size of the u image. v - a pointer to pixels data of output 8-bit image with V color plane. vStride - a row size of the v image.
◆ Copy()
def Copy | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
int | pixelSize, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Copies an image.
- Parameters
-
src - a pointer to pixels data of input image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. pixelSize - a pixel size of input/output image. dst - a pointer to pixels data of output image. dstStride - a row size of output image in bytes.
◆ FillPixel()
def FillPixel | ( | ctypes.c_void_p | dst, |
int | stride, | ||
int | width, | ||
int | height, | ||
array.array('B') | pixel | ||
) |
Fills image by value of given pixel.
- Parameters
-
dst - a pointer to pixels data of output image. stride - a row size of output image in bytes. width - a width of output image. height - a height of output image. pixel - an array of unsigned 8-bit integer width pixel channels. Its size is in range [1..4].
◆ GrayToBgra()
def GrayToBgra | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride, | ||
alpha = 255 |
|||
) |
Converts 8-bit gray to 32-bit BGRA (32-bit RGBA) image.
- Parameters
-
src - a pointer to pixels data of input 8-bit gray. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 32-bit BGRA (or 32-bit RGBA) image. dstStride - a row size of output image in bytes. alpha - a value of alpha channel. By default it is equal to 255.
◆ GrayToBgr()
def GrayToBgr | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Converts 8-bit gray image to 24-bit BGR (24-bit RGB) image and back.
- Parameters
-
src - a pointer to pixels data of input 8-bit gray image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 24-bit BGR (or 24-bit RGB) image. dstStride - a row size of output image in bytes.
◆ GrayToY()
def GrayToY | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Converts 8-bit gray image to 8-bit Y-plane of YUV image.
- Parameters
-
src - a pointer to pixels data of input 8-bit gray image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 8-bit Y-plane of YUV image. dstStride - a row size of output image in bytes.
◆ ImageSaveToFile()
bool ImageSaveToFile | ( | ctypes.c_void_p | src, |
int | stride, | ||
int | width, | ||
int | height, | ||
Simd.PixelFormat | format, | ||
Simd.ImageFile | file, | ||
int | quality, | ||
str | path | ||
) |
Saves an image to file in given image file format.
- Parameters
-
src - a pointer to pixels data of input image. stride - a row size of input image in bytes. width - a width of input image. height - a height of input image. format - a pixel format of input image. Supported pixel formats: Simd.PixelFormat.Gray8, Simd.PixelFormat.Bgr24, Simd.PixelFormat.Bgra32, Simd.PixelFormat.Rgb24, Simd.PixelFormat.Rgba32. file - a format of output image file. To auto choise format of output file set this parameter to Simd.ImageFile.Undefined. quality - a parameter of compression quality (if file format supports it). path - a path to output image file.
- Returns
- result of the operation.
◆ ImageLoadFromFile()
def ImageLoadFromFile | ( | str | path, |
Simd.PixelFormat | desiredFormat | ||
) |
Loads an image from file.
- Parameters
-
path - a path to input image file. desiredFormat - a desired pixel format of output image. It can be Simd.PixelFormat.Gray8, Simd.PixelFormat.Bgr24, Simd.PixelFormat.Bgra32, Simd.PixelFormat.Rgb24, Simd.PixelFormat.Rgba32 or Simd.PixelFormat.Empty (use pixel format of input image file).
- Returns
- a pointer to pixel data, row size in bytes, image width, image height, output pixel format. The output pixel data mast be deleted after use by function Simd.Lib.Free.
◆ InterleaveUv()
def InterleaveUv | ( | ctypes.c_void_p | u, |
int | uStride, | ||
ctypes.c_void_p | v, | ||
int | vStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | uv, | ||
int | uvStride | ||
) |
Interleaves separate 8-bit U and V planar images into 16-bit UV interleaved image.
All images must have the same width and height. This function used for YUV420P to NV12 conversion.
- Parameters
-
u - a pointer to pixels data of input 8-bit image with U color plane. uStride - a row size of the u image. v - a pointer to pixels data of input 8-bit image with V color plane. vStride - a row size of the v image. width - a width of input/output image. height - a height of input/output image. uv - a pointer to pixels data of output 16-bit UV image. uvStride - a row size of output image in bytes.
◆ RgbToBgra()
def RgbToBgra | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride, | ||
alpha = 255 |
|||
) |
Converts 24-bit RGB to 32-bit BGRA image image.
Also it can be used for 24-bit BGR to 32-bit RGBA conversion.
- Parameters
-
src - a pointer to pixels data of input 24-bit RGB (or 24-bit BGR) image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 32-bit BGRA (or 32-bit RGBA) image. dstStride - a row size of output image in bytes. alpha - a value of alpha channel. By default it is equal to 255.
◆ RgbToGray()
def RgbToGray | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Converts 24-bit RGB image to 8-bit gray image.
- Parameters
-
src - a pointer to pixels data of input 24-bit RGB. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 8-bit gray image. dstStride - a row size of output image in bytes.
◆ RgbaToGray()
def RgbaToGray | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Converts 32-bit RGBA image to 8-bit gray image.
- Parameters
-
src - a pointer to pixels data of input 32-bit RGBA. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 8-bit gray image. dstStride - a row size of output image in bytes.
◆ ResizerInit()
ctypes.c_void_p ResizerInit | ( | int | srcX, |
int | srcY, | ||
int | dstX, | ||
int | dstY, | ||
int | channels, | ||
Simd.ResizeChannel | type, | ||
Simd.ResizeMethod | method | ||
) |
Creates resize context.
- Parameters
-
srcX - a width of the input image. srcY - a height of the input image. dstX - a width of the output image. dstY - a height of the output image. channels - a channel number of input and output image. type - a type of input and output image channel. method - a method used in order to resize image.
- Returns
- a pointer to resize context. On error it returns NULL. This pointer is used in functions SimdResizerRun. It must be released with using of function Simd.Release.
◆ ResizerRun()
def ResizerRun | ( | ctypes.c_void_p | resizer, |
ctypes.c_void_p | src, | ||
int | srcStride, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Performs image resizing.
- Parameters
-
resizer - a resize context. It must be created by function Simd.ResizerInit and released by function Simd.Release. src - a pointer to pixels data of the original input image. srcStride - a row size (in bytes) of the input image. dst - a pointer to pixels data of the resized output image. dstStride - a row size (in bytes) of the output image.
◆ SynetSetInput()
def SynetSetInput | ( | ctypes.c_void_p | src, |
int | width, | ||
int | height, | ||
int | stride, | ||
Simd.PixelFormat | srcFormat, | ||
array.array('f') | lower, | ||
array.array('f') | upper, | ||
ctypes.c_void_p | dst, | ||
int | channels, | ||
Simd.TensorFormat | dstFormat | ||
) |
Sets image to the input of neural network of Synet Framework.
- Parameters
-
src - a pointer to pixels data of input image. height - a height of input image. stride - a row size of input image in bytes. width - a width of input image. srcFormat - a pixel format of input image. Supported pixel formats: Simd.PixelFormat.Gray8, Simd.PixelFormat.Bgr24, Simd.PixelFormat.Bgra32, Simd.PixelFormat.Rgb24, Simd.PixelFormat.Rgba32. lower - an array with lower bound of values of the output tensor. The size of the array have to correspond number of channels in the output image tensor. upper - an array with upper bound of values of the output tensor. The size of the array have to correspond number of channels in the output image tensor. dst - a pointer to the output 32-bit float image tensor. channels - a number of channels in the output image tensor. It can be 1 or 3. dstFormat - a format of output image tensor. There are supported following tensor formats: Simd.TensorFormat.Nchw, Simd.TensorFormat.Nhwc.
◆ WarpAffineInit()
ctypes.c_void_p WarpAffineInit | ( | int | srcW, |
int | srcH, | ||
int | srcS, | ||
int | dstW, | ||
int | dstH, | ||
int | dstS, | ||
channels, | |||
array.array('f') | mat, | ||
Simd.WarpAffineFlags | flags, | ||
array.array('B') | border | ||
) |
Creates wrap affine context.
- Parameters
-
srcW - a width of input image. srcH - a height of input image. srcS - a row size (in bytes) of the input image. dstW - a width of output image. dstH - a height of output image. dstS - a row size (in bytes) of the output image. channels - a channel number of input and output image. Its value must be in range [1..4]. mat - an array with coefficients of affine warp (2x3 matrix). flags - a flags of algorithm parameters. border - an array with color of border. The size of the array mast be equal to channels. It parameter is actual for SimdWarpAffineBorderConstant flag. It can be NULL.
- Returns
- a pointer to warp affine context. On error it returns NULL. This pointer is used in functions Simd.WarpAffineRun. It must be released with using of function Simd.Release.
◆ WarpAffineRun()
def WarpAffineRun | ( | ctypes.c_void_p | context, |
ctypes.c_void_p | src, | ||
ctypes.c_void_p | dst | ||
) |
Performs warp affine for current image.
- Parameters
-
context - a warp affine context. It must be created by function Simd.WarpAffineInit and released by function Simd.Release. src - a pointer to pixels data of the original input image. dst - a pointer to pixels data of the filtered output image.
◆ YToGray()
def YToGray | ( | ctypes.c_void_p | src, |
int | srcStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride | ||
) |
Converts 8-bit Y-plane of YUV image to 8-bit gray image.
- Parameters
-
src - a pointer to pixels data of input 8-bit Y-plane of YUV image. srcStride - a row size of input image in bytes. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 8-bit gray image. dstStride - a row size of output image in bytes.
◆ Yuv420pToBgr()
def Yuv420pToBgr | ( | ctypes.c_void_p | y, |
int | yStride, | ||
ctypes.c_void_p | u, | ||
int | uStride, | ||
ctypes.c_void_p | v, | ||
int | vStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride, | ||
yuvType = Simd.YuvType.Bt601 |
|||
) |
Converts YUV420P image to 24-bit BGR.
The input Y and output BGR images must have the same width and height. The input U and V images must have the same width and height (half size relative to Y component).
- Parameters
-
y - a pointer to pixels data of input 8-bit image with Y color plane. yStride - a row size of the y image. u - a pointer to pixels data of input 8-bit image with U color plane. uStride - a row size of the u image. v - a pointer to pixels data of input 8-bit image with V color plane. vStride - a row size of the v image. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 24-bit BGR image. dstStride - a row size of output image in bytes. yuvType - a type of input YUV image (see descriprion of Simd.YuvType).
◆ Yuv420pToBgra()
def Yuv420pToBgra | ( | ctypes.c_void_p | y, |
int | yStride, | ||
ctypes.c_void_p | u, | ||
int | uStride, | ||
ctypes.c_void_p | v, | ||
int | vStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride, | ||
alpha = 255 , |
|||
yuvType = Simd.YuvType.Bt601 |
|||
) |
Converts YUV420P image to 32-bit BGRA.
The input Y and output BGRA images must have the same width and height. The input U and V images must have the same width and height (half size relative to Y component).
- Parameters
-
y - a pointer to pixels data of input 8-bit image with Y color plane. yStride - a row size of the y image. u - a pointer to pixels data of input 8-bit image with U color plane. uStride - a row size of the u image. v - a pointer to pixels data of input 8-bit image with V color plane. vStride - a row size of the v image. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 32-bit BGRA image. dstStride - a row size of output image in bytes. alpha - a value of alpha channel. By default it is equal to 255. yuvType - a type of input YUV image (see descriprion of Simd.YuvType).
◆ Yuv420pToRgb()
def Yuv420pToRgb | ( | ctypes.c_void_p | y, |
int | yStride, | ||
ctypes.c_void_p | u, | ||
int | uStride, | ||
ctypes.c_void_p | v, | ||
int | vStride, | ||
int | width, | ||
int | height, | ||
ctypes.c_void_p | dst, | ||
int | dstStride, | ||
yuvType = Simd.YuvType.Bt601 |
|||
) |
Converts YUV420P image to 24-bit RGB.
The input Y and output BGR images must have the same width and height. The input U and V images must have the same width and height (half size relative to Y component).
- Parameters
-
y - a pointer to pixels data of input 8-bit image with Y color plane. yStride - a row size of the y image. u - a pointer to pixels data of input 8-bit image with U color plane. uStride - a row size of the u image. v - a pointer to pixels data of input 8-bit image with V color plane. vStride - a row size of the v image. width - a width of input/output image. height - a height of input/output image. dst - a pointer to pixels data of output 24-bit RGB image. dstStride - a row size of output image in bytes. yuvType - a type of input YUV image (see descriprion of Simd.YuvType).