45#include <m3api/xiApi.h>
59#define DEFAULT_TIMEOUT_MS 100
60#define EXPOSURE_DEFAULT_US 33333L
61#define MAGIC to_fourcc('X', 'I', 'M', 'E')
62#define MOD_NAME "[XIMEA] "
63#define MICROSEC_IN_SEC 1000000.0
68 XI_RETURN __cdecl (*
xiOpenDevice)(IN DWORD DevId, OUT PHANDLE hDevice);
71 XI_RETURN __cdecl (*
xiGetImage)(IN HANDLE hDevice, IN DWORD timeout, OUT LPXI_IMG img);
86#define GET_SYMBOL(sym) do {\
87 f->sym = (void *) dlsym(f->handle, #sym);\
88 if (f->sym == NULL) {\
89 log_msg(LOG_LEVEL_ERROR, MOD_NAME "Unable to find symbol %s: %s\n", #sym, dlerror());\
94#ifdef XIMEA_RUNTIME_LINKING
95 f->
handle = dlopen(XIMEA_LIBRARY_NAME, RTLD_NOW);
98 XIMEA_LIBRARY_NAME, dlerror());
99 char path[strlen(XIMEA_LIBRARY_PATH) + 1 + strlen(XIMEA_LIBRARY_NAME) + 1];
100 strcpy(path, XIMEA_LIBRARY_PATH);
102 strcat(path, XIMEA_LIBRARY_NAME);
103 f->
handle = dlopen(path, RTLD_NOW);
107 XIMEA_LIBRARY_NAME, XIMEA_LIBRARY_PATH, dlerror());
137#ifdef XIMEA_RUNTIME_LINKING
148 color_printf(
"\t" TBOLD(
"fps")
" - frames per second (decimal, exclusive with exposure parameter)\n");
150 printf(
"Available devices:\n");
170 for (DWORD i = 0; i <
count; ++i) {
182 char *save_ptr = NULL;
185 while ((tok = strtok_r(tmp,
":", &save_ptr)) != NULL) {
186 if (!strcmp(tok,
"help")) {
190 if (strstr(tok,
"device=")) {
192 s->
device_id = strtol(tok + strlen(
"device="), &endptr, 0);
193 if (*endptr !=
'\0') {
196 }
else if (strstr(tok,
"exposure=")) {
202 }
else if (strstr(tok,
"fps=") != NULL) {
218#define CHECK(cmd) do { \
219 XI_RETURN ret = cmd; \
220 if (ret != XI_OK) { \
221 log_msg(LOG_LEVEL_ERROR, MOD_NAME "%s: %d\n", #cmd, (int) ret); \
276 memset(&img, 0,
sizeof img);
277 img.size =
sizeof img;
320 for (DWORD i = 0; i < card_count; ++i) {
321 snprintf(cards[i].
dev,
sizeof cards[i].
dev,
":device=%d", (
int) i);
329 *available_cards = cards;
struct audio_frame ** audio
int void(** deleter)(void *))
struct video_frame * vf_alloc_desc(struct video_desc desc)
Allocates video frame accordig given desc.
int color_printf(const char *format,...)
void log_msg(int level, const char *format,...)
#define LOG_LEVEL_ERROR
general errors
#define LOG_LEVEL_VERBOSE
#define VIDCAP_INIT_NOERR
state not initialized, other action performed (typically help)
#define VIDCAP_INIT_OK
initialization successful
#define VIDEO_CAPTURE_ABI_VERSION
#define VIDCAP_INIT_FAIL
error ocured
#define VIDCAP_INIT_AUDIO_NOT_SUPPORTED
card does not support audio
@ LIBRARY_CLASS_VIDEO_CAPTURE
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
struct used to comunicate with audio capture/playback device
struct ximea_functions funcs
char * data
Raw tile data. Pointer must be at least 4B aligned.
enum interlacing_t interlacing
unsigned int width
width of every tile (!)
unsigned int height
height of every tile (!)
Struct video_frame represents a video frame and contains video description.
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
XI_RETURN __cdecl(* xiSetParamInt)(IN HANDLE hDevice, const char *prm, const int val)
XI_RETURN __cdecl(* xiGetImage)(IN HANDLE hDevice, IN DWORD timeout, OUT LPXI_IMG img)
XI_RETURN __cdecl(* xiGetNumberDevices)(OUT PDWORD pNumberDevices)
XI_RETURN __cdecl(* xiOpenDevice)(IN DWORD DevId, OUT PHANDLE hDevice)
XI_RETURN __cdecl(* xiGetDeviceInfoString)(IN DWORD DevId, const char *prm, char *value, DWORD value_size)
XI_RETURN __cdecl(* xiCloseDevice)(IN HANDLE hDevice)
XI_RETURN __cdecl(* xiStopAcquisition)(IN HANDLE hDevice)
XI_RETURN __cdecl(* xiStartAcquisition)(IN HANDLE hDevice)
@ PROGRESSIVE
progressive frame
This is an umbrella header for video functions.
const char * vidcap_params_get_fmt(const struct vidcap_params *params)
unsigned int vidcap_params_get_flags(const struct vidcap_params *params)
#define VIDCAP_FLAG_AUDIO_ANY
static void vidcap_ximea_done(void *state)
static const struct video_capture_info vidcap_ximea_info
static int vidcap_ximea_parse_params(struct state_vidcap_ximea *s, char *cfg)
static void vidcap_ximea_close_lib(struct ximea_functions *f)
static void vidcap_ximea_probe(struct device_info **available_cards, int *count, void(**deleter)(void *))
static void vidcap_ximea_show_help()
static bool vidcap_ximea_fill_symbols(struct ximea_functions *f)
static struct video_frame * vidcap_ximea_grab(void *state, struct audio_frame **audio)
#define EXPOSURE_DEFAULT_US
static int vidcap_ximea_init(struct vidcap_params *params, void **state)
#define DEFAULT_TIMEOUT_MS