-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
58 lines (45 loc) · 1.36 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import subprocess
import numpy as np
import OpenImageIO as oiio
import PyOpenColorIO as ocio
def test_tools():
tools = [
["iconvert", "--help"],
["idiff", "--help"],
["igrep", "--help"],
["iinfo", "--help"],
["maketx", "--help"],
["oiiotool", "--help"],
["ocioarchive", "--h"],
["ociobakelut", "--h"],
["ociocheck", "--h"],
["ociochecklut", "--h"],
["ocioconvert", "--h"],
["ociolutimage", "--h"],
["ociomakeclf", "--h"],
["ocioperf", "--h"],
["ociowrite", "--v"],
]
for tool in tools:
subprocess.run(tool, check=True)
def test_numpy():
rand_img = np.random.rand(128, 128, 3).astype(np.float32)
buf = oiio.ImageBuf(rand_img)
pixels = buf.get_pixels(oiio.FLOAT, oiio.ROI(0, 128, 0, 128, 0, 1))
assert np.allclose(pixels, rand_img)
buf = oiio.ImageBuf(pixels)
def main():
# Test tools
if os.getenv("OIIO_STATIC") != "1":
test_tools()
test_numpy()
config = ocio.GetCurrentConfig()
print("Config: ", config)
colorSpaceNames = [cs.getName() for cs in config.getColorSpaces()]
print("Color Spaces: ", colorSpaceNames)
# Print version
print("OpenImageIO Version: ", oiio.__version__)
print("OpenColorIO Version: ", ocio.__version__)
if __name__ == "__main__":
main()