summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <mutlaqja@ikarustech.com>2016-09-06 10:54:45 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-09-06 10:54:45 (GMT)
commit4e290affbce9378a055180cd9b062ab63a2361dd (patch)
tree6d658c67483ba8b9be955dcf27b3c2ec257f4b16
parent38e52bb4d5e57c7d438537931d6052cceaab2029 (diff)
More progress on dark frame library
-rw-r--r--kstars/ekos/capture.cpp16
-rw-r--r--kstars/ekos/capture.h3
-rw-r--r--kstars/ekos/darklibrary.cpp9
-rw-r--r--kstars/ekos/darklibrary.h5
-rw-r--r--kstars/ekos/focus.cpp141
-rw-r--r--kstars/ekos/focus.h16
-rw-r--r--kstars/ekos/guide.cpp119
-rw-r--r--kstars/ekos/guide.h10
-rw-r--r--kstars/ekos/sequencejob.h7
9 files changed, 125 insertions, 201 deletions
diff --git a/kstars/ekos/capture.cpp b/kstars/ekos/capture.cpp
index 1f6295d..df6e47e 100644
--- a/kstars/ekos/capture.cpp
+++ b/kstars/ekos/capture.cpp
@@ -851,16 +851,18 @@ void Capture::newFITS(IBLOB *bp)
{
FITSView *currentImage = targetChip->getImage(FITS_NORMAL);
FITSData *darkData = NULL;
+ uint16_t offsetX = activeJob->getSubX() / activeJob->getXBin();
+ uint16_t offsetY = activeJob->getSubY() / activeJob->getYBin();
darkData = DarkLibrary::Instance()->getDarkFrame(targetChip, activeJob->getExposure());
- connect(DarkLibrary::Instance(), SIGNAL(darkFrameCompleted(bool)), this, SLOT(setDarkCaptureComplete(bool)));
+ connect(DarkLibrary::Instance(), SIGNAL(darkFrameCompleted(bool)), this, SLOT(setCaptureComplete()));
connect(DarkLibrary::Instance(), SIGNAL(newLog(QString)), this, SLOT(appendLogText(QString)));
if (darkData)
- DarkLibrary::Instance()->subtract(darkData, currentImage, activeJob->getSubX(), activeJob->getSubY());
+ DarkLibrary::Instance()->subtract(darkData, currentImage, activeJob->getCaptureFilter(), offsetX, offsetY);
else
- DarkLibrary::Instance()->captureAndSubtract(targetChip, activeJob->getExposure(), activeJob->getSubX(), activeJob->getSubY(), currentImage);
+ DarkLibrary::Instance()->captureAndSubtract(targetChip, currentImage, activeJob->getExposure(), offsetX, offsetY);
return;
}
@@ -870,14 +872,6 @@ void Capture::newFITS(IBLOB *bp)
}
-void Capture::setDarkCaptureComplete(bool result)
-{
- if (result == false)
- appendLogText(i18n("Dark frame processing failed."));
-
- setCaptureComplete();
-}
-
void Capture::setCaptureComplete()
{
disconnect(currentCCD, SIGNAL(newExposureValue(ISD::CCDChip*,double,IPState)), this, SLOT(updateCaptureProgress(ISD::CCDChip*,double,IPState)));
diff --git a/kstars/ekos/capture.h b/kstars/ekos/capture.h
index 7b6cd68..7b52a7f 100644
--- a/kstars/ekos/capture.h
+++ b/kstars/ekos/capture.h
@@ -425,8 +425,7 @@ private slots:
// Send image info
void sendNewImage(QImage *image, ISD::CCDChip *myChip);
- // Capture
- void setDarkCaptureComplete(bool result);
+ // Capture
void setCaptureComplete();
// Temporary for post capture script
diff --git a/kstars/ekos/darklibrary.cpp b/kstars/ekos/darklibrary.cpp
index 4b9dd8f..d20c3dc 100644
--- a/kstars/ekos/darklibrary.cpp
+++ b/kstars/ekos/darklibrary.cpp
@@ -159,7 +159,7 @@ bool DarkLibrary::saveDarkFile(FITSData *darkData)
return true;
}
-bool DarkLibrary::subtract(FITSData *darkData, FITSView *lightImage, uint16_t offsetX, uint16_t offsetY)
+bool DarkLibrary::subtract(FITSData *darkData, FITSView *lightImage, FITSScale filter, uint16_t offsetX, uint16_t offsetY)
{
Q_ASSERT(darkData);
Q_ASSERT(lightImage);
@@ -189,6 +189,7 @@ bool DarkLibrary::subtract(FITSData *darkData, FITSView *lightImage, uint16_t of
darkoffset += darkW;
}
+ lightData->applyFilter(filter);
lightImage->rescale(ZOOM_KEEP_LEVEL);
lightImage->updateFrame();
@@ -197,17 +198,17 @@ bool DarkLibrary::subtract(FITSData *darkData, FITSView *lightImage, uint16_t of
return true;
}
-void DarkLibrary::captureAndSubtract(ISD::CCDChip *targetChip, double duration, uint16_t offsetX, uint16_t offsetY, FITSView*targetImage)
+void DarkLibrary::captureAndSubtract(ISD::CCDChip *targetChip, FITSView*targetImage, double duration, uint16_t offsetX, uint16_t offsetY)
{
targetChip->resetFrame();
targetChip->setCaptureMode(FITS_CALIBRATE);
targetChip->setFrameType(FRAME_DARK);
subtractParams.targetChip = targetChip;
+ subtractParams.targetImage= targetImage;
subtractParams.duration = duration;
subtractParams.offsetX = offsetX;
subtractParams.offsetY = offsetY;
- subtractParams.targetImage= targetImage;
connect(targetChip->getCCD(), SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
@@ -234,7 +235,7 @@ void DarkLibrary::newFITS(IBLOB *bp)
if (calibrationData->loadFITS(calibrationView->getImageData()->getFilename()))
{
saveDarkFile(calibrationData);
- subtract(calibrationData, subtractParams.targetImage, subtractParams.offsetX, subtractParams.offsetY);
+ subtract(calibrationData, subtractParams.targetImage, subtractParams.targetChip->getCaptureFilter(), subtractParams.offsetX, subtractParams.offsetY);
}
else
{
diff --git a/kstars/ekos/darklibrary.h b/kstars/ekos/darklibrary.h
index 4409579..67a4692 100644
--- a/kstars/ekos/darklibrary.h
+++ b/kstars/ekos/darklibrary.h
@@ -33,8 +33,8 @@ public:
static DarkLibrary *Instance();
FITSData * getDarkFrame(ISD::CCDChip *targetChip, double duration);
- bool subtract(FITSData *darkData, FITSView *lightImage, uint16_t offsetX, uint16_t offsetY);
- void captureAndSubtract(ISD::CCDChip *targetChip, double duration, uint16_t offsetX, uint16_t offsetY, FITSView*targetImage);
+ bool subtract(FITSData *darkData, FITSView *lightImage, FITSScale filter, uint16_t offsetX, uint16_t offsetY);
+ void captureAndSubtract(ISD::CCDChip *targetChip, FITSView*targetImage, double duration, uint16_t offsetX, uint16_t offsetY);
signals:
void darkFrameCompleted(bool);
@@ -65,6 +65,7 @@ private:
uint16_t offsetX;
uint16_t offsetY;
FITSView *targetImage;
+ FITSScale filter;
} subtractParams;
diff --git a/kstars/ekos/focus.cpp b/kstars/ekos/focus.cpp
index 9e59765..99d61ed 100644
--- a/kstars/ekos/focus.cpp
+++ b/kstars/ekos/focus.cpp
@@ -29,6 +29,7 @@
#include "fitsviewer/fitstab.h"
#include "fitsviewer/fitsview.h"
#include "ekosmanager.h"
+#include "darklibrary.h"
#include "kstars.h"
#include "focusadaptor.h"
@@ -56,8 +57,7 @@ Focus::Focus()
currentCCD = NULL;
currentFilter = NULL;
filterName = NULL;
- filterSlot = NULL;
- darkBuffer = NULL;
+ filterSlot = NULL;
canAbsMove = false;
canRelMove = false;
@@ -70,10 +70,7 @@ Focus::Focus()
subFramed = false;
resetFocus = false;
m_autoFocusSuccesful = false;
- filterPositionPending= false;
- haveDarkFrame = false;
-
- calibrationState = CALIBRATE_NONE;
+ filterPositionPending= false;
rememberUploadMode = ISD::CCD::UPLOAD_CLIENT;
HFRInc =0;
@@ -227,8 +224,6 @@ Focus::~Focus()
{
//qDeleteAll(HFRAbsolutePoints);
// HFRAbsolutePoints.clear();
-
- delete [] darkBuffer;
}
void Focus::toggleAutofocus(bool enable)
@@ -287,14 +282,14 @@ void Focus::resetFrame()
settings["y"] = y;
settings["w"] = w;
settings["h"] = h;
+ settings["binx"] = 1;
+ settings["biny"] = 1;
frameSettings[targetChip] = settings;
//targetChip->setFocusFrame(0,0,0,0);
//starSelected = false;
starCoords = QVector3D();
- subFramed = false;
-
- haveDarkFrame=false;
+ subFramed = false;
FITSView *targetImage = targetChip->getImage(FITS_FOCUS);
if (targetImage)
@@ -387,6 +382,8 @@ void Focus::syncCCDInfo()
int x,y,w,h;
if (targetChip->getFrame(&x, &y, &w, &h))
{
+ int binx=1,biny=1;
+ targetChip->getBinning(&binx, &biny);
if (w > 0 && h > 0)
{
QVariantMap settings;
@@ -395,6 +392,8 @@ void Focus::syncCCDInfo()
settings["y"] = y;
settings["w"] = w;
settings["h"] = h;
+ settings["binx"] = binx;
+ settings["biny"] = biny;
frameSettings[targetChip] = settings;
}
@@ -803,7 +802,6 @@ void Focus::capture()
ISD::CCDChip *targetChip = currentCCD->getChip(ISD::CCDChip::PRIMARY_CCD);
double seqExpose = exposureIN->value();
- CCDFrameType ccdFrame = FRAME_LIGHT;
if (currentCCD->isConnected() == false)
{
@@ -833,49 +831,32 @@ void Focus::capture()
{
rememberUploadMode = ISD::CCD::UPLOAD_LOCAL;
currentCCD->setUploadMode(ISD::CCD::UPLOAD_CLIENT);
- }
-
- // On bin change, invalidate the dark frame
- if (starCoords.isNull() == false && starCoords.z() != activeBin)
- haveDarkFrame = false;
-
- // Check if we need to capture a dark frame
- if (inFocusLoop == false && haveDarkFrame == false && focusDarkFrameCheck->isChecked() && calibrationState == CALIBRATE_NONE)
- {
- ccdFrame = FRAME_DARK;
- calibrationState = CALIBRATE_START;
-
- if (ISOCombo->isEnabled())
- KMessageBox::information(NULL, i18n("Cover your telescope in order to take a dark frame..."));
- }
+ }
targetChip->setBinning(activeBin, activeBin);
- targetChip->setCaptureMode( (ccdFrame == FRAME_LIGHT) ? FITS_FOCUS : FITS_CALIBRATE);
- targetChip->setCaptureFilter(defaultScale);
+ targetChip->setCaptureMode(FITS_FOCUS);
+
+ // Always disable filtering if using a dark frame and then re-apply after subtraction. TODO: Implement this in capture and guide and align
+ if (focusDarkFrameCheck->isChecked())
+ targetChip->setCaptureFilter(FITS_NONE);
+ else
+ targetChip->setCaptureFilter(defaultScale);
if (ISOCombo->isEnabled() && ISOCombo->currentIndex() != -1 && targetChip->getISOIndex() != ISOCombo->currentIndex())
targetChip->setISOIndex(ISOCombo->currentIndex());
connect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
- targetChip->setFrameType(ccdFrame);
-
- /*if (fw == 0 || fh == 0)
- targetChip->getFrame(&fx, &fy, &fw, &fh);
-
- targetChip->setFrame(fx, fy, fw, fh);
-
- if (orig_x == -1)
- targetChip->getFrame(&orig_x, &orig_y, &orig_w, &orig_h);
-
- if (frameModified == false && (fx != orig_x || fy != orig_y || fw != orig_w || fh != orig_h))
- frameModified = true;*/
+ targetChip->setFrameType(FRAME_LIGHT);
if (frameSettings.contains(targetChip))
{
QVariantMap settings = frameSettings[targetChip];
targetChip->setFrame(settings["x"].toInt(), settings["y"].toInt(), settings["w"].toInt(), settings["h"].toInt());
+ settings["binx"] = activeBin;
+ settings["biny"] = activeBin;
+ frameSettings[targetChip] = settings;
}
captureInProgress = true;
@@ -884,10 +865,7 @@ void Focus::capture()
if (inFocusLoop == false)
{
- if (ccdFrame == FRAME_LIGHT)
- appendLogText(i18n("Capturing image..."));
- else
- appendLogText(i18n("Capturing dark frame..."));
+ appendLogText(i18n("Capturing image..."));
if (inAutoFocus == false)
{
@@ -979,50 +957,43 @@ void Focus::FocusOut(int ms)
void Focus::newFITS(IBLOB *bp)
{
INDI_UNUSED(bp);
- QString HFRText;
// Ignore guide head if there is any.
if (!strcmp(bp->name, "CCD2"))
return;
ISD::CCDChip *targetChip = currentCCD->getChip(ISD::CCDChip::PRIMARY_CCD);
+ disconnect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
- if (inFocusLoop == false)
+ if (focusDarkFrameCheck->isChecked())
{
- if (calibrationState == CALIBRATE_START)
- {
- calibrationState = CALIBRATE_DONE;
- capture();
- return;
- }
+ FITSView *currentImage = targetChip->getImage(FITS_FOCUS);
+ FITSData *darkData = NULL;
+ QVariantMap settings = frameSettings[targetChip];
+ uint16_t offsetX = settings["x"].toInt() / settings["binx"].toInt();
+ uint16_t offsetY = settings["y"].toInt() / settings["biny"].toInt();
- // If we're done capturing dark frame, store it.
- if (focusDarkFrameCheck->isChecked() && calibrationState == CALIBRATE_DONE)
- {
- calibrationState = CALIBRATE_NONE;
+ darkData = DarkLibrary::Instance()->getDarkFrame(targetChip, exposureIN->value());
- delete [] darkBuffer;
+ connect(DarkLibrary::Instance(), SIGNAL(darkFrameCompleted(bool)), this, SLOT(setCaptureComplete()));
+ connect(DarkLibrary::Instance(), SIGNAL(newLog(QString)), this, SLOT(appendLogText(QString)));
- FITSView *calibrateImage = targetChip->getImage(FITS_CALIBRATE);
- Q_ASSERT(calibrateImage != NULL);
- FITSData *calibrateData = calibrateImage->getImageData();
+ if (darkData)
+ DarkLibrary::Instance()->subtract(darkData, currentImage, defaultScale, offsetX, offsetY);
+ else
+ DarkLibrary::Instance()->captureAndSubtract(targetChip, currentImage, exposureIN->value(), offsetX, offsetY);
- haveDarkFrame = true;
- int totalSize = calibrateData->getSize()*calibrateData->getNumOfChannels();
- darkBuffer = new float[totalSize];
- memcpy(darkBuffer, calibrateData->getImageBuffer(), totalSize*sizeof(float));
- }
+ return;
+ }
- // If we already have a dark frame, subtract it from light frame
- if (haveDarkFrame)
- {
- FITSView *currentImage = targetChip->getImage(FITS_FOCUS);
- Q_ASSERT(currentImage != NULL);
+ setCaptureComplete();
+}
- currentImage->getImageData()->subtract(darkBuffer);
- currentImage->rescale(ZOOM_KEEP_LEVEL);
- }
- }
+void Focus::setCaptureComplete()
+{
+ DarkLibrary::Instance()->disconnect(this);
+
+ ISD::CCDChip *targetChip = currentCCD->getChip(ISD::CCDChip::PRIMARY_CCD);
// Always reset capture mode to NORMAL
targetChip->setCaptureMode(FITS_NORMAL);
@@ -1069,7 +1040,7 @@ void Focus::newFITS(IBLOB *bp)
FITSData *image_data = targetChip->getImageData();
- disconnect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
+
starPixmap = targetImage->getTrackingBoxPixmap();
emit newStarPixmap(starPixmap);
@@ -1112,7 +1083,7 @@ void Focus::newFITS(IBLOB *bp)
return;
}
- HFRText = QString("%1").arg(currentHFR, 0,'g', 3);
+ QString HFRText = QString("%1").arg(currentHFR, 0,'g', 3);
if (focusType == FOCUS_MANUAL && lastHFR == -1)
appendLogText(i18n("FITS received. No stars detected."));
@@ -1236,14 +1207,15 @@ void Focus::newFITS(IBLOB *bp)
settings["y"] = subY;
settings["w"] = subW;
settings["h"] = subH;
+ settings["binx"] = subBinX;
+ settings["biny"] = subBinY;
+
frameSettings[targetChip] = settings;
starCoords.setX(subW/(2*subBinX));
starCoords.setY(subH/(2*subBinY));
- subFramed = true;
- haveDarkFrame=false;
- calibrationState = CALIBRATE_NONE;
+ subFramed = true;
}
else
{
@@ -2117,7 +2089,6 @@ void Focus::focusStarSelected(int x, int y)
// If binning was changed outside of the focus module, recapture
if (subBinX != activeBin)
{
- haveDarkFrame=false;
capture();
return;
}
@@ -2166,12 +2137,12 @@ void Focus::focusStarSelected(int x, int y)
settings["y"] = y;
settings["w"] = w;
settings["h"] = h;
- frameSettings[targetChip] = settings;
+ settings["binx"] = subBinX;
+ settings["biny"] = subBinY;
+ frameSettings[targetChip] = settings;
- subFramed = true;
- haveDarkFrame=false;
- calibrationState = CALIBRATE_NONE;
+ subFramed = true;
capture();
diff --git a/kstars/ekos/focus.h b/kstars/ekos/focus.h
index 8717ac8..f23ee32 100644
--- a/kstars/ekos/focus.h
+++ b/kstars/ekos/focus.h
@@ -46,7 +46,6 @@ public:
Focus();
~Focus();
- enum { CALIBRATE_NONE, CALIBRATE_START, CALIBRATE_DONE };
typedef enum { FOCUS_NONE, FOCUS_IN, FOCUS_OUT } FocusDirection;
typedef enum { FOCUS_MANUAL, FOCUS_AUTO, FOCUS_LOOP } FocusType;
@@ -165,8 +164,7 @@ public:
*/
void addFilter(ISD::GDInterface *newFilter);
- // Log
- void appendLogText(const QString &);
+
void clearLog();
QString getLogText() { return logText.join("\n"); }
@@ -290,6 +288,9 @@ public slots:
*/
void filterChangeWarning(int index);
+ // Log
+ void appendLogText(const QString &);
+
private slots:
/**
* @brief filterLockToggled Process filter locking/unlocking. Filter lock causes the autofocus process to use the selected filter whenever it runs.
@@ -328,6 +329,8 @@ private slots:
void setFrames(int value);
+ void setCaptureComplete();
+
signals:
void newLog();
void autoFocusFinished(bool status, double finalHFR);
@@ -460,12 +463,7 @@ private:
QVector<double> firstGausFrequencies, lastGausFrequencies;
QCPGraph *currentGaus, *firstGaus, *lastGaus;
- QVector<double> hfr_position, hfr_value;
-
- // Calibration
- int calibrationState;
- bool haveDarkFrame;
- float *darkBuffer;
+ QVector<double> hfr_position, hfr_value;
// Pixmaps
QPixmap starPixmap;
diff --git a/kstars/ekos/guide.cpp b/kstars/ekos/guide.cpp
index 275859c..dc47574 100644
--- a/kstars/ekos/guide.cpp
+++ b/kstars/ekos/guide.cpp
@@ -23,6 +23,7 @@
#include "guide/guider.h"
#include "phd2.h"
+#include "darklibrary.h"
#include "indi/driverinfo.h"
#include "indi/clientmanager.h"
@@ -49,9 +50,7 @@ Guide::Guide() : QWidget()
useGuideHead = false;
useDarkFrame = false;
rapidGuideReticleSet = false;
- isSuspended = false;
- darkExposure = 0;
- darkImage = NULL;
+ isSuspended = false;
AODriver= NULL;
GuideDriver=NULL;
calibration=NULL;
@@ -426,8 +425,6 @@ bool Guide::capture()
ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
- CCDFrameType ccdFrame = FRAME_LIGHT;
-
if (currentCCD->isConnected() == false)
{
appendLogText(i18n("Error: Lost connection to CCD."));
@@ -439,34 +436,11 @@ bool Guide::capture()
{
targetChip->resetFrame();
guider->setSubFramed(false);
- }
-
- // Exposure changed, take a new dark
- if (useDarkFrame && darkExposure != seqExpose)
- {
- darkExposure = seqExpose;
-
- // Load an image from the dark library. If not found, then capture a dark frame
- if (loadDarkFrame(seqExpose) == false)
- {
- targetChip->setFrameType(FRAME_DARK);
-
- if (calibration->useAutoStar() == false)
- KMessageBox::information(NULL, i18n("If the guider camera if not equipped with a shutter, cover the telescope or camera in order to take a dark exposure."), i18n("Dark Exposure"), "dark_exposure_dialog_notification");
-
- connect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*)));
- targetChip->capture(seqExpose);
-
- appendLogText(i18n("Taking a dark frame. "));
-
- return true;
- }
- }
+ }
targetChip->setCaptureMode(FITS_GUIDE);
- targetChip->setFrameType(ccdFrame);
- if (darkImage == NULL || calibration->useDarkFrame() == false)
- targetChip->setCaptureFilter((FITSScale) filterCombo->currentIndex());
+ targetChip->setFrameType(FRAME_LIGHT);
+ targetChip->setCaptureFilter((FITSScale) filterCombo->currentIndex());
if (guider->isGuiding())
{
@@ -483,6 +457,7 @@ bool Guide::capture()
return true;
}
+
void Guide::newFITS(IBLOB *bp)
{
INDI_UNUSED(bp);
@@ -493,26 +468,46 @@ void Guide::newFITS(IBLOB *bp)
ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
- // Received a dark calibration frame
- if (targetChip->getFrameType() == FRAME_DARK)
+ // Do we need to take a dark frame?
+ if (useDarkFrame)
{
- FITSView *targetImage = targetChip->getImage(FITS_CALIBRATE);
- if (targetImage)
- {
- delete (darkImage);
- darkImage = targetImage->getImageData();
+ if (calibration->useAutoStar() == false)
+ KMessageBox::information(NULL, i18n("If the guide camera is not equipped with a shutter, cover the telescope or camera in order to take a dark exposure."), i18n("Dark Exposure"), "dark_exposure_dialog_notification");
- // Save dark frame in the library
- saveDarkFrame();
+ int x,y,w,h;
+ int binx,biny;
- capture();
- }
+ targetChip->getFrame(&x,&y,&w,&h);
+ targetChip->getBinning(&binx,&biny);
+
+ FITSView *currentImage = targetChip->getImage(FITS_GUIDE);
+ FITSData *darkData = NULL;
+ uint16_t offsetX = x / binx;
+ uint16_t offsetY = y / biny;
+
+ darkData = DarkLibrary::Instance()->getDarkFrame(targetChip, exposureIN->value());
+
+ connect(DarkLibrary::Instance(), SIGNAL(darkFrameCompleted(bool)), this, SLOT(setCaptureComplete()));
+ connect(DarkLibrary::Instance(), SIGNAL(newLog(QString)), this, SLOT(appendLogText(QString)));
+
+ if (darkData)
+ DarkLibrary::Instance()->subtract(darkData, currentImage, targetChip->getCaptureFilter(), offsetX, offsetY);
else
- appendLogText(i18n("Dark frame processing failed."));
+ DarkLibrary::Instance()->captureAndSubtract(targetChip, currentImage, exposureIN->value(), offsetX, offsetY);
return;
}
+ setCaptureComplete();
+}
+
+void Guide::setCaptureComplete()
+{
+
+ DarkLibrary::Instance()->disconnect(this);
+
+ ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD);
+
FITSView *targetImage = targetChip->getImage(FITS_GUIDE);
if (targetImage == NULL)
@@ -524,29 +519,12 @@ void Guide::newFITS(IBLOB *bp)
return;
}
- /*if (targetImage == NULL)
- {
- pmath->set_image(NULL);
- guider->setImage(NULL);
- calibration->setImage(NULL);
- return;
- }*/
-
if (Options::guideLogging())
qDebug() << "Guide: recieved guide frame.";
FITSData *image_data = targetImage->getImageData();
-
Q_ASSERT(image_data);
- if (darkImage && darkImage->getImageBuffer() != image_data->getDarkFrame())
- {
- image_data->setDarkFrame(darkImage->getImageBuffer());
- image_data->applyFilter((FITSScale) filterCombo->currentIndex());
- targetImage->rescale(ZOOM_KEEP_LEVEL);
- targetImage->updateFrame();
- }
-
pmath->set_image(targetImage);
guider->setImage(targetImage);
@@ -1107,27 +1085,6 @@ void Guide::checkExposureValue(ISD::CCDChip *targetChip, double exposure, IPStat
}
}
-bool Guide::loadDarkFrame(double exposure)
-{
- QString filename = QString("dark-%1-%2.fits").arg(QString(currentCCD->getDeviceName()).replace(" ", "_")).arg(QString::number(exposure, 'f', 2));
- QString path = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + filename;
- if (darkImage == NULL)
- darkImage = new FITSData();
-
- return darkImage->loadFITS(path);
-}
-
-void Guide::saveDarkFrame()
-{
- QString filename = QString("dark-%1-%2.fits").arg(QString(currentCCD->getDeviceName()).replace(" ", "_")).arg(QString::number(darkExposure, 'f', 2));
- QString path = KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + filename;
-
- if (darkImage->saveFITS(path) == 0)
- appendLogText(i18n("Saved new dark frame %1 to library.", path));
- else
- appendLogText(i18n("Failed to save dark frame to library!"));
-}
-
void Guide::setUseDarkFrame(bool enable)
{
useDarkFrame = enable;
diff --git a/kstars/ekos/guide.h b/kstars/ekos/guide.h
index 3d1411a..d957016 100644
--- a/kstars/ekos/guide.h
+++ b/kstars/ekos/guide.h
@@ -264,6 +264,9 @@ public slots:
void setStatus(Ekos::GuideState newState);
+ // Capture
+ void setCaptureComplete();
+
protected slots:
void updateCCDBin(int index);
@@ -296,11 +299,6 @@ signals:
private:
void updateGuideParams();
- // Dark Library
- bool loadDarkFrame(double exposure);
- void saveDarkFrame();
- void clearDarkLibrary();
-
ISD::CCD *currentCCD;
ISD::Telescope *currentTelescope;
ISD::ST4* ST4Driver;
@@ -322,8 +320,6 @@ private:
bool phd2Connected;
bool useDarkFrame;
- double darkExposure;
- FITSData *darkImage;
QStringList logText;
diff --git a/kstars/ekos/sequencejob.h b/kstars/ekos/sequencejob.h
index 9e8d44e..d9d70c3 100644
--- a/kstars/ekos/sequencejob.h
+++ b/kstars/ekos/sequencejob.h
@@ -70,19 +70,26 @@ class SequenceJob : public QObject
void setCurrentFilter(int value);
const QString &getFilterName() { return filter; }
+
void setFrameType(int type, const QString & name);
int getFrameType() { return frameType;}
+
void setCaptureFilter(FITSScale capFilter) { captureFilter = capFilter; }
+ FITSScale getCaptureFilter() { return captureFilter;}
+
void setPreview(bool enable) { preview = enable; }
void setFullPrefix(const QString &cprefix) { fullPrefix = cprefix;}
void setFrame(int in_x, int in_y, int in_w, int in_h) { x=in_x; y=in_y; w=in_w; h=in_h; }
+
int getSubX() { return x;}
int getSubY() { return y;}
int getSubW() { return w;}
int getSubH() { return h;}
+
void setBin(int xbin, int ybin) { binX = xbin; binY=ybin;}
int getXBin() { return binX; }
int getYBin() { return binY; }
+
void setDelay(int in_delay) { delay = in_delay; }
void setCount(int in_count) { count = in_count;}
void setExposure(double duration) { exposure = duration;}