/* ThermalSDK capture v3: save frames + read temperatures. */ #define _WIN32_WINNT 0x0601 #include #include #include #include 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 void (CALLBACK *fn_ReadTemperatureAtPoint_t)(int, int, unsigned char *); typedef void (CALLBACK *fn_SetTempBoundary_t)(double, double, double); typedef void (CALLBACK *fn_SetUnitMode_t)(int); 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 && w > 0 && h > 0 && ch == 3) { memcpy(g_last, buf, (size_t)w * h * ch); if (g_saved < 10) { 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++; } } g_frames++; } int main(void) { SetDllDirectoryA("C:\\Project\\MAG160C\\IR_Camera_SDK-1.0.1\\windows\\windows\\app"); HMODULE h = LoadLibraryA("ThermalSDK.dll"); printf("load: %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_ReadTemperatureAtPoint_t T_Temp = (fn_ReadTemperatureAtPoint_t)GetProcAddress(h, "ReadTemperatureAtPoint"); fn_SetTempBoundary_t T_Bound = (fn_SetTempBoundary_t)GetProcAddress(h, "SetTempBoundary"); fn_SetUnitMode_t T_Unit = (fn_SetUnitMode_t)GetProcAddress(h, "SetUnitMode"); printf("exports: Start=%p Temp=%p\n", (void*)T_Start, (void*)T_Temp); if (!T_Start || !T_Set || !T_Temp) { printf("missing\n"); return 2; } T_Unit(0); T_Bound(30.0, 44.0, 37.0); T_Set(onIR); printf("Start()...\n"); fflush(stdout); BOOL ok = T_Start(); printf("Start=%d\n", ok); fflush(stdout); DWORD t0 = GetTickCount(); while (g_frames < 12 && GetTickCount() - t0 < 12000) Sleep(100); int pts[][2] = {{80, 60}, {40, 40}, {120, 80}, {80, 30}, {30, 90}, {130, 100}}; for (int n = 0; n < 6; ++n) { unsigned char res[64] = {0}; T_Temp(pts[n][0], pts[n][1], res); printf("temp(%d,%d): ", pts[n][0], pts[n][1]); for (int i = 0; i < 32; ++i) printf("%02x ", res[i]); printf("\n"); fflush(stdout); Sleep(100); } printf("frames: %d saved: %d\n", g_frames, g_saved); T_Stop(); printf("done\n"); return 0; }