几个月来,我一直在使用 Point Grey Research 的 Dragonfly Express 相机。 我已经编写了代码来使用相机并用它抓取图像。 最近我将固件和 SDK 从 2 更新到 2.2,从那以后我无法使用我的代码抓取图像。新的 FlyCapture2 控制面板 (2.2) 可以使用同一台相机来捕捉视频。 具体来说,当我在 Camera 对象上调用 StartCapture 时出现错误。我正在粘贴程序的输出,之后我将添加相关的相机代码:
* 相机信息 * 序列号 - 7340769 相机型号-蜻蜓快车DX-BW 相机供应商 - Point Grey Research 传感器 - 柯达 KAI-0340DM(1/3"640x480 CCD) 分辨率 - 648x484 固件版本 - 1.1.1.21 固件构建时间 - Wed Jun 21 23:01:00 2006
错误跟踪: 来源:.\IidcCameraInternal.cpp(429) 内置:2010 年 9 月 23 日 12:41:46 - 启动错误 ng 等时流。 +-> 来自:.\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;
}
}
最佳答案
刚看到 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) );
}
};
关于c++ - 更新固件\SDK 后无法在 PTGRey 相机(Dragonfly express)上开始捕获,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6640522/