Skip to content

Commit

Permalink
rgb_array bug: wrap arround of uint8 (#263)
Browse files Browse the repository at this point in the history
* rgb_array bug: wrap arround of uint8
enforce the cast to float before the subtraction (l350, 351)
to avoid wrap-around in the case of low-light images

* reset the memoized RGB array at flush
  • Loading branch information
kif authored and waveform80 committed Jun 18, 2016
1 parent 322a130 commit aa444ca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion picamera/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,13 @@ def __init__(self, camera, size=None):
def flush(self):
super(PiYUVArray, self).flush()
self.array = bytes_to_yuv(self.getvalue(), self.size or self.camera.resolution)
self._rgb = None

@property
def rgb_array(self):
if self._rgb is None:
# Apply the standard biases
YUV = self.array.copy()
YUV = self.array.astype(float)
YUV[:, :, 0] = YUV[:, :, 0] - 16 # Offset Y by 16
YUV[:, :, 1:] = YUV[:, :, 1:] - 128 # Offset UV by 128
# YUV conversion matrix from ITU-R BT.601 version (SDTV)
Expand Down

0 comments on commit aa444ca

Please sign in to comment.