Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
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) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXIMAGESTREAMEROPENCV_H_
13 #define CXIMAGESTREAMEROPENCV_H_
14 
15 #include "cxGrabberExport.h"
16 
17 #include <QObject> //needed for the mocer when OpenCv is not used...
18 #include "cxVideoServerConfig.h"
19 
20 #include "boost/shared_ptr.hpp"
21 #include <QTcpSocket>
22 #include <QDateTime>
23 #include <QSize>
24 #include <QStringList>
25 #include "cxSender.h"
26 #include "cxStreamer.h"
27 
28 class QDomElement;
29 
30 
31 class QTimer;
32 
33 namespace cv
34 {
35  class VideoCapture;
36  class Mat;
37 }
38 
39 namespace cx
40 {
41 typedef boost::shared_ptr<class Property> PropertyPtr;
42 typedef boost::shared_ptr<class DoublePropertyBase> DoublePropertyBasePtr;
43 typedef boost::shared_ptr<class BoolPropertyBase> BoolPropertyBasePtr;
44 
45 typedef boost::shared_ptr<cv::VideoCapture> VideoCapturePtr;
46 
49 class cxGrabber_EXPORT ImageStreamerOpenCVArguments
50 {
51 public:
52  QStringList getArgumentDescription();
53  virtual std::vector<PropertyPtr> getSettings(QDomElement root);
54  StringMap convertToCommandLineArguments(QDomElement root);
55 
56  DoublePropertyBasePtr getVideoPortOption(QDomElement root);
57  BoolPropertyBasePtr getPrintPropertiesOption(QDomElement root);
58 };
59 
72 class cxGrabber_EXPORT ImageStreamerOpenCV: public CommandLineStreamer
73 {
74 Q_OBJECT
75 
76 public:
78  virtual ~ImageStreamerOpenCV();
79 
80  virtual void initialize(StringMap arguments);
81  virtual void startStreaming(SenderPtr sender);
82  virtual void stopStreaming();
83  virtual bool isStreaming();
84 
85  virtual QString getType();
86  virtual QStringList getArgumentDescription();
87 
88 private slots:
89  void grab();
90  void send();
91  void continousGrabEvent();
92 
93 private:
94  void dumpProperties();
95  ImagePtr getImageMessage();
96  void dumpProperty(int val, QString name);
97 
98  void initialize_local();
99  void deinitialize_local();
100  vtkImageDataPtr convertTovtkImageData(cv::Mat& frame);
101 
102  QSize mRescaleSize;
103 
104  VideoCapturePtr mVideoCapture; // OpenCV video grabber
105  QDateTime mLastGrabTime;
106  bool mAvailableImage;
107  bool mGrabbing;
108 
109 };
110 
111 }
112 
113 #endif /* CXIMAGESTREAMEROPENCV_H_ */
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
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:64
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
Namespace for all CustusX production code.