简体   繁体   English

Basler pylon ip camera TimoutException 在 python 中抛出(文件“tlfactory.cpp”,第 694 行)

[英]Basler pylon ip camera TimoutException thrown (file 'tlfactory.cpp', line 694) in python

I have a problem using Basler Pylon ip camera while grabbing.我在抓取时使用 Basler Pylon ip 摄像头时遇到问题。 I set my ip as shown below.我设置了我的ip,如下所示。 以太网连接的 IP 地址

I used the grab.py code of pypylon from Github basler/pypylon/grab.py .我使用了Github basler/pypylon/grab.py中 pypylon 的grab.py 代码。 It works when I tried it on another computer but it throws a timeout exception on my computer.当我在另一台计算机上尝试它时它可以工作,但它在我的计算机上引发超时异常。 Can you please help me how to solve this problem?你能帮我解决这个问题吗?

The code:代码:

from pypylon import pylon
from pypylon import genicam

import sys

countOfImagesToGrab = 100

exitCode = 0

try:
    camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
    camera.Open()

    print("Using device ", camera.GetDeviceInfo().GetModelName())

    new_width = camera.Width.GetValue() - camera.Width.GetInc()
    if new_width >= camera.Width.GetMin():
        camera.Width.SetValue(new_width)

    camera.MaxNumBuffer = 5

    camera.StartGrabbingMax(countOfImagesToGrab)

    while camera.IsGrabbing():
        grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)

        if grabResult.GrabSucceeded():
            print("SizeX: ", grabResult.Width)
            print("SizeY: ", grabResult.Height)
            img = grabResult.Array
            print("Gray value of first pixel: ", img[0, 0])
        else:
            print("Error: ", grabResult.ErrorCode, grabResult.ErrorDescription)
        grabResult.Release()
    camera.Close()

except genicam.GenericException as e:
    print("An exception occurred.")
    print(e.GetDescription())
    exitCode = 1

sys.exit(exitCode)

And the error is: _genicam.TimeoutException: Grab timed out.错误是: _genicam.TimeoutException:Grab 超时。 Possible reasons are: The image transport from the camera device is not working properly, eg, all GigE network packets for streaming are dropped;可能的原因有: 来自相机设备的图像传输工作不正常,例如,所有用于流式传输的 GigE 网络数据包都被丢弃; The camera uses explicit triggering (see TriggerSelector for more information) and has not been triggered;相机使用显式触发(更多信息请参见 TriggerSelector)且未触发; Single frame acquisition mode is used and one frame has already been acquired;使用单帧采集模式,已经采集了一帧; The acquisition has not been started or has been stopped.采集尚未开始或已停止。 : TimeoutException thrown (file 'instantcameraimpl.h', line 1037) : TimeoutException 抛出(文件“instantcameraimpl.h”,第 1037 行)

超时异常

There is a warning in the error section that the camera is triggered explicitly.错误部分中有一个警告,表明相机被显式触发。 I guess the grab method is triggered in a different way.我猜抓取方法以不同的方式触发。 For this, can you change the startgrabbingmax method on your code with camera.StartGrabbing(pylon.GrabStrategy_LatestImageOnly) and try again?为此,您可以使用 camera.StartGrabbing(pylon.GrabStrategy_LatestImageOnly) 更改代码上的 startgrabbingmax 方法并重试吗?

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

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