cudaconfidencemapsdemo.h 5.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
// 
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
// except in compliance with the License. You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the 
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific language governing permissions 
// and limitations under the License.
// 
// ================================================================================================

#ifndef CUDACONFIDENCEMAPSDEMO_H__
#define CUDACONFIDENCEMAPSDEMO_H__

Declara Denis's avatar
Declara Denis committed
28 29
#include <tbb/tick_count.h>

30

31
#include "core/pipeline/autoevaluationpipeline.h"
32 33 34 35
#include "core/properties/buttonproperty.h"

#include "modules/modulesapi.h"
#include "modules/base/processors/matrixprocessor.h"
36
#include "modules/preprocessing/processors/glgaussianfilter.h"
37
#include "modules/preprocessing/processors/glimagecrop.h"
38
#include "modules/preprocessing/processors/glimageresampler.h"
39
#include "modules/cudaconfidencemaps/processors/cudaconfidencemapssolver.h"
40
#include "modules/cudaconfidencemaps/processors/usfanrenderer.h"
41
#include "modules/openigtlink/processors/openigtlinkclient.h"
42
#include "modules/advancedusvis/processors/advancedusfusion.h"
43 44 45 46



namespace campvis {
47

48
    class CAMPVIS_MODULES_API CudaConfidenceMapsDemo : public AutoEvaluationPipeline {
49 50 51 52
    public:
        /**
         * Creates a AutoEvaluationPipeline.
         */
53
        explicit CudaConfidenceMapsDemo(DataContainer *dc);
54 55 56 57 58 59 60 61 62 63 64 65

        /**
         * Virtual Destructor
         **/
        virtual ~CudaConfidenceMapsDemo();

        /// \see AutoEvaluationPipeline::init()
        virtual void init();

        /// \see AutoEvaluationPipeline::deinit()
        virtual void deinit();

66 67 68
        /// \see AbstractPipeline::executePipeline()
        virtual void executePipeline();

69 70 71
        /// \see AbstractPipeline::onEvent()
        virtual void onEvent(cgt::Event* e);

72 73 74 75
        /// \see AbstractPipeline::getName()
        virtual const std::string getName() const { return getId(); };
        static const std::string getId() { return "CudaConfidenceMapsDemo"; };

76 77
    protected:
        virtual void onPropertyChanged(const AbstractProperty* prop);
78

79
        void toggleIGTLConnection();
80
        void resetSettingsToDefault();
81
        void copyStatisticsToClipboard();
82
        void setAdvancedPropertiesVisibility(bool visible);
83

84
        // Processors
85
        OpenIGTLinkClient _usIgtlReader;
86
        GlImageCrop       _usCropFilter;
87
        GlGaussianFilter  _usPreBlur;
88 89
        GlGaussianFilter  _usBlurFilter;
        GlImageResampler  _usResampler;
90
        CudaConfidenceMapsSolver _usMapsSolver;
91 92
        AdvancedUsFusion  _usFusion;
        UsFanRenderer     _usFanRenderer;
93

94
        // Basic options
95
        BoolProperty   p_useFixedIterationCount;
96
        FloatProperty  p_millisecondBudget;
97
        IntProperty    p_iterationBudget;
98 99 100
        ButtonProperty p_connectDisconnectButton;
        FloatProperty  p_resamplingScale;
        FloatProperty  p_beta;
101

102
        ButtonProperty p_resetToDefault;
103

104 105 106
        BoolProperty   p_collectStatistics;
        ButtonProperty p_copyStatisticsToClipboard;

107
        BoolProperty   p_showAdvancedOptions;
108

109 110
        // Advanced options (hidden by default)
        BoolProperty   p_useAlphaBetaFilter;
111
        FloatProperty  p_gaussianFilterSize;
Declara Denis's avatar
Declara Denis committed
112
        FloatProperty  p_gradientScaling;
113 114 115 116
        FloatProperty  p_alpha;
        FloatProperty  p_gamma;
        FloatProperty  p_fanHalfAngle;
        FloatProperty  p_fanInnerRadius;
117
        BoolProperty   p_useSpacingEncodedFanGeometry; // Fan geometry is transmitted to campvis encoded in the x and y component of the voxel size (FOV in deg, innerRadius)
118 119 120
        StringProperty p_recordingDirectory;
        BoolProperty   p_enableRecording;

121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
        // Data structures to collect statistics
        struct StatisticsEntry {
            float time;
            int originalWidth, originalHeight;
            int downsampledWidth, downsampledHeight;
            float gaussianKernelSize;
            float scalingFactor;
            float alpha, beta, gamma, gradientScaling;
            int iterations;
            float solverExecutionTime;
            float totalExecutionTime;
            float solverError;
        };
        std::vector<StatisticsEntry> _statistics;
        tbb::tick_count _objectCreationTime;

137 138 139
        // Variables to keep track of file naming when recording...
        int _recordedFrames;
        std::string _filePrefix;
Declara Denis's avatar
Declara Denis committed
140 141

        tbb::tick_count _statisticsLastUpdateTime;
142 143 144 145
    };
}

#endif // CUDACONFIDENCEMAPSDEMO_H__