Пример #1
0
        private string TakeSnapshot(string savePath)
        {
            string fileName = "snapshot-" + DateTime.Now.ToString("yyyyMMddHHmmssff") + ".jpg";

            Debug.WriteLine("savePath = {0}, fileName = {1}", savePath, fileName);
            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }
            string filePath = Path.Combine(savePath, fileName);

            Debug.WriteLine("filePath = " + filePath);
            LogInfo("Saving snapshot to " + filePath);
            CubeImageUtils.TakeSnapshot(filePath, camControl, _config.JpegQuality,
                                        _config.UseMotionDetection, _config.MotionSensitivity,
                                        _config.UseMedianStacking,
                                        _config.UseContrastEnhancement, _config.ContrastValue, _config.ContrastMidpoint);

            _scan.imageSet.images.Add(new ScanImage(_cube.Elevation.ToString(), _cube.Rotation.ToString(), fileName));
            return(filePath);
        }
Пример #2
0
        private string TakeSnapshot(string savePath)
        {
            if (log.IsInfoEnabled)
            {
                log.Info("TakeSnapshot called using savePath = " + savePath);
            }

            string fileName = "snapshot-" + DateTime.Now.ToString("yyyyMMddHHmmssff") + ".jpg";

            if (log.IsDebugEnabled)
            {
                log.Debug("Snapshot file name is " + fileName);
            }

            if (!Directory.Exists(savePath))
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("savepath does not exist, creating");
                }

                Directory.CreateDirectory(savePath);
            }
            string filePath           = Path.Combine(savePath, fileName);
            bool   useMotionDetection = cbUseMotionDetection.Checked && !_temporarilyDisableMotionDetection;

            if (log.IsDebugEnabled)
            {
                log.Debug("use motion detection = " + useMotionDetection);
            }

            CubeImageUtils.TakeSnapshot(filePath, camControl, tbQuality.Value,
                                        useMotionDetection, tbSensitivity.Value,
                                        cbUseMedianStacking.Checked,
                                        cbUseContrastEnhancement.Checked, tbContrast.Value, tbMidpoint.Value);

            _scan.imageSet.images.Add(new ScanImage(_cube.Elevation.ToString(), _cube.Rotation.ToString(), fileName));
            _temporarilyDisableMotionDetection = false;
            return(filePath);
        }
Пример #3
0
        private void ShootCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                LogWriteLn("An error occured while trying to process the shoot string: " + e.Error.Message);
            }

            if (e.Cancelled)
            {
                LogWriteLn("Scan cancelled by user");
            }

            if (cbSetEXIF.Checked)
            {
                string result = "";
                LogWriteLn("Setting Exif data for images, checking Z string for LE value");
                string le = "38";
                try {
                    le = _cube.CubeParameters["LE"];
                } catch {
                    LogWriteLn("35mm Focal Length Equivalent was NOT found in the Z string, defaulting to 38\n");
                }
                if (String.IsNullOrWhiteSpace(le))
                {
                    LogWriteLn("35mm Focal Length Equivalent was NOT set in the Z string, defaulting to 38\n");
                }
                try {
                    result = result + CubeImageUtils.SetExifInfo(_scan.LocalScanFolder, le);
                } catch (Exception ex) {
                    result = ex.Message;
                }
                LogWriteLn(result);
            }
            else
            {
                LogWriteLn("Skipping setting EXIF data");
            }

            ToggleUIControls();
        }
Пример #4
0
        private void MainWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            for (int i = 1; i <= udIterations.Value; i++)
            {
                string batchSubject = String.Format("Batch Scan {0} of {1}", i, udIterations.Value);
                worker.ReportProgress(DEBUG, batchSubject);
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
                _scan = InitializeScan(_config.ShootPrefix, batchSubject);

                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
                try {
                    _cube.ProcessShootString(_config.ShootString, worker, e, _picSynchronizer);
                } catch (Exception ex) {
                    worker.ReportProgress(ERROR, "Unable to run scan: " + ex.Message);
                    continue;
                }

                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                if (_config.DoSetEXIF)
                {
                    try {
                        worker.ReportProgress(INFO, "Setting EXIF data");
                        CubeImageUtils.SetExifInfo(_scan.LocalScanFolder, _35mmFocalEquivalent);
                    } catch (Exception ex) {
                        worker.ReportProgress(ERROR, "Unable to set Exif: " + ex.Message);
                    }
                }

                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                string host       = _config.SftpHost;
                string user       = _config.SftpUser;
                string pass       = _config.SftpPassword;
                string uploadBase = _config.SftpUploadBase;
                string triggerURL = _config.TriggerURL;

                try {
                    worker.ReportProgress(UploadManager.STATUS_FLAG, "Uploading Scan");
                    _scan.metadata.uploadStartTime = DateTime.Now.ToString(Scan.DATE_FORMAT);
                    _scan.WriteManifest();
                    UploadEar(worker, _scan.LocalScanFolder, host, user, pass, uploadBase, _scan.metadata.scanID, triggerURL);
                } catch (Exception ex) {
                    worker.ReportProgress(ERROR, "Unable to upload scan: " + ex.Message);
                }

                worker.ReportProgress(DEBUG, "Scan upload complete");

                if (i == udIterations.Value)
                {
                    continue;                     // skip the wait time
                }

                worker.ReportProgress(DEBUG, String.Format("Waiting {0} minute{1} to start next scan", udDelay.Value, udDelay.Value > 1 ? "s" : ""));
                worker.ReportProgress(UploadManager.SWITCH_TO_CONTINUOUS, 0);
                ulong start = Convert.ToUInt64(DateTime.Now.Ticks);
                Debug.WriteLine("start = " + start);
                ulong max = Convert.ToUInt64(udDelay.Value) * 60 * 10000000;                 // convert the time from minutes to ticks, which is a hundred nanoseconds
                Debug.WriteLine("max = " + max);
                ulong delta = Convert.ToUInt64(DateTime.Now.Ticks) - start;
                Debug.WriteLine("first delta = " + delta);
                while (delta <= max)
                {
                    Thread.Sleep(5000);
                    if (worker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }
                    int prog = Convert.ToInt16(Math.Round(((double)delta / (double)max) * 100));
                    Debug.WriteLine("prog = " + prog);
                    //worker.ReportProgress(DEBUG, prog.ToString());
                    worker.ReportProgress(prog);
                    delta = Convert.ToUInt64(DateTime.Now.Ticks) - start;
                    Debug.WriteLine("delta = " + delta);
                }
            }

            worker.ReportProgress(UploadManager.SWITCH_TO_CONTINUOUS, null);
            worker.ReportProgress(DEBUG, "Batch Run Complete");
        }