code cleanup, reduce global and shared data structures

This commit is contained in:
Nicole Faerber 2021-02-07 20:15:54 +01:00
parent c653d72cf4
commit 5cfad502f7
4 changed files with 180 additions and 130 deletions

View file

@ -22,10 +22,6 @@
// from main thread
void update_fb(void);
//extern unsigned char *fbdata;
extern gboolean flir_run;
extern unsigned char *color_palette;
#include <unistd.h>
@ -53,31 +49,18 @@ extern unsigned char *color_palette;
#define PRODUCT_ID 0x1996
static struct libusb_device_handle *devh = NULL;
//int filecount=0;
struct timeval t1, t2;
long long fps_t;
double t_min = 0.0;
double t_max = 0.0;
double t_center = 0.0;
int FFC = 0; // detect FFC
static int FFC = 0; // detect FFC
// -- buffer for EP 0x85 chunks ---------------
#define BUF85SIZE 1048576 // size got from android app
int buf85pointer = 0;
unsigned char buf85[BUF85SIZE];
extern unsigned char *jpeg_buffer;
extern unsigned int jpeg_size;
extern unsigned char *ir_buffer;
extern double emissivity;
extern double tempreflected;
static int buf85pointer = 0;
static unsigned char buf85[BUF85SIZE];
static unsigned char fb_proc[160*120]; //, fb_proc2[160*120*3];
struct shutter_state_t shutter_state;
struct battery_state_t battery_state;
static struct t_data_t *tdata;
// EP81 device status message (JSON)
// {
@ -115,33 +98,33 @@ parse_status(unsigned char *buf)
res = cJSON_GetObjectItemCaseSensitive(status_json, "shutterState");
if (cJSON_IsString(res) && (res->valuestring != NULL)) {
if (strncmp(res->valuestring,"FFC",3)==0) {
shutter_state.shutterState=sFFC;
tdata->shutter_state.shutterState=sFFC;
} else if (strncmp(res->valuestring,"ON",2)==0) {
shutter_state.shutterState=sON;
tdata->shutter_state.shutterState=sON;
} else {
shutter_state.shutterState=sUNKNOWN;
tdata->shutter_state.shutterState=sUNKNOWN;
}
}
res = cJSON_GetObjectItemCaseSensitive(status_json, "shutterTemperature");
if (cJSON_IsNumber(res)) {
shutter_state.shutterTemperature=res->valuedouble;
tdata->shutter_state.shutterTemperature=res->valuedouble;
}
res = cJSON_GetObjectItemCaseSensitive(status_json, "usbNotifiedTimestamp");
if (cJSON_IsNumber(res)) {
shutter_state.usbNotifiedTimestamp=res->valuedouble;
tdata->shutter_state.usbNotifiedTimestamp=res->valuedouble;
}
res = cJSON_GetObjectItemCaseSensitive(status_json, "usbEnqueuedTimestamp");
if (cJSON_IsNumber(res)) {
shutter_state.usbEnqueuedTimestamp=res->valuedouble;
tdata->shutter_state.usbEnqueuedTimestamp=res->valuedouble;
}
res = cJSON_GetObjectItemCaseSensitive(status_json, "ffcState");
if (cJSON_IsString(res) && (res->valuestring != NULL)) {
if (strncmp(res->valuestring,"FFC_VALID_RAD",13)==0) {
shutter_state.ffcState=FFC_VALID_RAD;
tdata->shutter_state.ffcState=FFC_VALID_RAD;
} else if (strncmp(res->valuestring,"FFC_PROGRESS",12)==0) {
shutter_state.ffcState=FFC_PROGRESS;
tdata->shutter_state.ffcState=FFC_PROGRESS;
} else {
shutter_state.ffcState=FFC_UNKNOWN;
tdata->shutter_state.ffcState=FFC_UNKNOWN;
}
}
@ -168,19 +151,19 @@ parse_config_in(unsigned char *buf)
if (strncmp(res->valuestring,"batteryVoltageUpdate",20)==0) {
res3 = cJSON_GetObjectItemCaseSensitive(res2, "voltage");
if (cJSON_IsNumber(res3)) {
battery_state.voltage = res3->valuedouble;
tdata->battery_state.voltage = res3->valuedouble;
// printf("bat %.2fV\n", res3->valuedouble);
}
res3 = cJSON_GetObjectItemCaseSensitive(res2, "percentage");
if (cJSON_IsNumber(res3)) {
battery_state.percentage = res3->valueint;
tdata->battery_state.percentage = res3->valueint;
// printf("bat %f%%\n", res3->valuedouble);
}
}
if (strncmp(res->valuestring,"batteryChargingCurrentUpdate",28)==0) {
res3 = cJSON_GetObjectItemCaseSensitive(res2, "chargingCurrent");
if (cJSON_IsNumber(res3)) {
battery_state.chargingCurrent = res3->valuedouble;
tdata->battery_state.chargingCurrent = res3->valuedouble;
// printf("bat %.2fV\n", res3->valuedouble);
}
}
@ -202,9 +185,9 @@ raw2temperature(unsigned short RAW)
// mystery correction factor
RAW *=4;
// calc amount of radiance of reflected objects ( Emissivity < 1 )
double RAWrefl=PlanckR1/(PlanckR2*(exp(PlanckB/(tempreflected/*TempReflected*/+273.15))-PlanckF))-PlanckO;
double RAWrefl=PlanckR1/(PlanckR2*(exp(PlanckB/(tdata->tempreflected/*TempReflected*/+273.15))-PlanckF))-PlanckO;
// get displayed object temp max/min
double RAWobj=(RAW-(1-emissivity/*Emissivity*/)*RAWrefl)/emissivity/*Emissivity*/;
double RAWobj=(RAW-(1-tdata->emissivity/*Emissivity*/)*RAWrefl)/tdata->emissivity/*Emissivity*/;
// calc object temperature
return PlanckB/log(PlanckR1/(PlanckR2*(RAWobj+PlanckO))+PlanckF)-273.15;
@ -261,20 +244,17 @@ void vframe(char ep[],char EP_error[], int r, int actual_length, unsigned char b
parse_status(&buf85[28+ThermalSize+JpgSize]);
}
int i,v;
int v;
// get a full frame, first print the status
t1=t2;
gettimeofday(&t2, NULL);
buf85pointer=0;
unsigned short pix[160*120]; // original Flir 16 Bit RAW
unsigned short *pix=tdata->raw_ir_buffer; // original Flir 16 Bit RAW
int x, y;
unsigned char *fb_proc,*fb_proc2;
fb_proc = malloc(160 * 128); // 8 Bit gray buffer really needs only 160 x 120
memset(fb_proc, 128, 160*128); // sizeof(fb_proc) doesn't work, value depends from LUT
// fb_proc = malloc(160 * 128); // 8 Bit gray buffer really needs only 160 x 120
memset(fb_proc, 128, 160*120); // sizeof(fb_proc) doesn't work, value depends from LUT
fb_proc2 = malloc(160 * 128 * 3); // 8x8x8 Bit RGB buffer
//fb_proc2 = malloc(160 * 128 * 3); // 8x8x8 Bit RGB buffer
int min = 0x10000, max = 0;
float rms = 0;
@ -321,33 +301,33 @@ void vframe(char ep[],char EP_error[], int r, int actual_length, unsigned char b
// calc medium of 2x2 center pixels
int med = (pix[59 * 160 + 79]+pix[59 * 160 + 80]+pix[60 * 160 + 79]+pix[60 * 160 + 80])/4;
t_min = raw2temperature(min);
t_max = raw2temperature(max);
t_center = raw2temperature(med);
tdata->t_min = raw2temperature(min);
tdata->t_max = raw2temperature(max);
tdata->t_center = raw2temperature(med);
if (ir_buffer == NULL) {
ir_buffer = (unsigned char *)malloc(640*480*4);
if (tdata->ir_buffer == NULL) {
tdata->ir_buffer = (unsigned char *)malloc(640*480*4);
fprintf(stderr, "nb\n");
}
for (y = 0; y < 120; ++y) {
for (x = 0; x < 160; ++x) {
// fb_proc is the gray scale frame buffer
v=fb_proc[y * 160 + x] ; // unsigned char!!
ir_buffer[4*y * 160 + x*4] =
color_palette[3 * v + 2]; // B
ir_buffer[(4*y * 160 + x*4)+1] =
color_palette[3 * v + 1]; // G
ir_buffer[(4*y * 160 + x*4)+2] =
color_palette[3 * v]; // R
tdata->ir_buffer[4*y * 160 + x*4] =
tdata->color_palette[3 * v + 2]; // B
tdata->ir_buffer[(4*y * 160 + x*4)+1] =
tdata->color_palette[3 * v + 1]; // G
tdata->ir_buffer[(4*y * 160 + x*4)+2] =
tdata->color_palette[3 * v]; // R
// ir_buffer[(4*y * 160 + x*4)+3] =
// 0x00; // A, empty
}
}
if (jpeg_size == 0 && JpgSize > 0) {
jpeg_size=JpgSize;
jpeg_buffer=(unsigned char *)malloc(jpeg_size);
memcpy(jpeg_buffer, &buf85[28+ThermalSize], jpeg_size);
if (tdata->jpeg_size == 0 && JpgSize > 0) {
tdata->jpeg_size=JpgSize;
tdata->jpeg_buffer=(unsigned char *)malloc(tdata->jpeg_size);
memcpy(tdata->jpeg_buffer, &buf85[28+ThermalSize], tdata->jpeg_size);
}
if (strncmp ((char *)&buf85[28+ThermalSize+JpgSize+17],"FFC",3)==0) {
@ -361,8 +341,8 @@ void vframe(char ep[],char EP_error[], int r, int actual_length, unsigned char b
}
}
// free memory
free(fb_proc); // thermal RAW
free(fb_proc2); // visible jpg
//free(fb_proc); // thermal RAW
//free(fb_proc2); // visible jpg
}
static int
@ -476,7 +456,7 @@ int r = 1;
int state = 1;
// int ct=0;
while (flir_run) {
while (tdata->flir_run) {
switch(state) {
case 1:
/* Flir config
@ -615,7 +595,6 @@ int r = 1;
// poll Endpoints 0x81, 0x83
r = libusb_bulk_transfer(devh, 0x81, buf, sizeof(buf), &actual_length, 10);
if (actual_length > 16) {
int i;
unsigned int magic, second, len;
magic=*(unsigned int *)&buf[0];
@ -627,6 +606,7 @@ int r = 1;
parse_config_in(&buf[16]);
}
#if 0
int i;
for (i=0; i<actual_length; i++) {
if (buf[i] > 31 && buf[i]<128)
fprintf(stderr, "%c", buf[i]);
@ -702,6 +682,7 @@ int r = 1;
gpointer cam_thread_main(gpointer user_data)
{
tdata=(struct t_data_t *)user_data;
EPloop(NULL);
return NULL;

View file

@ -28,4 +28,19 @@ struct battery_state_t {
double chargingCurrent;
};
struct t_data_t {
unsigned short *raw_ir_buffer;
unsigned char *jpeg_buffer;
unsigned int jpeg_size;
unsigned char *ir_buffer;
double emissivity;
double tempreflected;
double t_min, t_max, t_center;
struct shutter_state_t shutter_state;
struct battery_state_t battery_state;
gboolean flir_run;
unsigned char *color_palette;
};
#endif

184
flirgtk.c
View file

@ -51,13 +51,13 @@ static cairo_surface_t *psurface;
static gboolean take_vis_shot=FALSE;
// settings
int colorpalette=9;
double emissivity=0.9;
double tempreflected=20.0;
static int colorpalette=9;
static gboolean show_battery=TRUE;
static gboolean show_palette=TRUE;
static gboolean show_crosshair=TRUE;
static gboolean shot_store_visual=FALSE;
static gboolean shot_store_ir_raw=FALSE;
static double vis_surface_alpha=0.3;
static double vis_surface_scaling=(1./2.25);
@ -69,24 +69,18 @@ static double vis_y_offset=0.;
gboolean pending=FALSE;
gboolean ircam=TRUE;
gboolean viscam=FALSE;
gboolean flir_run = FALSE;
unsigned char *color_palette;
//gboolean flir_run = FALSE;
//unsigned char *color_palette;
gpointer cam_thread_main(gpointer user_data);
extern double t_min, t_max, t_center;
extern struct shutter_state_t shutter_state;
extern struct battery_state_t battery_state;
// data structure shared with camera thread
static struct t_data_t tdata;
unsigned char *ir_buffer=NULL;
unsigned char *jpeg_buffer=NULL;
unsigned int jpeg_size=0;
gboolean
configure_event (GtkWidget *widget,
GdkEventConfigure *event,
gpointer data)
configure_event (GtkWidget *widget, GdkEventConfigure *event, gpointer data)
{
//GtkAllocation allocation;
@ -119,9 +113,9 @@ char tdisp[16];
memset(fbdata,0,(640*20*4));
y=P_YPOS;
for (x=0; x<256; x++) {
fbdata[4* y * 640 + ((x+P_XPOS)*4)] = color_palette[3 * x + 2]; // B
fbdata[(4* y * 640 + ((x+P_XPOS)*4))+1] = color_palette[3 * x + 1]; // G
fbdata[(4* y * 640 + ((x+P_XPOS)*4))+2] = color_palette[3 * x]; // R
fbdata[4* y * 640 + ((x+P_XPOS)*4)] = tdata.color_palette[3 * x + 2]; // B
fbdata[(4* y * 640 + ((x+P_XPOS)*4))+1] = tdata.color_palette[3 * x + 1]; // G
fbdata[(4* y * 640 + ((x+P_XPOS)*4))+2] = tdata.color_palette[3 * x]; // R
}
y=P_YPOS;
p1 = (unsigned int *)&fbdata[4 * y * 640 + (P_XPOS*4)]; // pointer to start of line
@ -131,7 +125,7 @@ char tdisp[16];
}
// update palette scale temperature range
snprintf(tdisp, 16, "%.1f°C", t_min);
snprintf(tdisp, 16, "%.1f°C", tdata.t_min);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_select_font_face (cr, "Sans",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
@ -139,7 +133,7 @@ char tdisp[16];
cairo_move_to (cr, 102, 16);
cairo_show_text (cr, tdisp);
snprintf(tdisp, 16, "%.1f°C", t_max);
snprintf(tdisp, 16, "%.1f°C", tdata.t_max);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_select_font_face (cr, "Sans",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
@ -183,6 +177,40 @@ int fd;
}
void
store_raw_ir_shot(void)
{
time_t now;
struct tm *loctime;
char pname[PATH_MAX];
const char *tmp;
char fname[30];
int fd;
if (tdata.raw_ir_buffer == NULL) {
g_printerr("raw IR buffer == NULL\n");
return;
}
now = time(NULL);
loctime = localtime (&now);
strftime (fname, 30, "ir-%y%m%d%H%M%S", loctime);
tmp=g_get_user_special_dir(G_USER_DIRECTORY_PICTURES);
if (tmp == NULL)
tmp = "./";
strncpy(pname, tmp, PATH_MAX-30-4); // leave room for filename+extension
strncat(pname, "/", PATH_MAX-5); // -5 to leave space for trailing \0 byte + extension
strncat(pname, fname, PATH_MAX-5); // -5 to leave space for trailing \0 byte + extension
strncat(pname, ".raw", PATH_MAX-1); // -5 to leave space for trailing \0 byte + extension
fd=open(pname, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd>=0) {
write (fd, (unsigned char *)tdata.raw_ir_buffer, 160*120*2);
close(fd);
}
}
static gboolean
draw_event (GtkWidget *widget,
cairo_t *wcr,
@ -200,8 +228,8 @@ cairo_t *cr;
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
// first draw the frame buffer containing the IR frame
if (ircam && ir_buffer!=NULL) {
ir_surface=cairo_image_surface_create_for_data (ir_buffer,
if (ircam && tdata.ir_buffer!=NULL) {
ir_surface=cairo_image_surface_create_for_data (tdata.ir_buffer,
CAIRO_FORMAT_RGB24,
160,
120,
@ -214,13 +242,13 @@ cairo_t *cr;
cairo_surface_destroy (ir_surface);
}
if (jpeg_size != 0 && jpeg_buffer != NULL) {
if (tdata.jpeg_size != 0 && tdata.jpeg_buffer != NULL) {
if (take_vis_shot) {
take_vis_shot=FALSE;
store_vis_shot(jpeg_buffer, jpeg_size);
store_vis_shot(tdata.jpeg_buffer, tdata.jpeg_size);
}
if (viscam) {
jpeg_surface=cairo_image_surface_create_from_jpeg_mem(jpeg_buffer, jpeg_size);
jpeg_surface=cairo_image_surface_create_from_jpeg_mem(tdata.jpeg_buffer, tdata.jpeg_size);
cairo_save(cr);
cairo_scale (cr, vis_surface_scaling, vis_surface_scaling);
cairo_set_source_surface (cr, jpeg_surface, vis_x_offset, vis_y_offset);
@ -231,8 +259,8 @@ cairo_t *cr;
cairo_restore(cr);
cairo_surface_destroy (jpeg_surface);
}
jpeg_size=0;
jpeg_buffer=NULL;
tdata.jpeg_size=0;
tdata.jpeg_buffer=NULL;
}
// then draw decoration on top
@ -267,7 +295,7 @@ cairo_t *cr;
cairo_stroke (cr);
// print center temperature near crosshair
snprintf(tdisp, 16, "%.1f°C", t_center);
snprintf(tdisp, 16, "%.1f°C", tdata.t_center);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_select_font_face (cr, "Sans",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
@ -278,7 +306,7 @@ cairo_t *cr;
// print battery % top right
if (show_battery) {
snprintf(tdisp, 16, "%d%%", battery_state.percentage);
snprintf(tdisp, 16, "%d%%", tdata.battery_state.percentage);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_select_font_face (cr, "Sans",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
@ -328,21 +356,25 @@ const char *tmp;
strncat(pname, "/", PATH_MAX-5); // -5 to leave space for trailing \0 byte + extension
strncat(pname, fname, PATH_MAX-5); // -5 to leave space for trailing \0 byte + extension
strncat(pname, ".png", PATH_MAX-1); // -1 to leave space for trailing \0 byte
cairo_surface_write_to_png (psurface, pname);
take_vis_shot=TRUE;
if (shot_store_ir_raw)
store_raw_ir_shot();
if (shot_store_visual)
take_vis_shot=TRUE;
}
void
start_clicked(GtkWidget *button, gpointer user_data)
{
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(play_button))) {
flir_run = TRUE;
memset(&shutter_state, 0, sizeof(shutter_state));
memset(&battery_state, 0, sizeof(battery_state));
if (ir_buffer == NULL)
tdata.flir_run = TRUE;
memset(&tdata.shutter_state, 0, sizeof(tdata.shutter_state));
memset(&tdata.battery_state, 0, sizeof(tdata.battery_state));
if (tdata.ir_buffer == NULL)
g_printerr("ir_buffer\n");
g_thread_new ("CAM thread", cam_thread_main, NULL);
g_thread_new ("CAM thread", cam_thread_main, &tdata);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(stop_button), FALSE);
}
}
@ -351,7 +383,7 @@ void
stop_clicked(GtkWidget *button, gpointer user_data)
{
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stop_button))) {
flir_run = FALSE;
tdata.flir_run = FALSE;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(play_button), FALSE);
}
}
@ -378,8 +410,6 @@ static void
close_window (void)
{
// clean up and quit
//window = NULL;
// gtk_main_quit();
// g_application_quit(gapp);
gtk_application_remove_window(gapp, GTK_WINDOW(window));
}
@ -393,16 +423,16 @@ int act;
if (act < 0) {
g_printerr("oops, palette selection = %d\n", act);
} else {
if (act == 0) color_palette = palette_7;
if (act == 1) color_palette = palette_15;
if (act == 2) color_palette = palette_17;
if (act == 3) color_palette = palette_85;
if (act == 4) color_palette = palette_92;
if (act == 5) color_palette = palette_Grayscale;
if (act == 6) color_palette = palette_Grey;
if (act == 7) color_palette = palette_Iron2;
if (act == 8) color_palette = palette_Iron_Black;
if (act == 9) color_palette = palette_Rainbow;
if (act == 0) tdata.color_palette = palette_7;
if (act == 1) tdata.color_palette = palette_15;
if (act == 2) tdata.color_palette = palette_17;
if (act == 3) tdata.color_palette = palette_85;
if (act == 4) tdata.color_palette = palette_92;
if (act == 5) tdata.color_palette = palette_Grayscale;
if (act == 6) tdata.color_palette = palette_Grey;
if (act == 7) tdata.color_palette = palette_Iron2;
if (act == 8) tdata.color_palette = palette_Iron_Black;
if (act == 9) tdata.color_palette = palette_Rainbow;
colorpalette=act;
};
}
@ -410,13 +440,13 @@ int act;
void
emissivity_changed (GtkRange *range, gpointer user_data)
{
emissivity=gtk_range_get_value (range);
tdata.emissivity=gtk_range_get_value (range);
}
void
tempreflected_changed (GtkSpinButton *spin_button, gpointer user_data)
{
tempreflected=gtk_spin_button_get_value (spin_button);
tdata.tempreflected=gtk_spin_button_get_value (spin_button);
}
void
@ -472,7 +502,7 @@ GtkDialogFlags flags = GTK_DIALOG_USE_HEADER_BAR /*| GTK_DIALOG_MODAL*/ | GTK_DI
gtk_scale_add_mark (GTK_SCALE(w), 0.60, GTK_POS_BOTTOM, "half shiny");
gtk_scale_add_mark (GTK_SCALE(w), 0.80, GTK_POS_TOP, "half matte");
gtk_scale_add_mark (GTK_SCALE(w), 0.90, GTK_POS_BOTTOM, "matte");
gtk_range_set_value(GTK_RANGE(w), emissivity);
gtk_range_set_value(GTK_RANGE(w), tdata.emissivity);
gtk_container_add (GTK_CONTAINER (vb), w);
g_signal_connect (w, "value-changed",
G_CALLBACK (emissivity_changed), NULL);
@ -481,7 +511,7 @@ GtkDialogFlags flags = GTK_DIALOG_USE_HEADER_BAR /*| GTK_DIALOG_MODAL*/ | GTK_DI
gtk_container_add (GTK_CONTAINER (vb), w);
w=gtk_spin_button_new_with_range(-100.0, +100.0, 0.5);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), tempreflected);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), tdata.tempreflected);
gtk_container_add (GTK_CONTAINER (vb), w);
g_signal_connect (w, "value-changed",
G_CALLBACK (tempreflected_changed), NULL);
@ -510,6 +540,18 @@ show_crosshair_toggled (GtkToggleButton *togglebutton, gpointer user_data)
show_crosshair=gtk_toggle_button_get_active(togglebutton);
}
void
shot_visual_toggled (GtkToggleButton *togglebutton, gpointer user_data)
{
shot_store_visual=gtk_toggle_button_get_active(togglebutton);
}
void
shot_ir_raw_toggled (GtkToggleButton *togglebutton, gpointer user_data)
{
shot_store_ir_raw=gtk_toggle_button_get_active(togglebutton);
}
void
ui_settings_activate (GSimpleAction *simple,
GVariant *parameter,
@ -550,6 +592,18 @@ GtkDialogFlags flags = GTK_DIALOG_USE_HEADER_BAR /*| GTK_DIALOG_MODAL*/ | GTK_DI
g_signal_connect (w, "toggled",
G_CALLBACK (show_palette_toggled), NULL);
w=gtk_check_button_new_with_label ("Shot store visual image");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), shot_store_visual);
gtk_container_add (GTK_CONTAINER (vb), w);
g_signal_connect (w, "toggled",
G_CALLBACK (shot_visual_toggled), NULL);
w=gtk_check_button_new_with_label ("Shot store raw IR image");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), shot_store_ir_raw);
gtk_container_add (GTK_CONTAINER (vb), w);
g_signal_connect (w, "toggled",
G_CALLBACK (shot_ir_raw_toggled), NULL);
gtk_widget_show_all(c);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
@ -630,7 +684,7 @@ GtkDialogFlags flags = GTK_DIALOG_USE_HEADER_BAR /*| GTK_DIALOG_MODAL*/ | GTK_DI
w=gtk_label_new("X Offset");
gtk_container_add (GTK_CONTAINER (vb), w);
w=gtk_spin_button_new_with_range(-100.0, +100.0, 1.);
w=gtk_spin_button_new_with_range(-200.0, +200.0, 1.);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), vis_x_offset);
gtk_container_add (GTK_CONTAINER (vb), w);
g_signal_connect (w, "value-changed",
@ -639,7 +693,7 @@ GtkDialogFlags flags = GTK_DIALOG_USE_HEADER_BAR /*| GTK_DIALOG_MODAL*/ | GTK_DI
w=gtk_label_new("Y Offset");
gtk_container_add (GTK_CONTAINER (vb), w);
w=gtk_spin_button_new_with_range(-100.0, +100.0, 1.);
w=gtk_spin_button_new_with_range(-200.0, +200.0, 1.);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), vis_y_offset);
gtk_container_add (GTK_CONTAINER (vb), w);
g_signal_connect (w, "value-changed",
@ -654,10 +708,7 @@ GtkDialogFlags flags = GTK_DIALOG_USE_HEADER_BAR /*| GTK_DIALOG_MODAL*/ | GTK_DI
void
quit_activate
(GSimpleAction *simple,
GVariant *parameter,
gpointer user_data)
quit_activate (GSimpleAction *simple, GVariant *parameter, gpointer user_data)
{
close_window ();
}
@ -680,7 +731,7 @@ const GActionEntry entries[] = {
};
// init default color palette
color_palette = palette_Rainbow;
tdata.color_palette = palette_Rainbow;
// gappw=gtk_application_window_new(gapp);
// window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@ -787,17 +838,20 @@ GtkWidget *widget;
int
main (int argc, char **argv)
{
tdata.ir_buffer = (unsigned char *)malloc(640*480*4);
tdata.raw_ir_buffer = (unsigned short *)malloc(169*120*2);
tdata.emissivity=0.9;
tdata.tempreflected=20.0;
tdata.t_min=0.0;
tdata.t_max=0.0;
tdata.t_center=0.0;
tdata.flir_run=FALSE;
gapp=gtk_application_new("org.gnome.flirgtk", G_APPLICATION_FLAGS_NONE);
// gtk_init(&argc, &argv);
//create_main_window();
g_signal_connect(gapp, "activate", G_CALLBACK (flirgtk_app_activate), NULL);
g_application_run (G_APPLICATION (gapp), argc, argv);
g_object_unref (gapp);
// gtk_main();
return 0;
}

View file

@ -19,7 +19,7 @@
#define PlanckR2 0.0125
// Reflected Apparent Temperature [°C]
#define TempReflected 20.0
#define TempReflected 22.0
// 0.01 to 0.99 on the emissivity scale.
// Highly polished metallic surfaces such as copper or aluminum usually have an emissivity below 0.10.