几个月来,我一直在使用点灰研究公司的蜻蜓快车相机。我已经编写了使用相机的代码,并用它获取图像。最近,我已经将固件和SDK从2更新到2.2,因为那时我无法使用我的代码获取图像。新的FlyCapture2控制面板(2.2)工作并能够使用相同的摄像机捕捉视频。具体来说,当我调用相机对象上的StartCapture时,我会收到一个错误。我正在粘贴我的程序的输出,然后我将添加相关的摄像机代码:
*相机信息*系列- 7340769相机型号-蜻蜓快车DX-BW相机供应商-点灰色研究传感器-柯达凯-0340 DX (1/3“640x480 CCD)分辨率- 648x484固件版本- 1.1.1.21固件建立时间-韦德6月21 :01:00 2006
错误跟踪:来源:.\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;
}
}发布于 2011-10-23 07:16:20
刚刚看到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-09-28 13:47:54
只需澄清一两件事:
我不知道这最后一点是否已经记录在点灰色文献中,但只是一个观察。在第4点上,我可能弄错了。我仍然是FlyCapture的新手,还没有完全理解这一切。我欢迎有机会直截了当地谈这件事。
关于最后一点,这里。
https://stackoverflow.com/questions/6640522
复制相似问题