mirror of
https://github.com/eddyem/SBIG_340.git
synced 2025-12-06 02:35:12 +03:00
add darks processing
This commit is contained in:
parent
f08fe7fc31
commit
b7654b2569
@ -57,6 +57,8 @@ glob_pars const Gdefault = {
|
|||||||
.port = "4444",
|
.port = "4444",
|
||||||
.once = 0,
|
.once = 0,
|
||||||
.timestamp = 0,
|
.timestamp = 0,
|
||||||
|
.dark_interval = 1800,
|
||||||
|
.min_dark_exp = 30,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -99,6 +101,8 @@ myoption cmdlnopts[] = {
|
|||||||
{"timestamp",NO_ARGS, NULL, 't', arg_int, APTR(&G.timestamp), _("add timestamp to filename")},
|
{"timestamp",NO_ARGS, NULL, 't', arg_int, APTR(&G.timestamp), _("add timestamp to filename")},
|
||||||
#endif
|
#endif
|
||||||
{"port", NEED_ARG, NULL, 'p', arg_string, APTR(&G.port), _("port to connect (default: 4444)")},
|
{"port", NEED_ARG, NULL, 'p', arg_string, APTR(&G.port), _("port to connect (default: 4444)")},
|
||||||
|
{"dark-interval",NEED_ARG,NULL, 'D', arg_double, APTR(&G.dark_interval),_("time interval (in seconds) between dark images taken (default: 1800)")},
|
||||||
|
{"min-dark-exp",NEED_ARG,NULL, 'E', arg_double, APTR(&G.min_dark_exp),_("minimal exposition (in seconds) at which darks would be taken (default: 30)")},
|
||||||
#endif
|
#endif
|
||||||
end_option
|
end_option
|
||||||
};
|
};
|
||||||
|
|||||||
@ -50,6 +50,8 @@ typedef struct{
|
|||||||
char *imformat; // output file format
|
char *imformat; // output file format
|
||||||
char *hostname; // hostname to connect
|
char *hostname; // hostname to connect
|
||||||
char *port; // port to connect
|
char *port; // port to connect
|
||||||
|
double dark_interval; // time interval (in seconds) between dark images taken
|
||||||
|
double min_dark_exp; // minimal exposition (in seconds) @ which darks would be taken
|
||||||
char** rest_pars; // the rest parameters: array of char*
|
char** rest_pars; // the rest parameters: array of char*
|
||||||
} glob_pars;
|
} glob_pars;
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,8 @@ static int write_jpeg(const char *fname, const uint8_t *data, imstorage *img){
|
|||||||
char date[256];
|
char date[256];
|
||||||
strftime(date, 256, "%d/%m/%y\n%H:%M:%S", localtime(&img->exposetime));
|
strftime(date, 256, "%d/%m/%y\n%H:%M:%S", localtime(&img->exposetime));
|
||||||
gdFTUseFontConfig(1);
|
gdFTUseFontConfig(1);
|
||||||
char *ret = gdImageStringFT(im, NULL, 0xffffff, "monotype", 10, 0., 2, 12, date);
|
char *font = (char*)"monotype";
|
||||||
|
char *ret = gdImageStringFT(im, NULL, 0xffffff, font, 10, 0., 2, 12, date);
|
||||||
if(ret) fprintf(stderr, "Error: %s\n", ret);
|
if(ret) fprintf(stderr, "Error: %s\n", ret);
|
||||||
const char *prefx = "";
|
const char *prefx = "";
|
||||||
double ex = img->exptime;
|
double ex = img->exptime;
|
||||||
@ -66,7 +67,7 @@ static int write_jpeg(const char *fname, const uint8_t *data, imstorage *img){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
snprintf(date, 256, "exp=%.3g %ss", ex, prefx);
|
snprintf(date, 256, "exp=%.3g %ss", ex, prefx);
|
||||||
gdImageStringFT(im, NULL, 0xffffff, "monotype", 10, 0., 2, img->H-4, date);
|
gdImageStringFT(im, NULL, 0xffffff, font, 10, 0., 2, img->H-4, date);
|
||||||
im->tpixels[10][10] = 0XFF0000;
|
im->tpixels[10][10] = 0XFF0000;
|
||||||
im->tpixels[15][15] = 0XFF0000;
|
im->tpixels[15][15] = 0XFF0000;
|
||||||
gdImageJpeg(im, fp, 90);
|
gdImageJpeg(im, fp, 90);
|
||||||
|
|||||||
@ -297,7 +297,7 @@ int writefits(imstorage *img){
|
|||||||
WRITEKEY(TSTRING, "FIELD", "180 degrees", "Camera field of view");
|
WRITEKEY(TSTRING, "FIELD", "180 degrees", "Camera field of view");
|
||||||
switch(img->imtype){
|
switch(img->imtype){
|
||||||
case IMTYPE_AUTODARK:
|
case IMTYPE_AUTODARK:
|
||||||
sprintf(buf, "object without dark");
|
sprintf(buf, "obj.-dark");
|
||||||
break;
|
break;
|
||||||
case IMTYPE_DARK:
|
case IMTYPE_DARK:
|
||||||
sprintf(buf, "dark");
|
sprintf(buf, "dark");
|
||||||
@ -345,7 +345,13 @@ int writefits(imstorage *img){
|
|||||||
snprintf(buf, 80, "(%d, %d)", img->subframe->Xstart, img->subframe->Ystart);
|
snprintf(buf, 80, "(%d, %d)", img->subframe->Xstart, img->subframe->Ystart);
|
||||||
WRITEKEY(TSTRING, "SUBFRAME", buf, "Subframe start coordinates (Xstart, Ystart)");
|
WRITEKEY(TSTRING, "SUBFRAME", buf, "Subframe start coordinates (Xstart, Ystart)");
|
||||||
}
|
}
|
||||||
TRYFITS(fits_write_img, fp, TUSHORT, 1, img->W * img->H, img->imdata);
|
// flip image around OX
|
||||||
|
size_t W = img->W, Wb = sizeof(uint16_t)*W, H = img->H, imsz = img->W * H, y;
|
||||||
|
uint16_t *image = MALLOC(uint16_t, imsz), *optr = image, *iptr = &img->imdata[W*(H-1)];
|
||||||
|
for(y = 0; y < H; ++y, optr += W, iptr -= W)
|
||||||
|
memcpy(optr, iptr, Wb);
|
||||||
|
TRYFITS(fits_write_img, fp, TUSHORT, 1, imsz, image);
|
||||||
|
FREE(image);
|
||||||
TRYFITS(fits_close_file, fp);
|
TRYFITS(fits_close_file, fp);
|
||||||
if(*filename == '!') ++filename; // remove '!' from filename
|
if(*filename == '!') ++filename; // remove '!' from filename
|
||||||
modifytimestamp(filename, img);
|
modifytimestamp(filename, img);
|
||||||
@ -483,6 +489,7 @@ int store_image(imstorage *img){
|
|||||||
if(img->imformat & FORMAT_FITS){ // save FITS
|
if(img->imformat & FORMAT_FITS){ // save FITS
|
||||||
if(writefits(img)) status |= 4;
|
if(writefits(img)) status |= 4;
|
||||||
}
|
}
|
||||||
|
if(img->imtype != IMTYPE_DARK) // store debayer only if image type isn't dark
|
||||||
if(write_debayer(img, glob_min)) status |= 8; // and save colour image
|
if(write_debayer(img, glob_min)) status |= 8; // and save colour image
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
3
main.c
3
main.c
@ -120,6 +120,9 @@ int main(int argc, char **argv){
|
|||||||
img->timestamp = G->timestamp;
|
img->timestamp = G->timestamp;
|
||||||
#endif
|
#endif
|
||||||
#if defined CLIENT || defined DAEMON
|
#if defined CLIENT || defined DAEMON
|
||||||
|
#ifdef DAEMON
|
||||||
|
set_darks(G->min_dark_exp, G->dark_interval);
|
||||||
|
#endif
|
||||||
daemonize(img, G->hostname, G->port);
|
daemonize(img, G->hostname, G->port);
|
||||||
#endif
|
#endif
|
||||||
if(img){
|
if(img){
|
||||||
|
|||||||
18
socket.c
18
socket.c
@ -24,8 +24,6 @@
|
|||||||
#include "usefull_macros.h"
|
#include "usefull_macros.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
//#include <sys/socket.h>
|
|
||||||
//#include <netinet/in.h>
|
|
||||||
#include <netdb.h> // addrinfo
|
#include <netdb.h> // addrinfo
|
||||||
#include <arpa/inet.h> // inet_ntop
|
#include <arpa/inet.h> // inet_ntop
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -106,9 +104,15 @@ static int getdpar(uint8_t *str, char *parameter, double *ret){
|
|||||||
|
|
||||||
/**************** CLIENT/SERVER FUNCTIONS ****************/
|
/**************** CLIENT/SERVER FUNCTIONS ****************/
|
||||||
#ifdef DAEMON
|
#ifdef DAEMON
|
||||||
|
static double min_dark_exp, dark_interval;
|
||||||
static imstorage *storedima = NULL;
|
static imstorage *storedima = NULL;
|
||||||
static uint64_t imctr = 0; // image counter
|
static uint64_t imctr = 0; // image counter
|
||||||
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
// setter for min_dark_exp, dark_interval
|
||||||
|
void set_darks(double exp, double dt){
|
||||||
|
min_dark_exp = exp;
|
||||||
|
dark_interval = dt;
|
||||||
|
}
|
||||||
static void clearimstorage(){
|
static void clearimstorage(){
|
||||||
if(!storedima) return;
|
if(!storedima) return;
|
||||||
FREE(storedima->imname);
|
FREE(storedima->imname);
|
||||||
@ -296,6 +300,7 @@ static void daemon_(imstorage *img, int sock){
|
|||||||
FNAME();
|
FNAME();
|
||||||
if(sock < 0) return;
|
if(sock < 0) return;
|
||||||
pthread_t sock_thread;
|
pthread_t sock_thread;
|
||||||
|
static double lastDT = 0.; // last time dark was taken
|
||||||
if(pthread_create(&sock_thread, NULL, server, (void*) &sock))
|
if(pthread_create(&sock_thread, NULL, server, (void*) &sock))
|
||||||
ERR("pthread_create()");
|
ERR("pthread_create()");
|
||||||
int errcntr = 0;
|
int errcntr = 0;
|
||||||
@ -307,6 +312,15 @@ static void daemon_(imstorage *img, int sock){
|
|||||||
ERR("pthread_create()");
|
ERR("pthread_create()");
|
||||||
}
|
}
|
||||||
if(exp_calculated > 0.) img->exptime = exp_calculated;
|
if(exp_calculated > 0.) img->exptime = exp_calculated;
|
||||||
|
if(img->imtype != IMTYPE_AUTODARK){ // check for darks
|
||||||
|
if(img->imtype == IMTYPE_DARK) img->imtype = IMTYPE_LIGHT; // last was dark
|
||||||
|
else if(img->exptime > min_dark_exp){ // need to store dark frame?
|
||||||
|
if(dtime() - lastDT > dark_interval){
|
||||||
|
lastDT = dtime();
|
||||||
|
img->imtype = IMTYPE_DARK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if(start_exposition(img, NULL)){
|
if(start_exposition(img, NULL)){
|
||||||
WARNX(_("Error starting exposition, try later"));
|
WARNX(_("Error starting exposition, try later"));
|
||||||
++errcntr;
|
++errcntr;
|
||||||
|
|||||||
3
socket.h
3
socket.h
@ -27,5 +27,8 @@
|
|||||||
#include "imfunctions.h"
|
#include "imfunctions.h"
|
||||||
|
|
||||||
void daemonize(imstorage *img, char *hostname, char *port);
|
void daemonize(imstorage *img, char *hostname, char *port);
|
||||||
|
#ifdef DAEMON
|
||||||
|
void set_darks(double exp, double dt);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // __SOCKET_H__
|
#endif // __SOCKET_H__
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user