简体   繁体   English

为 Ximea 相机设置下采样

[英]Set downsampling for Ximea camera

I am attempting to configure downsampling for the MC023CG-SY-UB Ximea camera.我正在尝试为 MC023CG-SY-UB Ximea 相机配置下采样。 When I invoke the following setters in the python API:当我在 python API 中调用以下设置器时:

cam.set_imgdataformat('XI_RGB24');
cam.set_gain(20);
cam.disable_aeag();
cam.enable_auto_wb();
cam.set_exposure(7000);
cam.set_downsampling('XI_DWN_2x2');

I get this error:我收到此错误:

xiAPI: XiApiToGentlParamModel::SetDownsampling ERROR setting value 2
xiAPI: xiAPI error: Expected XI_OK in:../API/xiFAPI/interfaces/02_mid/xifapi_Handlers_Setters.gen.h SetParam/Line:55
xiAPI: xiSetParam - error: setting parameter downsampling
Traceback (most recent call last):
File "show_ximea_position.py", line 21, in <module>
    cam.set_downsampling('XI_DWN_2x2');

File "/usr/local/lib/python2.7/site-packages/ximea/xiapi.py", line 611, in set_downsampling
self.set_param('downsampling', downsampling)
File "/usr/local/lib/python2.7/site-packages/ximea/xiapi.py", line 389, in set_param
raise Xi_error(stat)
ximea.xiapi.Xi_error: ERROR 12: Not supported

I tried every XI_DWN_NxN sampling method from 2x2->16x16 mentioned in the documentation , and all yield the same error ( Not supported ).我尝试了文档中提到的 2x2->16x16 中的每种 XI_DWN_NxN 采样方法,并且都产生了相同的错误(不支持)。 If I use XI_DWN_1x1, the configuration is functional, but the image resolution is way too high.如果我使用 XI_DWN_1x1,配置可以正常工作,但图像分辨率太高。

What functions should I invoke to reduce the resolution of the camera?我应该调用哪些函数来降低相机的分辨率? I know that I can do something like:我知道我可以做类似的事情:

cam.set_width 
cam.set_height

but that crops the image, and does not alter the resolution.但这会裁剪图像,并且不会改变分辨率。

Turns out that this message is returned back only if the camera you are using does NOT support downsampling.事实证明,仅当您使用的相机不支持下采样时才会返回此消息。 Your only other option is to reduce the number of pixels you fetch back.您唯一的其他选择是减少您取回的像素数量。 In other words, the aforementioned camera supports capture at 1936x1216, but you do not have to capture all of them.换言之,上述相机支持以 1936x1216 的分辨率进行拍摄,但您不必全部拍摄。 In the example below, I am fetching 944x1200.在下面的示例中,我正在获取 944x1200。

width = 944;
height = 1200;
cam.set_imgdataformat('XI_RGB24');
cam.set_width(width);
cam.set_height(height);
# this value needs to be in increments of 16
# math to get this number : 1936 - 944 = 992 / 2 = 496
cam.set_offsetX(496);
# 496 / 16 = 31.0 yields valid offset for x for center of image

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM