0

几个月来,我一直在使用 Point Grey Research 的 Dragonfly Express 相机。我已经编写了代码来使用相机并用它来抓取图像。最近我将固件和 SDK 从 2 更新到 2.2,从那以后我无法使用我的代码抓取图像。新的 FlyCapture2 控制面板 (2.2) 可以工作,并且能够使用同一个摄像头捕捉视频。具体来说,当我在 Camera 对象上调用 StartCapture 时出现错误。我正在粘贴我的程序的输出,然后我将添加相关的相机代码:

* 相机信息 * 序列号 - 7340769 相机型号 - Dragonfly Express DX-BW 相机供应商 - Point Grey Research Sensor - Kodak KAI-0340DM (1/3" 640x480 CCD) 分辨率 - 648x484 固件版本 - 1.1.1.21 固件构建时间 - 周三2006年6月21日23:01:00

错误跟踪:来源:.\IidcCameraInternal.cpp(429) 内置:2010 年 9 月 23 日 12:41:46 - 启动同步流时出错。+-> 来自:.\Iso.cpp(1515) 内置:2010 年 9 月 23 日 12:41:43 - 同步启动失败。错误:0x15。

    bool
Camera::Start()
{
    FlyCapture2::BusManager busMgr;
    unsigned int numCameras;
    error = busMgr.GetNumOfCameras(&numCameras);
    if (error != FlyCapture2::PGRERROR_OK)
    {
        error.PrintErrorTrace();
        return false;
    }
    FlyCapture2::PGRGuid guid;
    {
        error = busMgr.GetCameraFromIndex(0, &guid);
        if (error != FlyCapture2::PGRERROR_OK)
        {
            error.PrintErrorTrace();
            return false;
        }
    }


    // Connect to a camera
    error = cam.Connect(&guid);
    if (error != FlyCapture2::PGRERROR_OK)
    {
        error.PrintErrorTrace();
        return false;
    }

    // Get the camera information
    FlyCapture2::CameraInfo camInfo;
    error = cam.GetCameraInfo(&camInfo);
    if (error != FlyCapture2::PGRERROR_OK)
    {
        error.PrintErrorTrace();
        return false;
    }

    FlyCapture2::FC2Config Config;

    FlyCapture2::TriggerDelay Trigger;
    cam.GetTriggerDelay (&Trigger);
    Trigger.absValue = 0.000075;
    Trigger.onOff = true;
    error = cam.SetTriggerDelay (&Trigger);
    if (error != FlyCapture2::PGRERROR_OK)
    {
        error.PrintErrorTrace();
        return false;
    }
    FlyCapture2::StrobeControl s;
    {           
        FlyCapture2::TriggerMode Mode;
        memset (&Mode, 0, sizeof(Mode));
        Mode.source = 0;
        error = cam.GetTriggerMode (&Mode);
        if (error != FlyCapture2::PGRERROR_OK)
        {
            error.PrintErrorTrace();
            return false;
        }
        Mode.mode = 14;
        Mode.onOff = true;
        Mode.polarity = 1;
        error = cam.SetTriggerMode (&Mode);
        if (error != FlyCapture2::PGRERROR_OK)
        {
            error.PrintErrorTrace();
            return false;
        }
    }
    {
        FlyCapture2::Property p;
        memset (&p, 0, sizeof(p));
        p.type = FlyCapture2::AUTO_EXPOSURE;
        p.onOff = false;
        error = cam.SetProperty (&p);
        if (error != FlyCapture2::PGRERROR_OK)
        {
            error.PrintErrorTrace();
            return false;
        }
        memset (&p, 0, sizeof(p));
        p.type = FlyCapture2::BRIGHTNESS;
        p.absControl = true;
        p.absValue = Brightness;
        error = cam.SetProperty (&p);
        if (error != FlyCapture2::PGRERROR_OK)
        {
            error.PrintErrorTrace();
            return false;
        }
        memset (&p, 0, sizeof(p));
        p.type = FlyCapture2::SHUTTER;
        p.absControl = true;
        p.absValue = Shutter;
        p.onOff = false;
        error = cam.SetProperty (&p);
        if (error != FlyCapture2::PGRERROR_OK)
        {
            error.PrintErrorTrace();
            return false;
        }
        memset (&p, 0, sizeof(p));
        p.type = FlyCapture2::GAIN;
        p.absControl = true;
        p.absValue = Gain;
        p.onOff = false;
        error = cam.SetProperty (&p);
        if (error != FlyCapture2::PGRERROR_OK)
        {
            error.PrintErrorTrace();
            return false;
        }
        bool IsStandard = false;
        {
            error = cam.SetVideoModeAndFrameRate (FlyCapture2::VideoMode::VIDEOMODE_640x480Y8, FlyCapture2::FRAMERATE_60 );
            if (error != FlyCapture2::PGRERROR_OK)
            {
                error.PrintErrorTrace();
                return false;
            }
            FlyCapture2::Format7ImageSettings f7;
            memset (&f7, 0, sizeof(f7));
            f7.mode = FlyCapture2::MODE_0;
            float Percent = 1;
            f7.mode = FlyCapture2::MODE_0;
            f7.height = h;
            f7.width = w;
            f7.offsetX = 4+((640-w)/2);
            f7.offsetY = 2+((480-h)/2);
            f7.pixelFormat = FlyCapture2::PIXEL_FORMAT_MONO8;
            Percent = 100;
            bool Valid = false;
            FlyCapture2::Format7PacketInfo Info;
            error = cam.ValidateFormat7Settings  (&f7, &Valid, &Info);
            if (error != FlyCapture2::PGRERROR_OK)
            {
                error.PrintErrorTrace();
                return false;
            }           
            error = cam.SetFormat7Configuration (&f7, Info.recommendedBytesPerPacket);
            if (error != FlyCapture2::PGRERROR_OK)
            {
                error.PrintErrorTrace();
                return false;
            }
        }
    }
    cam.GetConfiguration  ( &Config);
    Config.grabTimeout = 4000;
    Config.numBuffers = 120;
    Config.grabMode = FlyCapture2::BUFFER_FRAMES;
    error = cam.SetConfiguration  ( &Config);
    if (error != FlyCapture2::PGRERROR_OK)
    {
        error.PrintErrorTrace();
        return false;
    }

    PrintCameraInfo(&camInfo);        

    // Start capturing images
    error = cam.StartCapture();
    if (error != FlyCapture2::PGRERROR_OK)
    {
        error.PrintErrorTrace();
        return false;
    }
}
4

2 回答 2

2

刚刚看到 AndyUK 的第 4 点,但不确定这是否会对原始海报有所帮助。我需要一些关于返回的错误的额外信息。要获得设置格式 7 的更通用代码,您需要从相机查询可用的步长。每个模型(以及可能的固件版本)都将支持偏移的步长和图像大小的步长。指定的偏移量和大小必须是这些步长值的倍数。如果您使用 Camera.GetFormat7Info() 提取信息,则相关字段为 offsetHStepSize、offsetVStepSize、imageHStepSize 和 imageVStepSize。我不确定,但听起来 AndyUK 的 Flea2 模型的值将是 8、2、8、2。尽管这很常见,但偏移量和图像大小步长不一定相同。

virtual Error GetFormat7Info( 
            Format7Info*   pInfo,
            bool*          pSupported );

/** Format 7 information for a single mode. */
struct Format7Info
{
        /** Format 7 mode. */
        Mode mode;

        /** Maximum image width. */
        unsigned int maxWidth;
        /** Maximum image height. */
        unsigned int maxHeight;
        /** Horizontal step size for the offset. */
        unsigned int offsetHStepSize;
        /** Vertical step size for the offset. */
        unsigned int offsetVStepSize;
        /** Horizontal step size for the image. */
        unsigned int imageHStepSize;
        /** Vertical step size for the image. */
        unsigned int imageVStepSize;
        /** Supported pixel formats in a bit field. */
        unsigned int pixelFormatBitField;

        /** Current packet size in bytes. */
        unsigned int packetSize;
        /** Minimum packet size in bytes for current mode. */
        unsigned int minPacketSize;
        /** Maximum packet size in bytes for current mode. */
        unsigned int maxPacketSize;
        /** Current packet size as a percentage of maximum packet size. */
            float percentage;
        /** Reserved for future use. */
        unsigned int reserved[16];

        Format7Info()
        {
            mode = MODE_0;
            maxWidth = 0;
            maxHeight = 0;
            offsetHStepSize = 0;
            offsetVStepSize = 0;
            imageHStepSize = 0;
            imageVStepSize = 0;
            pixelFormatBitField = 0;
            packetSize = 0;
            minPacketSize = 0;
            maxPacketSize = 0;
            percentage = 0.0f;
            memset( reserved, 0, sizeof(reserved) );
        }
    };
于 2011-10-23T07:16:20.123 回答
0

只需澄清一两件事:

  1. 即使您断电并重新启动,拔下火线等,它是否经常这样做?

  2. 您是否尝试过运行安装时随附的 Point Gray 提供的 FlyCapture2 SDK 示例?无论固件/ SDK 更新如何,它们仍然可以正常运行吗?您似乎正在使用外部硬件触发器,因此您是否尝试过例如 AsynchTriggerEx 示例,当您为其提供软件触发器或外部硬件触发器时,它仍然运行良好?或者也许尝试了 FlyCap2MFC.exe 示例只是为了检查它是否仍然可以捕获视频?

  3. 当您逐行执行代码时会发生什么?当它进入 Start() 时,你知道麻烦从什么时候开始吗?库返回的“错误”值在什么时候是不受欢迎的,即不是每个相机功能应该返回的PGRERROR_OK值?

  4. 当我在 Format7(部分图像)模式下使用 Flea2 相机时,对于 MONO8 模式下的图像,我注意到设置 Format7ImageSettings 结构的宽度时,除非该值是我的特定应用程序的 8 的倍数,否则ValidateFormat7Settings 将返回FlyCapture2::Error 值 PGRERROR_IIDC_FAILED。同样,高度值也需要是2(偶数)的倍数,以确保令人满意的 Format7 设置。此错误会导致 cam.StartCapture() 函数挂起。

我不知道最后一点是否已经记录在 Point Grey 文献中,而只是一个观察。我可能在第 4 点上搞错了。我还是 FlyCapture 的新手,还没有完全理解它。我很高兴有机会直接讨论这个问题。

更多关于最后一点的信息

于 2011-09-28T13:47:54.967 回答