SDK Image¶
Module realize VLImage - structure for storing image in special format.
-
class
lunavl.sdk.image_utils.image.ColorFormat[source]¶ Enum for vl luna color formats
-
B8G8R8= 'B8G8R8'¶ 3 channel, 8 bit per channel, B-G-R color order format;
-
B8G8R8X8= 'B8G8R8X8'¶ 3 channel, 8 bit per channel, B-G-R color order format with 8 bit padding before next pixel;
-
R16= 'R16'¶ 1 channel, 8 bit per channel format;
-
R8= 'R8'¶ 1 channel, 8 bit per channel format;
-
R8G8B8= 'R8G8B8'¶ 3 channel, 8 bit per channel, R-G-B color order format;
-
R8G8B8X8= 'R8G8B8X8'¶ 3 channel, 8 bit per channel, R-G-B color order format with 8 bit padding before next pixel;
-
Unknown= 'Unknown'¶ unknown format
-
coreFormat¶ Convert format to luna core format.
- Returns
luna core format
- Return type
FormatType
-
-
class
lunavl.sdk.image_utils.image.ImageFormat[source]¶ Enum for image format
-
JPG= 'jpg'¶ jpg
-
PNG= 'png'¶ png
-
PPM= 'ppm'¶ ppm
-
TIF= 'tif'¶ tif
-
-
class
lunavl.sdk.image_utils.image.VLImage(body, imgFormat=None, filename='')[source]¶ Class image.
-
coreImage¶ core image object
- Type
CoreFE.Image
-
source¶ source of image (todo change)
- Type
str
-
filename¶ filename of the file which is source of image
- Type
str
-
asNPArray()[source]¶ Get image as numpy array.
- Returns
numpy array
todo: doctest
- Return type
ndarray
-
bitDepth¶ Get number of bits per pixel.
- Returns
number of bits per pixel.
- Return type
int
-
channelCount¶ Get chanel count of the image.
- Returns
channel count.
>>> img = VLImage.load(url='https://st.kp.yandex.net/im/kadr/3/1/4/kinopoisk.ru-Keira-Knightley-3142930.jpg') >>> img.channelCount 3
- Return type
int
-
channelSize¶ Get size of one chanel in bites.
- Returns
channel size in bytes.
>>> img = VLImage.load(url='https://st.kp.yandex.net/im/kadr/3/1/4/kinopoisk.ru-Keira-Knightley-3142930.jpg') >>> img.channelSize 8
- Return type
int
-
channelStep¶ Get chanel step. todo: more description
- Returns
channel size in bytes.
Notes
padding bytes are considered spare channels.
>>> img = VLImage.load(url='https://st.kp.yandex.net/im/kadr/3/1/4/kinopoisk.ru-Keira-Knightley-3142930.jpg') >>> img.channelStep 3
- Return type
int
-
computePitch(rowWidth)[source]¶ Compute row size in bytes
- Parameters
rowWidth – row width in pixels.
- Returns
row size in bytes.
- Return type
int
-
convertToBinaryImg(imageFormat=<ImageFormat.PPM: 'ppm'>)[source]¶ Convert VL image to binary image :param imageFormat: format
- Returns
bytes
- Return type
bytes
-
format¶ FaceEngine.Image) -> FaceEngine.FormatType
>>> image = VLImage.load(url='https://st.kp.yandex.net/im/kadr/3/1/4/kinopoisk.ru-Keira-Knightley-3142930.jpg') >>> image.format.value 'R8G8B8'
- Return type
- Type
getFormat(self
-
getByteDepth¶ Get number of bytes per pixel.
- Returns
number of bytes per pixel.
- Return type
int
-
isBGR()[source]¶ Check whether format image is bgr or not.
- Returns
True if the image is bgr image otherwise False
Notes
padding is ignored for padded channels.
>>> VLImage.load(url='https://st.kp.yandex.net/im/kadr/3/1/4/kinopoisk.ru-Keira-Knightley-3142930.jpg').isBGR() False
- Return type
bool
-
isPadded()[source]¶ Determinate image format has padding bytes or not.
- Returns
true if image format has padding bytes.
todo examples
- Return type
bool
-
isValid()[source]¶ Check image is valid loaded to core image or not
- Returns
True if image is valid otherwise False
- Return type
bool
-
classmethod
load(*_, filename=None, url=None, imgFormat=None)[source]¶ Load imag from numpy array or file or url.
- Parameters
*_ – for remove positional argument
filename – filename
url – url
imgFormat –
- Returns
vl image
- Raises
ValueError – if no one argument did not set.
>>> VLImage.load(url='https://st.kp.yandex.net/im/kadr/3/1/4/kinopoisk.ru-Keira-Knightley-3142930.jpg').rect x = 0, y = 0, width = 1000, height = 1288
todo: more doc test
- Return type
-