python - unsigned char* 图像到 Python

标签 python c++ python-imaging-library unsigned-char pep3118

我能够使用 SWIG 为相机库生成 python 绑定(bind),并且能够使用库的内置函数捕获和保存图像。 我正在尝试从相机获取数据并将其转换为 Python Image Library 格式,该库提供了将相机数据作为 unsigned char* 返回的功能。 有谁知道如何将 unsigned char* 图像数据转换成我可以在 Python 中使用的某种数据格式? 基本上我正在尝试将 unsigned char* 图像数据转换为 Python 图像库格式。

谢谢。

最佳答案

我相信您应该使用 fromstring 方法,如下所述:

How to read a raw image using PIL?

此外,还有一篇关于使用 python 和 opencv 从相机捕获数据的好文章值得一读:http://www.jperla.com/blog/post/capturing-frames-from-a-webcam-on-linux

关于python - unsigned char* 图像到 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3586003/

相关文章:

c++ - 尽管覆盖仍编译错误

python - 从图像中删除所有空白区域

python - 类图像没有属性 'open'

python - 使用 Python 裁剪 AVI 文件

c++ - 有关使用 C++\XAML for Metro 进行 Windows 8 编程的资源和信息

c++ - 有人知道这个 d3d9 调试输出是否错误吗?

python - 如何在过滤器中添加if语句?

python - 如何找到总价

python - PyQt5在numpy数组中设置RGBA像素

python - 使用 keras 和 python 3.6 构建神经网络