66 lines
2.4 KiB
C
66 lines
2.4 KiB
C
/* Debug ThermalSDK harness: verbose loading, check every step. */
|
|
#define _WIN32_WINNT 0x0601
|
|
#include <windows.h>
|
|
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
|
|
typedef void (CALLBACK *INewIRFrame)(const unsigned char *, int, int, int);
|
|
typedef bool (CALLBACK *fn_Start_t)(void);
|
|
typedef void (CALLBACK *fn_Stop_t)(void);
|
|
typedef void (CALLBACK *fn_SetNewIRFrameDelegate_t)(INewIRFrame);
|
|
typedef int (CALLBACK *fn_GetSDKVersion_t)(void);
|
|
|
|
static volatile int g_frames;
|
|
static unsigned char g_last[320 * 240 * 3];
|
|
static int g_saved;
|
|
|
|
static void CALLBACK onIR(const unsigned char *buf, int w, int h, int ch) {
|
|
if (buf) {
|
|
memcpy(g_last, buf, (size_t)w * h * ch);
|
|
if (g_saved < 8) {
|
|
char path[128];
|
|
snprintf(path, sizeof(path), "official_ir_%02d.rgb", g_saved);
|
|
FILE *f = fopen(path, "wb");
|
|
if (f) { fwrite(buf, 1, (size_t)w * h * ch, f); fclose(f); }
|
|
g_saved++;
|
|
}
|
|
if (g_frames < 5) {
|
|
printf(" IR frame: w=%d h=%d ch=%d first RGB=%d,%d,%d\n",
|
|
w, h, ch, buf[0], buf[1], buf[2]);
|
|
}
|
|
}
|
|
g_frames++;
|
|
}
|
|
|
|
int main(void) {
|
|
const char *dir = "C:\\Project\\MAG160C\\IR_Camera_SDK-1.0.1\\windows\\windows\\app";
|
|
printf("SetDllDirectory: %d\n", SetDllDirectoryA(dir));
|
|
HMODULE h = LoadLibraryA("ThermalSDK.dll");
|
|
printf("LoadLibrary ThermalSDK: %p err=%lu\n", (void*)h, GetLastError());
|
|
if (!h) return 1;
|
|
fn_Start_t T_Start = (fn_Start_t)GetProcAddress(h, "Start");
|
|
fn_Stop_t T_Stop = (fn_Stop_t)GetProcAddress(h, "Stop");
|
|
fn_SetNewIRFrameDelegate_t T_Set = (fn_SetNewIRFrameDelegate_t)GetProcAddress(h, "SetNewIRFrameDelegate");
|
|
fn_GetSDKVersion_t T_Ver = (fn_GetSDKVersion_t)GetProcAddress(h, "GetSDKVersion");
|
|
printf("exports: Start=%p Set=%p Ver=%p\n", (void*)T_Start, (void*)T_Set, (void*)T_Ver);
|
|
|
|
/* dependencies */
|
|
HMODULE core = LoadLibraryA("CoreSDKLib.dll");
|
|
printf("CoreSDKLib: %p err=%lu\n", (void*)core, GetLastError());
|
|
HMODULE cam = LoadLibraryA("CameraSDK.dll");
|
|
printf("CameraSDK: %p err=%lu\n", (void*)cam, GetLastError());
|
|
|
|
if (T_Set) T_Set(onIR);
|
|
printf("delegate set, calling Start()...\n");
|
|
fflush(stdout);
|
|
BOOL ok = T_Start ? T_Start() : FALSE;
|
|
printf("Start returned: %d\n", ok);
|
|
fflush(stdout);
|
|
Sleep(8000);
|
|
printf("frames received: %d\n", g_frames);
|
|
if (T_Stop) T_Stop();
|
|
printf("done\n");
|
|
return 0;
|
|
}
|