📄 bcam.h
字号:
//-----------------------------------------------------------------------------
// Company: Basler Vision Technologies
// Section: Vision Components
// Project: 1394 Driver
// <b> Visual SourceSafe Information:</b>
// $Archive: /Software/inc/Bcam.h $
// $Author: Moebius, V.$
// $Revision: 28$
// $Date: 22.06.2004 10:28:34$
//-----------------------------------------------------------------------------
/**
\file Bcam.h
\brief User C++ API for the BCAM 1394 driver
This interface needs the following classes defined:
- CString
- CPoint
- CSize
Use either WTL or MFC to supply these classes.
\todo Things missing in this interface
- Maybe somemore async functions
- Ask camera, if OnePush is still active
Things to implement in the camera
- Memory_Channel
- Vmode_Error_Status
- Feature_Control_Error_Status
- White_Balance
- Format7 : mode == binning, ColorCode == Color
*/
//-----------------------------------------------------------------------------
#pragma warning (disable: 4005) // 'DEFINE_GUID' : macro redefinition
#ifndef BCAM_H
#define BCAM_H
#if (WINVER < 0x40A)
#error Use of Bcam API requires WINVER >= 0x40A
#endif
#if(WINVER<0x0500)
typedef PVOID HDEVNOTIFY;
typedef HDEVNOTIFY *PHDEVNOTIFY;
#define DEVICE_NOTIFY_WINDOW_HANDLE 0x00000000
#define ERROR_DEVICE_REMOVED 1617L
WINUSERAPI
HDEVNOTIFY
WINAPI
RegisterDeviceNotificationA(
IN HANDLE hRecipient,
IN LPVOID NotificationFilter,
IN DWORD Flags
);
WINUSERAPI
HDEVNOTIFY
WINAPI
RegisterDeviceNotificationW(
IN HANDLE hRecipient,
IN LPVOID NotificationFilter,
IN DWORD Flags
);
#ifdef UNICODE
#define RegisterDeviceNotification RegisterDeviceNotificationW
#else
#define RegisterDeviceNotification RegisterDeviceNotificationA
#endif // !UNICODE
WINUSERAPI
BOOL
WINAPI
UnregisterDeviceNotification(
IN HDEVNOTIFY Handle
);
#endif
// #pragma warning (disable: 4996) // 4996: ... was declared deprecated
// #pragma warning (disable: 4702) // unreachable code
#if defined( USE_MFC )
#include <afxwin.h> // MFC core and standard components
#else
#include <windows.h>
#endif
#pragma warning( push, 3 )
#include <dbt.h>
#include <list>
#include <map>
#pragma warning( pop )
#if defined( USE_WTL) && _MSC_VER < 1300
#include <atlapp.h>
#include <atlmisc.h> // WTL's CSize, CString, ...
#endif
#if defined( USE_MFC ) && _MSC_VER >= 1300
#include <afxstr.h> // MFC7 CString
#endif
#if ! defined( USE_MFC ) && _MSC_VER >= 1300
#include <atlstr.h> // ATL CString
#endif
#if _MSC_VER >= 1300
#include <atltypes.h> // CSize, CPoint, ...
#endif
#include "functions.h"
#include "BcamError.h"
#include "BcamException.h"
#include "BcamPropertyBag.h"
#include <assert.h>
#ifndef TRACE
/// In case we are using WTL replace TRACE calls by AtlTrace
#define TRACE AtlTrace
#endif
/// the bcam namespace
namespace Bcam
{
using namespace Bvc;
/*-------------------------*/
struct BcamOL;
/// Function codes of all functions which can be called asynchronously
enum FunctionCode_t
{
NotifyUser = -3, ///< a user defined notification, no function
NotifyQuit = -2, ///< notification to quit processing, no function
NotifyBreak = -1, ///< dito
AsyncShutterRawSet = 0, ///< function Bcam.Shutter.Raw.SetAsync was completed
AsyncShutterAbsSet, ///< function Bcam.Shutter.Abs.SetAsync was completed
AsyncGainRawSet, ///< function Bcam.Gain.Raw.SetAsync was completed
AsyncGainAbsSet, ///< function Bcam.Gain.Abs.SetAsync was completed
AsyncBrightnessRawSet, ///< function Bcam.Brightness.Raw.SetAsync was completed
AsyncBrightnessAbsSet, ///< function Bcam.Brightness.Abs.SetAsync was completed
AsyncHueRawSet, ///< function Bcam.Hue.Raw.SetAsync was completed
AsyncHueAbsSet, ///< function Bcam.Hue.Abs.SetAsync was completed
AsyncGammaRawSet, ///< function Bcam.Gamma.Raw.SetAsync was completed
AsyncGammaAbsSet, ///< function Bcam.Gamma.Abs.SetAsync was completed
AsyncSaturationRawSet, ///< function Bcam.Saturation.Raw.SetAsync was completed
AsyncSaturationAbsSet, ///< function Bcam.Saturation.Abs.SetAsync was completed
AsyncTriggerRawSet, ///< function CBcam::CTrigger::CRawRegister::SetAsync was completed
AsyncTriggerAbsSet, ///< function CBcam::CTrigger::CAbsRegister::SetAsync was completed
AsyncWhiteBalanceRawUBSet, ///< function Bcam.WhiteBalance.Raw.UBValue.SetAsync was completed
AsyncWhiteBalanceRawVRSet, ///< function Bcam.WhiteBalance.Raw.VRValue.SetAsync was completed
AsyncWhiteBalanceAbsUBSet, ///< function Bcam.WhiteBalance.Abs.UBValue.SetAsync was completed
AsyncWhiteBalanceAbsVRSet, ///< function Bcam.WhiteBalance.Abs.VRValue.SetAsync was completed
AsyncPositionSet, ///< function CSetPosition::SetAsync was completed
AsyncSizeSet, ///< function CSetSize::SetAsync was completed
AsyncBytePerPacketSet, ///< function CBytePerPacket::SetAsync was completed
AsyncGrabImage, ///< An image was grabbed
AsyncOneShot, ///< function CBcam::COneshot::SetAsync was completed
AsyncContinuousShot ///< function CBcem::CContiousShot::SetAsync was completed
};
/// Different types of IsSupported inquiries
enum Supported_t
{
inqPresent,
inqAbsControl,
inqOnePush,
inqReadOut,
inqOnOff,
inqAuto,
inqManual,
inqPolarity,
inqTestImage_1 = 1,
inqTestImage_2 = 2,
inqTestImage_3 = 3,
inqTestImage_4 = 4,
inqTestImage_5 = 5,
inqTestImage_6 = 6,
inqTestImage_7 = 7,
inqShadingCorrection,
inqSCM_1_3 = 1, // shading correction with factor 1:3 supported
inqSCM_1_5 = 2 // shading correction with factor 1:5 supported
} ;
/// Trigger modes defined by DCAM
enum DCSTriggerMode
{
DCS_TriggerMode0 = 0,
DCS_TriggerMode1,
DCS_TriggerMode2,
DCS_TriggerMode3
};
/// Shading correction modes
enum SCMode_t
{
SCM_Test = -1, // the camera sends the shading correction table instead of real image data
SCM_Disabled = 0,
SCM_1_3 = 1, // shading correction with factor 1:3
SCM_1_5 = 2 // shading correction with factor 1:5
};
/// Trigger polarity
enum Polarity_t
{
LowActive = 0,
HighActive = 1,
};
/// Timespan in msec
typedef ULONG Timespan;
/// Video formats as defided by DCAM
enum DCSVideoFormat
{
DCS_Format0 = 0,
DCS_Format1 = 1,
DCS_Format2 = 2,
DCS_Format6 = 6,
DCS_Format7 = 7
};
/// Modes of a video format as defined by DCAM
enum DCSVideoMode
{
DCS_IgnoreVideoMode = -1,
DCS_Mode0 = 0,
DCS_Mode1 = 1,
DCS_Mode2 = 2,
DCS_Mode3 = 3,
DCS_Mode4 = 4,
DCS_Mode5 = 5,
DCS_Mode6 = 6,
DCS_Mode7 = 7,
};
/// Fixed frame rates as defined by DCAM
enum DCSVideoFrameRate
{
DCS_IgnoreFrameRate = -1,
DCS_1_875fps = 0,
DCS_3_75fps,
DCS_7_5fps,
DCS_15fps,
DCS_30fps,
DCS_60fps,
DCS_120fps,
DCS_240fps
};
/// Values used by switches
enum OnOff_t
{
Off = 0,
On
};
/**
* \define Used by nested classes to get access to the outer class
*/
#define IMPLEMENT_THIS(OUTER, MEMBER_VARIABLE) \
OUTER* This() \
{ \
return (OUTER*)((BYTE*)this - offsetof(OUTER, MEMBER_VARIABLE)); \
};
/**------------------------------------------------------------------
* class: BcamUtility
*
* \brief Helper class which offers the user some convenience
*
*/
//--------------------------------------------------------------------
class BcamUtility
{
public:
/// Table 1.2.2
static CString VideoResolutionName(DCSVideoFormat VideoFormat, DCSVideoMode VideoMode);
/// Table 1.2.3
static CString VideoFrameRateName(DCSVideoFrameRate VideoFrameRate);
/// Mapping color ID to name (according to 2.2.2)
static CString ColorCodeName(DCSColorCode ColorCode);
/// Mapping BcamFeatureID to feature name
static CString FeatureName(BcamFeatureID id);
/// Mapping (video format, video mode ) to number of bytes per packet
static unsigned long BytePerPacket(DCSVideoFormat VideoFormat, DCSVideoMode VideoMode, DCSVideoFrameRate VideoFramerate);
/// Mapping (video format, video mode ) to ImageSize (for formats 0 - 2 only)
static CSize ImageSize(DCSVideoFormat VideoFormat, DCSVideoMode VideoMode);
/// Mapping (video format, video mode ) to color code (for formats 0 - 2 only)
static DCSColorCode ColorCode(DCSVideoFormat VideoFormat, DCSVideoMode VideoMode);
/// Mapping DCSColorCode to number of bits per pixel
static unsigned short BitsPerPixel(DCSColorCode ColorCode);
/// is a given device name a "full" device name, i.e. does it contain the driver interface GUID
static bool IsFullDeviceName(CString deviceName);
/// returns the full device name
static CString FullDeviceName(CString deviceName);
/// returns the friendly device name (i.e. not containng the driver interface GUID)
static CString FriendlyDeviceName(CString deviceName);
};
//------------------------------------------------------------------------------
// class CBcam
// Author: Hartmut Nebelung
// Date:
//------------------------------------------------------------------------------
/**
* \brief Encapsulation of the Bcam driver API
*
*
* \todo Multishot
*/
//------------------------------------------------------------------------------
class CBcam
{
typedef std::map<HANDLE, CBcam*> BcamMap_t ;
public:
/// Callback function type
typedef void (*BcamCallbackFunc) (CBcam&, void*);
CBcam();
private: // copying prohibited
CBcam( const CBcam& );
CBcam& operator=( const CBcam& );
public:
virtual ~CBcam();
// List all cameras currently found in the system
static std::list<CString> DeviceNames();
static std::list<CString>& DeviceNames( std::list<CString>& );
// Register a client window for device notifications
static void RegisterClient(HWND hwnd);
// Unregister a client from device notifications
static void UnregisterClient();
// CleanUp code.
static void CleanUp();
// Get the version of the installed driver
static DWORD InstalledDriverVersion();
// Handler for device notifications
static LRESULT OnDeviceChange(WPARAM wParam, LPARAM lParam);
// Set a callback function which will be called if a device is to be removed
void SetOnRemoveRequestCallback( BcamCallbackFunc, void* pv = NULL );
// Set a callback function which will be called if a device has been removed
void SetOnRemoveCompleteCallback( BcamCallbackFunc, void* pv = NULL );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -