Fraxinus  16.5.0-fx-rc1
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxImageStreamerOpenCV.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #ifndef CXIMAGESTREAMEROPENCV_H_
34 #define CXIMAGESTREAMEROPENCV_H_
35 
36 #include "cxGrabberExport.h"
37 
38 #include <QObject> //needed for the mocer when OpenCv is not used...
39 #include "cxVideoServerConfig.h"
40 
41 #include "boost/shared_ptr.hpp"
42 #include <QTcpSocket>
43 #include <QDateTime>
44 #include <QSize>
45 #include <QStringList>
46 #include "cxSender.h"
47 #include "cxStreamer.h"
48 
49 class QDomElement;
50 
51 
52 class QTimer;
53 
54 namespace cv
55 {
56  class VideoCapture;
57  class Mat;
58 }
59 
60 namespace cx
61 {
62 typedef boost::shared_ptr<class Property> PropertyPtr;
63 typedef boost::shared_ptr<class DoublePropertyBase> DoublePropertyBasePtr;
64 typedef boost::shared_ptr<class BoolPropertyBase> BoolPropertyBasePtr;
65 
66 typedef boost::shared_ptr<cv::VideoCapture> VideoCapturePtr;
67 
70 class cxGrabber_EXPORT ImageStreamerOpenCVArguments
71 {
72 public:
73  QStringList getArgumentDescription();
74  virtual std::vector<PropertyPtr> getSettings(QDomElement root);
75  StringMap convertToCommandLineArguments(QDomElement root);
76 
77  DoublePropertyBasePtr getVideoPortOption(QDomElement root);
78  BoolPropertyBasePtr getPrintPropertiesOption(QDomElement root);
79 };
80 
93 class cxGrabber_EXPORT ImageStreamerOpenCV: public CommandLineStreamer
94 {
95 Q_OBJECT
96 
97 public:
99  virtual ~ImageStreamerOpenCV();
100 
101  virtual void initialize(StringMap arguments);
102  virtual void startStreaming(SenderPtr sender);
103  virtual void stopStreaming();
104  virtual bool isStreaming();
105 
106  virtual QString getType();
107  virtual QStringList getArgumentDescription();
108 
109 private slots:
110  void grab();
111  void send();
112  void continousGrabEvent();
113 
114 private:
115  void dumpProperties();
116  ImagePtr getImageMessage();
117  void dumpProperty(int val, QString name);
118 
119  void initialize_local();
120  void deinitialize_local();
121  vtkImageDataPtr convertTovtkImageData(cv::Mat& frame);
122 
123  QSize mRescaleSize;
124 
125  VideoCapturePtr mVideoCapture; // OpenCV video grabber
126  QDateTime mLastGrabTime;
127  bool mAvailableImage;
128  bool mGrabbing;
129 
130 };
131 
132 }
133 
134 #endif /* CXIMAGESTREAMEROPENCV_H_ */
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
std::map< QString, QString > StringMap
boost::shared_ptr< class Property > PropertyPtr
boost::shared_ptr< class BoolPropertyBase > BoolPropertyBasePtr
boost::shared_ptr< cv::VideoCapture > VideoCapturePtr
boost::shared_ptr< class DoublePropertyBase > DoublePropertyBasePtr
boost::shared_ptr< Sender > SenderPtr
Definition: cxSender.h:85
vtkSmartPointer< class vtkImageData > vtkImageDataPtr