几个月来,我一直在使用Point Grey Research公司的Dragonfly Express相机。我已经编写了代码来使用相机和抓取图像。最近我已经将固件和SDK从2更新到2.2,从那时起我就无法使用我的代码抓取图像。新的FlyCapture2控制面板(2.2)工作,并能够使用相同的相机捕捉视频。具体来说,当我在Camera对象上调用StartCapture时,我得到了一个错误。我正在粘贴我的程序的输出,然后我会添加相关的相机代码:
* CAMERA INFORMATION *序列号- 7340769相机型号-蜻蜓快车DX-BW相机供应商- Point Grey Research传感器-柯达KAI-0340DM (1/3" 640x480 CCD)分辨率- 648x484固件版本为1.1.1.21固件构建时间- 2006年6月21日星期三23:01:00
错误跟踪:来源:. iidcamera internal .cpp(429) Built: Sep 23 2010 12:41:46 -启动错误Ng等时流。+-> From: .Iso.cpp(1515) Built: Sep 23 2010 12:41:43 -同步启动失败. 错误:0 x15。
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;
}
}
刚刚看到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) );
}
};
有一两件事需要澄清:
-
它是否不断地这样做,即使你断电并重新启动,拔掉火线等?
-
您是否尝试运行由Point Gray提供的安装附带的FlyCapture2 SDK示例?无论固件/SDK更新如何,它们仍然可以正常运行吗?你似乎是利用外部硬件触发器,所以你有没有尝试过例如AsynchTriggerEx的例子,这仍然运行良好,当你馈送它的软件触发器或外部硬件触发器?或者也许尝试FlyCap2MFC.exe的例子只是为了检查它仍然捕获视频,好吗?
-
当您逐行执行代码时会发生什么?当它进入Start()时,您知道问题是从哪里开始的吗?在什么时候,库返回的"错误"值是不受欢迎的,即不是PGRERROR_OK值每个相机函数应该返回?
-
当我在Format7(部分图像)模式下使用Flea2相机时,对于MONO8模式下的图像,我注意到在设置format7imagessettings结构体的宽度时,除非此值是8的倍数对于我的特定应用程序,然后ValidateFormat7Settings将返回FlyCapture2::Error值PGRERROR_IIDC_FAILED。同样,高度值也需要是2(偶数)的倍,以确保满意的Format7设置。此错误将导致cam.StartCapture()函数挂起。
我不知道最后一点是否已经记录在point Grey的文献中,但这只是一种观察。第四点我可能弄错了。我仍然是FlyCapture的新手,还没有完全理解它。我希望有机会澄清这件事。