首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在巨蟒中用Spinnaker从点灰色摄像机获取彩色图像?

如何在巨蟒中用Spinnaker从点灰色摄像机获取彩色图像?
EN

Stack Overflow用户
提问于 2018-11-06 12:26:20
回答 2查看 5.3K关注 0票数 7

我试图从flea3相机(代码"FL3-U3-32S2C-CS",显示彩色相机)获取彩色图像(在我的例子中,rgb或bgr没有区别),但是我的代码生成灰度照片.下面的代码片段有什么问题?知道吗?

代码语言:javascript
复制
    #  Begin acquiring images
    cam.BeginAcquisition()

    #  Retrieve next image and convert it
    image_result = cam.GetNextImage()
    img_converted = image_result.Convert(PySpin.PixelFormat_RGB8, PySpin.HQ_LINEAR)

    #  Convert the Image object to RGB array
    width = image_result.GetWidth()
    height = image_result.GetHeight()
    rgb_array = img_converted.GetData()
    rgb_array = rgb_array.reshape(height, width, 3)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-12-05 13:49:29

以下说明了如何做到这一点:

代码语言:javascript
复制
### Set Pixel Format to RGB8 ###
node_pixel_format = 
PySpin.CEnumerationPtr(nodemap.GetNode('PixelFormat'))

if not PySpin.IsAvailable(node_pixel_format) or not PySpin.IsWritable(node_pixel_format):
   print('Unable to set Pixel Format to RGB8 (enum retrieval). Aborting...')
node_pixel_format_RGB8 = node_pixel_format.GetEntryByName('RGB8')
if not PySpin.IsAvailable(node_pixel_format_RGB8) or not PySpin.IsReadable(node_pixel_format_RGB8):
   print('Unable to set Pixel Format to RGB8 (entry retrieval). Aborting...')

pixel_format_RGB8 = node_pixel_format_RGB8.GetValue()
node_pixel_format.SetIntValue(pixel_format_RGB8)
票数 3
EN

Stack Overflow用户

发布于 2018-11-28 02:57:41

我也有同样的问题,但在USB上有一个黑蝇S摄像头。我得用一种特定的格式才能让它起作用。在获取之前,我还设置了相机上的像素格式。

代码语言:javascript
复制
cam.PixelFormat.SetValue(PySpin.PixelFormat_BGR8)
cam.BeginAcquisition()
image_result = cam.GetNextImage()
image_converted = image_result.Convert(PySpin.PixelFormat_BGR8)
#  Convert the Image object to RGB array
width = image_result.GetWidth()
height = image_result.GetHeight()
rgb_array = image_converted.GetData()
rgb_array = rgb_array.reshape(height, width, 3)
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53171872

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档