📄 camlink.hpp
字号:
/*******************************************************************************\
Copyright (C) 2001-2008, Vimicro Corporation ("VIMICRO")
VIMICRO USB CAMERA DRIVER FOR WINDOWS CE 3.0
--------------------------------------------------------------------------
+ This program has been developed by Vimicro Corporation. You have VIMICRO's
permission to incorporate this code into your product, royalty free.
+ VIMICRO specifically disclaims all warranties, express or implied, and all
liability, including consequential and other indirect damages, for the use
of this code, including liability for infringement of any proprietary
rights, and including the warranties of merchantability and fitness for a
particular purpose. VIMICRO does not assume any responsibility for any
errors which may appear in this code nor any responsibility to update it.
--------------------------------------------------------------------------
Component: CAMLINK / CAMPRP / CAMSRC / USBCAM
File: CAMIINK.HPP
Author: Bob Lu <bob@vimicro.com> / <bob_lu@msn.com>
\*******************************************************************************/
#ifndef _CAMLINK_HPP_
#define _CAMLINK_HPP_
#define CAM_DEBUG 0
//#define CAM_DEBUG 1
#define CAM_MSBOX 0
#define ROUND0(x) (int)(x)
#define ROUND1(x) (int)(x + 0.5)
#define RANGE08(x) x<0 ? 0 : (x>255 ? 255 : x)
#define SIZEOF(object) ((size_t) sizeof(object))
#define MALLOC(size) malloc((size_t)size)
#define MEMFREE(mem) if (mem) free( (void *)mem )
#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
#define MEMMOVE(dest,src,size) memmove((void *)(dest), (const void *)(src), (size_t)(size))
#define FOPEN(filename, mode) fopen( (const char *)filename, (const char *)mode )
#define FCLOSE(stream) fclose( (FILE *)stream )
#define FREAD(file,buf,sizeofbuf) ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
#define FWRITE(file,buf,sizeofbuf) ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
typedef struct _pixel{
BYTE b;
BYTE g;
BYTE r;
} pixel;
#define USBCAM_SLOT0_DWORD TEXT("Slot0")
#define USBCAM_SLOT1_DWORD TEXT("Slot1")
#define USBCAM_BRIGHTNESS_DWORD TEXT("Brightness")
#define USBCAM_CONTRAST_DWORD TEXT("Contrast")
#define USBCAM_GAMMA_DWORD TEXT("Gamma")
#define USBCAM_IMAGESIZE_DWORD TEXT("ImageSize")
#define USBCAM_IMAGEMODE_DWORD TEXT("ImageMode")
#define USBCAM_ANTIFLICKER_DWORD TEXT("AntiFlicker")
#define USBCAM_BANDWIDTH_DWORD TEXT("BandWidth")
//------------------------------------------------------------------------------
#define ZIP30X_MAX_DEVICES 0x2
#define ZIP30X_MIN_FRAMELEN 0x200
#define ZIP30X_MAX_JPEG_LENGTH 0x20000
#define ZIP30X_THRESHOLD_JPEG 0x19000
#define ZIP30X_QSIF_RGB24_LEN 0xE100
#define ZIP30X_SIF_RGB24_LEN 0x38400
#define ZIP30X_SIZE_QSIF 0x0
#define ZIP30X_SIZE_SIF 0x1
#define ZIP30X_SIZE_VGA 0x2
#define ZIP30X_SIZE_80X60 0x3 //zy
#define ZIP30X_JPEG_RETRY 0x64
#define ZIP30X_FLICKER_50H 0x0
#define ZIP30X_FLICKER_60H 0x1
#define ZIP30X_FLICKER_OUT 0x2
#define ZIP30X_ALT_0 0x0
#define ZIP30X_ALT_1 0x1
#define ZIP30X_ALT_2 0x2
#define ZIP30X_ALT_3 0x3
#define ZIP30X_ALT_4 0x4
#define ZIP30X_ALT_5 0x5
#define ZIP30X_ALT_6 0x6
#define ZIP30X_ALT_7 0x7
#define DEFAULT_ZIP30X_SIZE ZIP30X_SIZE_QSIF
#define DEFAULT_ZIP30X_FLICKER ZIP30X_FLICKER_50H
#define DEFAULT_ZIP30X_ALT ZIP30X_ALT_2
#define DEFAULT_ZIP30X_BRIGHTNESS 5
#define DEFAULT_ZIP30X_CONTRAST 5
#define DEFAULT_ZIP30X_GAMMA 5
#define DEFAULT_ZIP30X_IMAGEMODE 3
typedef struct _CAM_PROPERTY_EXT {
BOOL bInstar;
DWORD dwRemoveLine;
DWORD Brightness;
DWORD Contrast;
DWORD Gamma;
DWORD Register;
DWORD Size;
DWORD Flicker;
} CAM_PROPERTY_EXT, *PCAM_PROPERTY_EXT;
typedef struct _CAM_INSTAR
{
BOOL bEnumed;
DWORD dwAvalCount;
DWORD dwDeveCount;
DWORD dwLstAvalSlot;
HANDLE hCamera;
PUCHAR pDecoderObj;
PUCHAR pIOReadData;
// -Jerry- FIFO, Mar 10, 03
BOOL bFIFOSign;
DWORD dwFIFOCount;
CAM_PROPERTY_EXT PropertyExt[ZIP30X_MAX_DEVICES];
} CAM_INSTAR, * PCAM_INSTAR;
#define FIFO_WARNING
#define FIFO_REGADDR 0x1A
#define FIFO_SIGN 0
#define FIFO_COUNT 4
//------------------------------------------------------------------------------
DWORD CamDecompress(unsigned char *Inbuf,
DWORD inbufLen,
unsigned char *OutBuf,
DWORD outbufLen,
BOOL bProperty,
BOOL bScale);
//------------------------------------------------------------------------------
/*
* TRY macro workhorse
* -- envelops expression inside try-except
*/
#define TRY_EXCEPT( expression ) \
{ \
BOOL bException=FALSE; \
DWORD dwExceptionCode; \
__try \
{ \
expression; \
} \
__except(EXCEPTION_EXECUTE_HANDLER) \
{ \
bException = TRUE; \
dwExceptionCode = _exception_code(); \
} \
if ( bException ) \
{ \
DWORD dwLastError = GetLastError(); \
CAMERR((TEXT("!! Error ExceptionCode(%u), Error(%d)\r\n"), dwExceptionCode, dwLastError)); \
} \
}
//------------------------------------------------------------------------------
#ifdef DEBUG
#define CAMDBG(v) RETAILMSG(TRUE,v)
#define CAMERR(v) RETAILMSG(TRUE,v)
#define CAMBOX(v) CamIO_MessageError(v);
#else //DEBUG
#if CAM_DEBUG
#define CAMDBG(v) RETAILMSG(TRUE, v)
#define CAMERR(v) RETAILMSG(TRUE, v)
#else //CAM_DEBUG
#define CAMDBG(v)
#define CAMERR(v)
#endif //CAM_DEBUG
#if CAM_MSBOX
#define CAMBOX(v) CamIO_MessageError(v);
#else //CAM_MSBOX
#define CAMBOX(v)
#endif //CAM_MSBOX
#endif //DEBUG
#endif // _CAMLINK_HPP_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -