__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
import numpy as np
YUV2RGB_JPEG = np.array([[1.0, 1.0, 1.0 ], [0.0, -0.344, 1.772], [1.402, -0.714, 0.0]]) # noqa
YUV2RGB_SMPTE170M = np.array([[1.164, 1.164, 1.164], [0.0, -0.392, 2.017], [1.596, -0.813, 0.0]]) # noqa
YUV2RGB_REC709 = np.array([[1.164, 1.164, 1.164], [0.0, -0.213, 2.112], [1.793, -0.533, 0.0]]) # noqa
def YUV420_to_RGB(YUV_in, size, matrix=YUV2RGB_JPEG, rb_swap=True, final_width=0):
"""Convert a YUV420 image to an interleaved RGB image of half resolution.
The size parameter should include padding if there is any, which can be trimmed off
at the end with the final_width parameter.
"""
w, h = size
w2 = w // 2
h2 = h // 2
n = w * h
n2 = n // 2
n4 = n // 4
YUV = np.empty((h2, w2, 3), dtype=int)
YUV[:, :, 0] = YUV_in[:n].reshape(h, w)[0::2, 0::2]
YUV[:, :, 1] = YUV_in[n:n + n4].reshape(h2, w2) - 128.0
YUV[:, :, 2] = YUV_in[n + n4:n + n2].reshape(h2, w2) - 128.0
if rb_swap:
matrix = matrix[:, [2, 1, 0]]
RGB = np.dot(YUV, matrix).clip(0, 255).astype(np.uint8)
if final_width and final_width != w2:
RGB = RGB[:, :final_width, :]
return RGB
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| allocators | Folder | 0755 |
|
|
| devices | Folder | 0755 |
|
|
| encoders | Folder | 0755 |
|
|
| outputs | Folder | 0755 |
|
|
| previews | Folder | 0755 |
|
|
| __init__.py | File | 2.14 KB | 0644 |
|
| configuration.py | File | 5.25 KB | 0644 |
|
| controls.py | File | 3.25 KB | 0644 |
|
| converters.py | File | 1.15 KB | 0644 |
|
| dma_heap.py | File | 2.66 KB | 0644 |
|
| formats.py | File | 1.3 KB | 0644 |
|
| job.py | File | 3.59 KB | 0644 |
|
| metadata.py | File | 229 B | 0644 |
|
| picamera2.py | File | 113.97 KB | 0644 |
|
| platform.py | File | 732 B | 0644 |
|
| request.py | File | 22.71 KB | 0644 |
|
| sensor_format.py | File | 1.25 KB | 0644 |
|
| utils.py | File | 2.9 KB | 0644 |
|