array.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:ivport-v2 作者: ivmech 项目源码 文件源码
def rgb_array(self):
        if self._rgb is None:
            # Apply the standard biases
            YUV = self.array.copy()
            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)
            #              Y       U       V
            M = np.array([[1.164,  0.000,  1.596],    # R
                          [1.164, -0.392, -0.813],    # G
                          [1.164,  2.017,  0.000]])   # B
            # Calculate the dot product with the matrix to produce RGB output,
            # clamp the results to byte range and convert to bytes
            self._rgb = YUV.dot(M.T).clip(0, 255).astype(np.uint8)
        return self._rgb
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号