123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- #pragma once
- #ifdef _WIN32
- #ifdef LIBVIDEOCAPTURE_EXPORTS
- #define LIBVIDEOCAPTURE_API __declspec(dllexport)
- #else
- #define LIBVIDEOCAPTURE_API __declspec(dllimport)
- #endif
- # elif ( defined(__GNUC__) && __GNUC__ >= 4 )
- #define LIBVIDEOCAPTURE_API __attribute__((visibility("default")))
- #else // RVC_OS_WIN
- #define LIBVIDEOCAPTURE_API
- #endif // RVC_OS_WIN
- #include <stdarg.h>
- /**
- * video capture header file
- *
- * caution:
- * (1) the thread use these functions must call CoInitialize at first
- * (2) only tackle RGB24
- */
- /** function return values */
- #define VIDEOCAP_OK 0
- #define VIDEOCAP_ERROR -1
- /** frame size mode, we only support eight currently */
- #define VIDEOCAP_FRAME_SQCIF 0x00
- #define VIDEOCAP_FRAME_QQVGA 0x01
- #define VIDEOCAP_FRAME_QCIF 0x02
- #define VIDEOCAP_FRAME_QVGA 0x03
- #define VIDEOCAP_FRAME_CIF 0x04
- #define VIDEOCAP_FRAME_VGA 0x05
- #define VIDEOCAP_FRAME_4CIF 0x06
- #define VIDEOCAP_FRAME_SVGA 0x07
- #define VIDEOCAP_FRAME_NHD 0x08
- #define VIDEOCAP_FRAME_SXGA 0x09
- #define VIDEOCAP_FRAME_720P 0x0A
- #define VIDEOCAP_FRAME_1080P 0x0B
- //#define VIDEOCAP_CS_YUV420 0x01
- //#define VIDEOCAP_CS_RGB24 0x02
- /* width and height */
- #define VIDEOCAP_SQCIF_WIDTH 128
- #define VIDEOCAP_SQCIF_HEIGHT 96
- #define VIDEOCAP_QQVGA_WIDTH 160
- #define VIDEOCAP_QQVGA_HEIGHT 120
- #define VIDEOCAP_QCIF_WIDTH 176
- #define VIDEOCAP_QCIF_HEIGHT 144
- #define VIDEOCAP_QVGA_WIDTH 320
- #define VIDEOCAP_QVGA_HEIGHT 240
- #define VIDEOCAP_CIF_WIDTH 352
- #define VIDEOCAP_CIF_HEIGHT 288
- #define VIDEOCAP_VGA_WIDTH 640
- #define VIDEOCAP_VGA_HEIGHT 480
- #define VIDEOCAP_4CIF_WIDTH 704
- #define VIDEOCAP_4CIF_HEIGHT 576
- #define VIDEOCAP_SVGA_WIDTH 800
- #define VIDEOCAP_SVGA_HEIGHT 600
- #define VIDEOCAP_NHD_WIDTH 640
- #define VIDEOCAP_NHD_HEIGHT 360
- #define VIDEOCAP_SXGA_WIDTH 1280
- #define VIDEOCAP_SXGA_HEIGHT 960
- #define VIDEOCAP_720P_WIDTH 1280
- #define VIDEOCAP_720P_HEIGHT 720
- #define VIDEOCAP_1080P_WIDTH 1920
- #define VIDEOCAP_1080P_HEIGHT 1080
- #define VIDEOCAP_OPT_ENABLE_GRAB 0x01
- #define VIDEOCAP_OPT_EANBLE_RESIZE 0x02
- #define VIDEOCAP_OPT_ENABLE_FLIP 0x04
- #define VIDEOCAP_OPT_ENABLE_ASYNC_GRAB 0x08
- #define VIDEOCAP_OPT_HOZFLIP 0x10
- #define VIDEOCAP_MAX_MODE 12
- /* video device capability */
- typedef struct videocap_device_cap_s {
- int mode[VIDEOCAP_MAX_MODE]; /* VIDEOCAP_FRAME_XXX */
- int mode_cnt;
- int max_frame_interval[VIDEOCAP_MAX_MODE]; /* max frame interval for each mode */
- int min_frame_interval[VIDEOCAP_MAX_MODE]; /* min frame interval for each mode */
- }videocap_device_cap_t;
- struct video_frame;
- typedef struct videocap_param_s
- {
- /* mode VIDEOCAP_FRAME_xxx */
- int cap_mode; /* capture mode setting on capture device, mainly for picture grabbing */
- int res_mode; /* resize mode for user, for example, cap_mode 640*480, res_mode is 176*144 */
- /* video frame format */
- int frame_fmt; /* VIDEO_FORMAT_I420 or VIDEO_FORMAT_RGB24 */
- float fps; /* frame per second */
- int dev_id;/* device id, return by videocap_get_device_count and videocap_get_device_name */
- /** preview window */
- void* pre_hwnd; /* preview window handle , if null no preview */
- int pre_width; /* preview video width */
- int pre_height; /* preview video height */
- /** callbacks */
- /* called from inner thread, should not block, can be null */
- void (*on_frame)(void* user_data, video_frame* frame);
- void (*on_frame_raw)(void* user_data, video_frame* frame); // for rgb24
- int (*on_frame_i420)(void* user_data, video_frame* frame); // for i420
- /* triggered when video capture device is lost */
- void (*on_device_lost)(void* user_data);
- /* after grab */
- void (*on_grab)(void* user_data, video_frame* frame);
- void* user_data;
- int option; /* combination of VIDEOCAP_OPT_ xxx */
- int irotate;
- }videocap_param_t;
- typedef struct videocap_callback_s {
- void (*debug)(void* user_data, const char* fmt, va_list arg);
- void (*oncapturefailed)();
- void (*onvideocapexcption)();
- #ifdef _WIN32
- #else
- void (*logevent)(int itype, int idevid, const char* strmessage);
- #endif
-
- void* user_data;
- }videocap_callback_t;
- class IVideoCapture
- {
- public:
- virtual int VideoCaptureSetParam(videocap_param_t* param) = 0;
- virtual int StartVideoCapture() = 0;
- virtual int StopVideoCapture() = 0;
- virtual void VideoCaptureDestroy() = 0;
- virtual int GetCamBrightness(int* ibright, bool bRawRange) = 0;
- virtual int SetCamBrightness(int ibright, bool bRawRange) = 0;
- virtual int SetCamAutoBrightness() = 0;
- virtual bool GetCamRawBrightnessRange(int* imin, int* imax) = 0;
- };
- extern "C" LIBVIDEOCAPTURE_API IVideoCapture* CreateVideoCaptureObj(videocap_callback_t* pCallback);
- extern "C" LIBVIDEOCAPTURE_API void DestroyVideoCaptureObj(IVideoCapture* pIVideoCapture);
|