easyyuv 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- easyyuv-0.1.0/PKG-INFO +39 -0
- easyyuv-0.1.0/README.md +29 -0
- easyyuv-0.1.0/easyyuv/__init__.py +8 -0
- easyyuv-0.1.0/easyyuv/converter.py +59 -0
- easyyuv-0.1.0/easyyuv.egg-info/PKG-INFO +39 -0
- easyyuv-0.1.0/easyyuv.egg-info/SOURCES.txt +9 -0
- easyyuv-0.1.0/easyyuv.egg-info/dependency_links.txt +1 -0
- easyyuv-0.1.0/easyyuv.egg-info/requires.txt +2 -0
- easyyuv-0.1.0/easyyuv.egg-info/top_level.txt +1 -0
- easyyuv-0.1.0/pyproject.toml +22 -0
- easyyuv-0.1.0/setup.cfg +4 -0
easyyuv-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: easyyuv
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An easy-to-use YUV format conversion package
|
|
5
|
+
Author: Ian
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: numpy
|
|
9
|
+
Requires-Dist: opencv-python
|
|
10
|
+
|
|
11
|
+
# EasyYUV
|
|
12
|
+
|
|
13
|
+
A simple Python package for YUV image format conversion.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- UYVY to YUYV
|
|
18
|
+
- YUYV to UYVY
|
|
19
|
+
- YUV to BGR
|
|
20
|
+
- YUV to JPG and PNG
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install easyyuv
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import easyyuv as ey
|
|
32
|
+
|
|
33
|
+
ey.uyvy_to_yuyv(
|
|
34
|
+
"input.yuv",
|
|
35
|
+
"output.yuv",
|
|
36
|
+
1280,
|
|
37
|
+
960
|
|
38
|
+
)
|
|
39
|
+
```
|
easyyuv-0.1.0/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# EasyYUV
|
|
2
|
+
|
|
3
|
+
A simple Python package for YUV image format conversion.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- UYVY to YUYV
|
|
8
|
+
- YUYV to UYVY
|
|
9
|
+
- YUV to BGR
|
|
10
|
+
- YUV to JPG and PNG
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install easyyuv
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
import easyyuv as ey
|
|
22
|
+
|
|
23
|
+
ey.uyvy_to_yuyv(
|
|
24
|
+
"input.yuv",
|
|
25
|
+
"output.yuv",
|
|
26
|
+
1280,
|
|
27
|
+
960
|
|
28
|
+
)
|
|
29
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import cv2
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def read_yuv(input_path, width, height):
|
|
6
|
+
if width <= 0 or height <= 0 or width % 2 != 0:
|
|
7
|
+
raise ValueError("Invalid image dimensions")
|
|
8
|
+
|
|
9
|
+
data = np.fromfile(input_path, dtype=np.uint8)
|
|
10
|
+
|
|
11
|
+
if data.size != width * height * 2:
|
|
12
|
+
raise ValueError("Invalid YUV file size")
|
|
13
|
+
|
|
14
|
+
return data
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# UYVY 轉 YUYV
|
|
18
|
+
def uyvy_to_yuyv(input_path, output_path, width, height):
|
|
19
|
+
data = read_yuv(input_path, width, height)
|
|
20
|
+
data = data.reshape(-1, 4)
|
|
21
|
+
result = data[:, [1, 0, 3, 2]]
|
|
22
|
+
result.tofile(output_path)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# YUYV 轉 UYVY
|
|
26
|
+
def yuyv_to_uyvy(input_path, output_path, width, height):
|
|
27
|
+
data = read_yuv(input_path, width, height)
|
|
28
|
+
data = data.reshape(-1, 4)
|
|
29
|
+
result = data[:, [1, 0, 3, 2]]
|
|
30
|
+
result.tofile(output_path)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# YUV 轉 BGR
|
|
34
|
+
def yuv_to_bgr(input_path, width, height, fmt="UYVY"):
|
|
35
|
+
data = read_yuv(input_path, width, height)
|
|
36
|
+
data = data.reshape(height, width, 2)
|
|
37
|
+
|
|
38
|
+
if fmt.upper() == "UYVY":
|
|
39
|
+
return cv2.cvtColor(data, cv2.COLOR_YUV2BGR_UYVY)
|
|
40
|
+
|
|
41
|
+
elif fmt.upper() == "YUYV":
|
|
42
|
+
return cv2.cvtColor(data, cv2.COLOR_YUV2BGR_YUY2)
|
|
43
|
+
|
|
44
|
+
else:
|
|
45
|
+
raise ValueError("Unsupported YUV format")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# YUV 轉 JPG 或 PNG
|
|
49
|
+
def yuv_to_image(input_path, output_path,
|
|
50
|
+
width, height, fmt="UYVY"):
|
|
51
|
+
|
|
52
|
+
image = yuv_to_bgr(input_path, width, height, fmt)
|
|
53
|
+
|
|
54
|
+
success = cv2.imwrite(str(output_path), image)
|
|
55
|
+
|
|
56
|
+
if not success:
|
|
57
|
+
raise IOError("Failed to save image")
|
|
58
|
+
|
|
59
|
+
return success
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: easyyuv
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An easy-to-use YUV format conversion package
|
|
5
|
+
Author: Ian
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: numpy
|
|
9
|
+
Requires-Dist: opencv-python
|
|
10
|
+
|
|
11
|
+
# EasyYUV
|
|
12
|
+
|
|
13
|
+
A simple Python package for YUV image format conversion.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- UYVY to YUYV
|
|
18
|
+
- YUYV to UYVY
|
|
19
|
+
- YUV to BGR
|
|
20
|
+
- YUV to JPG and PNG
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install easyyuv
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import easyyuv as ey
|
|
32
|
+
|
|
33
|
+
ey.uyvy_to_yuyv(
|
|
34
|
+
"input.yuv",
|
|
35
|
+
"output.yuv",
|
|
36
|
+
1280,
|
|
37
|
+
960
|
|
38
|
+
)
|
|
39
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
easyyuv
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "easyyuv"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "An easy-to-use YUV format conversion package"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Ian"}
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
dependencies = [
|
|
17
|
+
"numpy",
|
|
18
|
+
"opencv-python"
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[tool.setuptools]
|
|
22
|
+
packages = ["easyyuv"]
|
easyyuv-0.1.0/setup.cfg
ADDED