-
Notifications
You must be signed in to change notification settings - Fork 10
/
test_pixelformats.py
70 lines (61 loc) · 1.53 KB
/
test_pixelformats.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
59
60
61
62
63
64
65
66
67
68
69
70
from __future__ import print_function
import mv
import numpy as np
#import pylab as plt
cam = mv.dmg.VD000001
cam_settings = cam.Setting.Base.Camera
cam_settings.TestMode = 'HorizontalMonoRamp'
cam_settings.TestImageBarWidth = 1
cam_settings.ChannelBitDepth = 16
#'Mono8': ok
#'RGB888Packed'
# 'Auto'
# 'BGR101010Packed_V2'
# 'BGR888Packed'
# 'Mono10'
# 'Mono12'
# 'Mono12Packed_V2'
# 'Mono14'
# 'Mono16'
# 'Mono8' #
# 'RGB101010Packed'
# 'RGB121212Packed'
# 'RGB141414Packed'
# 'RGB161616Packed'
# 'RGB888Packed'
# 'RGBx888Packed'
# 'RGBx888Planar'
# 'Raw': 1,
# 'YUV422Packed'
# 'YUV422Planar'
# 'YUV422_10Packed'
# 'YUV422_UYVYPacked'
# 'YUV422_UYVY_10Packed'
# 'YUV444Packed'
# 'YUV444_10Packed'
# 'YUV444_UYVPacked'
# 'YUV444_UYV_10Packed'
pixel_formats = ('Mono8', 'Mono10', 'Mono12', 'Mono16',
'RGB888Packed', 'RGB101010Packed', 'RGB121212Packed', 'RGB141414Packed', 'RGB161616Packed',
'RGBx888Packed',
'BGR888Packed',
'RGBx888Planar')
for pixfmt in pixel_formats:
cam.Setting.Base.ImageDestination.PixelFormat = pixfmt
nr = cam.image_request()
result = cam.get_image(timeout = 1.0)
#print "result:"
#print result.result, result.state, result.info
print(pixfmt)
try:
buf = result.get_buffer()
print("buffer:", buf.shape)
img = np.asarray(buf)
print(img.shape, img.dtype)
print(img[...,0, :6])
except mv.MVError as e:
print("Error getting buffer:", e)
print()
#
#plt.imshow(np.squeeze(img))
#plt.show()