CustusX  15.3.4-beta
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 "cxConfig.h"
40 
41 #include "boost/shared_ptr.hpp"
42 #include <QTcpSocket>
43 #include <QDateTime>
44 #include <QSize>
45 #include "igtlImageMessage.h"
46 #include <QStringList>
47 #include "cxIGTLinkImageMessage.h"
48 #include "cxSender.h"
49 #include "cxStreamer.h"
50 
51 class QDomElement;
52 
53 
54 class QTimer;
55 
56 namespace cv
57 {
58  class VideoCapture;
59 }
60 
61 namespace cx
62 {
63 typedef boost::shared_ptr<class Property> PropertyPtr;
64 typedef boost::shared_ptr<class DoublePropertyBase> DoublePropertyBasePtr;
65 typedef boost::shared_ptr<class BoolPropertyBase> BoolPropertyBasePtr;
66 
67 typedef boost::shared_ptr<cv::VideoCapture> VideoCapturePtr;
68 
71 class cxGrabber_EXPORT ImageStreamerOpenCVArguments
72 {
73 public:
74  QStringList getArgumentDescription();
75  virtual std::vector<PropertyPtr> getSettings(QDomElement root);
76  StringMap convertToCommandLineArguments(QDomElement root);
77 
78  DoublePropertyBasePtr getVideoPortOption(QDomElement root);
79  BoolPropertyBasePtr getPrintPropertiesOption(QDomElement root);
80 };
81 
94 class cxGrabber_EXPORT ImageStreamerOpenCV: public CommandLineStreamer
95 {
96 Q_OBJECT
97 
98 public:
100  virtual ~ImageStreamerOpenCV();
101 
102  virtual void initialize(StringMap arguments);
103  virtual bool startStreaming(SenderPtr sender);
104  virtual void stopStreaming();
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  IGTLinkImageMessage::Pointer getImageMessage();
117  void dumpProperty(int val, QString name);
118 
119  void initialize_local();
120  void deinitialize_local();
121 
122 // QTimer* mGrabTimer;
123  QSize mRescaleSize;
124 
125  VideoCapturePtr mVideoCapture; // OpenCV video grabber
126  QDateTime mLastGrabTime;
127 // QTime mCounter;
128  bool mAvailableImage;
129  bool mGrabbing;
130 
131 };
132 
133 }
134 
135 #endif /* CXIMAGESTREAMEROPENCV_H_ */
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:88