python - 通过 python uEye 在 IDS 相机上配置 Mono12 模式
问题描述
有谁知道如何在 IDS 相机上正确配置 Mono12 模式?
我尝试了 is_SetColorMode 方法,将每像素的 BITES 设置为 12,将每像素的 BYTES 设置为 2,依此类推。它不能那么好。
最后,我在 IDS uEye Cockpit 中完成了一个配置文件,保存了它,现在用于在 python 代码的开头设置相机。它也没有帮助。
我现在遇到的问题是我得到的图像是在两个~2056*2056(芯片大小)的数组中引入的。发生这种情况是因为我每个像素有 2 个字节。但我不知道如何将其正确转换为正常图像。
此外,即使在默认的 Mono8 模式下,我看到的图片也与我在 IDS 应用程序中看到的不同。
这是代码(我也可以给出配置文件):
import matplotlib.pyplot as plt
import numpy as np
import cv2
import sys
import pyueye.ueye as ueye
import time
hCam = ueye.HIDS(0)
# Starts the driver and establishes the connection to the camera
nRet = ueye.is_InitCamera(hCam, None)
if nRet != ueye.IS_SUCCESS:
print("is_InitCamera ERROR")
conf_file = 'camera_config_mono12.ini'
nRet = ueye.is_ParameterSet(hCam,
ueye.INT(2),
ueye.wchar_p(conf_file),
ueye.sizeof(ueye.INT(2)))
print(str(nRet) + ' - ParameterSet')
nRet = ueye.is_SetColorMode(hCam, ueye.IS_CM_MONO12)
print(str(nRet) + ' - SetColorMode')
BitesPerPix = ueye.INT(12)
BytesPerPixel = 2
nRet = ueye.is_SetDisplayMode(hCam, ueye.INT(1))
print(str(nRet) + ' - SetDisplayMode')
nRet = ueye.is_SetFrameRate(hCam, ueye.c_double(1), ueye.c_double())
print(str(nRet) + ' - SetFrameRate')
exp_time = ueye.c_void_p(200)
nRet = ueye.is_Exposure(hCam, ueye.INT(12), exp_time, 8)
print(str(nRet) + ' - Exposure')
rectAOI = ueye.IS_RECT()
nRet = ueye.is_AOI(hCam, ueye.INT(2), rectAOI, ueye.sizeof(rectAOI))
print(str(nRet) + ' - AOI')
save_file = 'C:\\Users\\novoks\\Desktop\\emva_tests\\ids\\saved_conf.ini'
nRet = ueye.is_ParameterSet(hCam,
ueye.INT(4),
ueye.wchar_p(save_file),
ueye.sizeof(ueye.INT(4)))
pcImageMem = ueye.c_mem_p()
pid = ueye.c_int()
nRet = ueye.is_AllocImageMem(hCam,
rectAOI.s32Width,
rectAOI.s32Height,
BitesPerPix,
pcImageMem,
pid)
print(str(nRet) + ' - AllocImageMem')
nRet = ueye.is_SetImageMem(hCam, pcImageMem, pid)
print(str(nRet) + ' - SetImageMem')
nRet = ueye.is_CaptureVideo(hCam, ueye.IS_DONT_WAIT)
print(str(nRet) + ' - CaptureVideo')
time.sleep(1)
#nRet = ueye.is_FreezeVideo(hCam, ueye.INT(0))
#print(str(nRet) + ' - FreezeVideo')
bts = ueye.INT()
pitch = ueye.INT()
nRet = ueye.is_InquireImageMem(hCam,
pcImageMem,
pid,
ueye.INT(),
ueye.INT(),
bts,
pitch)
print(str(nRet) + ' - InquireImageMem')
array = ueye.get_data(pcImageMem,
rectAOI.s32Width,
rectAOI.s32Height,
BitesPerPix,
pitch,
copy=False)
print(str(nRet) + ' - get_data')
pict = np.reshape(array,
(rectAOI.s32Height.value,
rectAOI.s32Width.value,
BytesPerPixel))
plt.figure(figsize=[12,5])
plt.subplot(1,3,1)
plt.imshow(pict[:,:,0])
plt.subplot(1,3,2)
plt.imshow(pict[:,:,1])
plt.subplot(1,3,3)
plt.imshow(pict[:,:,0] + pict[:,:,1])
plt.show()
nRet = ueye.is_ExitCamera(hCam)
解决方案
尝试通过ueye.is_PixelClock()
命令减少像素时钟。当我尝试RAW12
使用pixelclock= 35
(我的 UI-3240 的最大可用速度)时,图像采集命令什么都不返回(0)——就像你的情况一样。
但是一旦我加速到10MHz,图像数据就正常返回了。
IDS Camera Manager 也可以检查此图像格式与像素时钟的问题。当您将格式从 Mono8(默认)切换到 Raw12 时,程序会立即显示错误消息。
推荐阅读
- javascript - JavaScript 等效于 Python 的 oauth2client POST 请求到 Google 提醒
- events - 跟踪停止播放音频事件?
- php - Laravel 5:如果存在特定参数,则验证错误
- node.js - 如何在 Web-push 中向特定用户发送推送通知?
- logging - 覆盖 micronaut 记录器端点
- python - 我无法添加给定列表
- unity3d - 如何在 Unity3d 中制作响应式下拉元素?
- c++ - 通过同一命名空间中的另一个类型访问类型
- identityserver4 - 如何在键入的 HttpClient 中获取访问令牌
- html - 更新 keyentry 上的列表元素