建立 MAG160C 逆向工程交接仓库
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
/* Capture grayscale AND RGB24 at the same moment via CoreSDKLib, plus
|
||||
* verify the palette mapping. */
|
||||
#define _WIN32_WINNT 0x0601
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.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 *MAG_GetOutputBMPdata_t)(int, int *, unsigned char **);
|
||||
typedef int (CALLBACK *MAG_GetOutputBMPdataRGB24_t)(int, unsigned char *, int, int);
|
||||
|
||||
static volatile int g_frames;
|
||||
static void CALLBACK onIR(const unsigned char *buf, int w, int h, int ch) {
|
||||
(void)buf; (void)w; (void)h; (void)ch;
|
||||
g_frames++;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
SetDllDirectoryA("C:\\Project\\MAG160C\\IR_Camera_SDK-1.0.1\\windows\\windows\\app");
|
||||
HMODULE t = LoadLibraryA("ThermalSDK.dll");
|
||||
HMODULE c = LoadLibraryA("CoreSDKLib.dll");
|
||||
if (!t || !c) return 1;
|
||||
fn_Start_t T_Start = (fn_Start_t)GetProcAddress(t, "Start");
|
||||
fn_Stop_t T_Stop = (fn_Stop_t)GetProcAddress(t, "Stop");
|
||||
fn_SetNewIRFrameDelegate_t T_Set = (fn_SetNewIRFrameDelegate_t)GetProcAddress(t, "SetNewIRFrameDelegate");
|
||||
MAG_GetOutputBMPdata_t G_Gray = (MAG_GetOutputBMPdata_t)GetProcAddress(c, "MAG_GetOutputBMPdata");
|
||||
MAG_GetOutputBMPdataRGB24_t G_RGB = (MAG_GetOutputBMPdataRGB24_t)GetProcAddress(c, "MAG_GetOutputBMPdataRGB24");
|
||||
|
||||
T_Set(onIR);
|
||||
BOOL ok = T_Start();
|
||||
printf("Start=%d\n", ok); fflush(stdout);
|
||||
Sleep(3000);
|
||||
|
||||
for (int chan = 0; chan < 5; ++chan) {
|
||||
int w = 0;
|
||||
unsigned char *graybuf = NULL;
|
||||
int rc = G_Gray(chan, &w, &graybuf);
|
||||
printf("chan %d gray rc=%d buf=%p\n", chan, rc, (void*)graybuf);
|
||||
if (rc && graybuf) {
|
||||
/* read true w/h from dev+0xadc/0xae0 = graybuf - 0xaf0 + 0xadc */
|
||||
unsigned char *dev = graybuf - 0xaf0;
|
||||
int w2 = *(int *)(dev + 0xadc);
|
||||
int h2 = *(int *)(dev + 0xae0);
|
||||
printf(" dev w=%d h=%d\n", w2, h2);
|
||||
if (w2 > 0 && w2 < 1000 && h2 > 0 && h2 < 1000) {
|
||||
unsigned char *rgb = malloc((size_t)w2 * h2 * 3);
|
||||
int rc2 = G_RGB(chan, rgb, w2 * h2 * 3, 1);
|
||||
printf(" RGB24 rc=%d\n", rc2);
|
||||
if (rc2) {
|
||||
FILE *f = fopen("official_gray3.bin", "wb");
|
||||
if (f) { fwrite(graybuf, 1, (size_t)w2 * h2, f); fclose(f); }
|
||||
f = fopen("official_rgb3.bin", "wb");
|
||||
if (f) { fwrite(rgb, 1, (size_t)w2 * h2 * 3, f); fclose(f); }
|
||||
printf(" saved gray=%dx%d rgb\n", w2, h2);
|
||||
}
|
||||
free(rgb);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
T_Stop();
|
||||
printf("done\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user