05Robot 3.0

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

CameraObject.h
Go to the documentation of this file.
1
7 #ifndef CAMERAOBJECT_H
8 #define CAMERAOBJECT_H
9
10 #include <QSemaphore>
11 #include <QObject>
12 #include <QString>
13 #include <QVariant>
14 #include "Serialization.hpp"
15 #include "Camera.h"
16 #include "ProcessorObject.h"
17
18 #include <opencv2/opencv.hpp>
19 #include <opencv2/highgui/highgui.hpp>
20 #include <opencv2/imgproc/imgproc.hpp>
21
22 #include <iostream>
23 #include <fstream>
24 #include <cxmlio.h>
28 class ProcessorObject;
29
33 class CameraObject : public cXmlIO
34 {
35 Q_OBJECT
36 public:
40 enum DisplayData {
41 DisplayRawImage,
42 DisplayThreshold,
43 DisplayPoints,
44 DisplayNoImage,
45 };
46
50 ADD_PROPERTY(calibrationPath, QString)
51 Q_PROPERTY(QString CalibrationFileName READ calibrationFileName WRITE setCalibrationFileName DESIGNABLE true USER true)
52
56 ADD_PROPERTY(displayData, DisplayData)
57 Q_ENUMS(DisplayData)
58
59 public:
63 QString calibrationFileName() const {return m_calibrationFileName;}
67 void readCallibrationFile();
71 void setCalibrationFileName(const QString& calibrationFileName) {m_calibrationFileName = calibrationFileName;readCallibrationFile();}
72
73 virtual void writeXml(QXmlStreamWriter& xml);
74 virtual void readXml(QXmlStreamReader& xml);
75 //cImagePocessing *markersGenerator;
76 private:
77 QString m_calibrationFileName;
78 int n_img;
79
80 int matType;
81 bool first_grab;
82 cv::Mat frame;
83 cv::Mat thresh;
84 vector<vector<cv::Point> > contours;
85 vector<cv::Point2f> points;
86 ofstream output_file;
87
88 bool doRemap;
89 cv::Mat map1,map2;
90
91 public:
95 cv::Mat cameraMatrix;
99 cv::Mat distCoeffs;
103 QString cameraName;
104
105 public:
106 QSemaphore * syncSem;
107 CameraObject(Camera *c, int camType, int camId, QSemaphore *ss);
108 ~CameraObject()
109 {
110 qDebug("deleting co");
111 if(isRunning)
112 cam->stop();
113 cam->disconnect();
114 //delete markersGenerator;
115 // QFile ser(cameraName+".set");
116 // ser.open(QIODevice::WriteOnly);
117 // if(ser.isOpen())
118 // {
119 // QDataStream out(&ser);
120 // out<<*this;
121 // out<<*cam;
122 // ser.close();
123 // }
124 delete cam;
125 }
126
127 public:
131 Camera* cam;
135 int cameraType;
139 int cameraID;
143 bool isRunning;
144
145 public slots:
149 void cStart();
153 void cSync();
157 void cGrab();
161 void cStop();
162
163 void requestImage(void*, void*); // (cv::Mat *, QSemaphore *)
164 void requestPoints2(void*, void*); // (vector<cv::Point> *, QSemaphore * camSem)
165
166 signals:
174 void frameOut(cv::Mat* image, int width, int height);
180 void writeInfo(QString info);
181
182 };
184 #endif
ADD_PROPERTY
#define ADD_PROPERTY(member, _type)
Definition: common.h:14
CameraObject::DisplayData
DisplayData
Display data type enum.
Definition: CameraObject.h:40
cxmlio.h
CameraObject::cGrab
void cGrab()
Copies image from internal buffer to requested buffers.
CameraObject::calibrationPath
QString calibrationPath() const
Gets calibrationPath property value.
CameraObject::frameOut
void frameOut(cv::Mat *image, int width, int height)
Emitted at finish of each frame capture.
Camera
Base camera interface class.
Definition: Camera.h:49
CameraObject::DisplayRawImage
Definition: CameraObject.h:41
CameraObject::cameraName
QString cameraName
Camera name.
Definition: CameraObject.h:103
Camera::stop
virtual int stop()
Stops acquisition.
Definition: Camera.h:146
ProcessorObject
Wrapper object containing single processor, managing its processing and control pipelines, and properties.
Definition: ProcessorObject.h:28
CameraObject::cameraType
int cameraType
Corresponding camera type.
Definition: CameraObject.h:135
CameraObject::cam
Camera * cam
Pointer to corresponding Camera.
Definition: CameraObject.h:131
CameraObject::writeInfo
void writeInfo(QString info)
Data logger.
CameraObject
Wrapper object containing single camera, managing its processing and control pipelines, and properties.
Definition: CameraObject.h:33
CameraObject::syncSem
QSemaphore * syncSem
Definition: CameraObject.h:106
CameraObject::readXml
virtual void readXml(QXmlStreamReader &xml)
Called by findInXML. Reads XML entries. Has to be overloaded if additional data was written to file i...
CameraObject::DisplayNoImage
Definition: CameraObject.h:44
Camera::disconnect
virtual int disconnect()
Disconnects from camera.
Definition: Camera.h:152
CameraObject::cameraMatrix
cv::Mat cameraMatrix
Camera matrix.
Definition: CameraObject.h:95
CameraObject::DisplayThreshold
Definition: CameraObject.h:42
CameraObject::cStop
void cStop()
Stops camera pipeline, sets isRunning to true.
Serialization.hpp
CameraObject::CameraObject
CameraObject(Camera *c, int camType, int camId, QSemaphore *ss)
CameraObject::writeXml
virtual void writeXml(QXmlStreamWriter &xml)
Writes XML entries to file. Can be overloaded to save additional data, apart from object properties...
CameraObject::isRunning
bool isRunning
Camera running flag.
Definition: CameraObject.h:143
cXmlIO
Delivers XML file serialisation and deserialisation methods for modules.
Definition: cxmlio.h:22
CameraObject::displayData
DisplayData displayData() const
Gets displayData property value.
CameraObject::cameraID
int cameraID
Corresponding camera ID.
Definition: CameraObject.h:139
CameraObject::CalibrationFileName
QString CalibrationFileName
Definition: CameraObject.h:51
CameraObject::distCoeffs
cv::Mat distCoeffs
Distortion coefficients.
Definition: CameraObject.h:99
CameraObject::DisplayPoints
Definition: CameraObject.h:43
Camera.h
ProcessorObject.h
CameraObject::cStart
void cStart()
Starts camera pipeline, sets isRunning to true.
CameraObject::setCalibrationFileName
Q_ENUMS(DisplayData) public void setCalibrationFileName(const QString &calibrationFileName)
Gets calibration file path.
Definition: CameraObject.h:71
CameraObject::cSync
void cSync()
Sends software trigger to camera.
CameraObject::requestPoints2
void requestPoints2(void *, void *)
CameraObject::~CameraObject
~CameraObject()
Definition: CameraObject.h:108
CameraObject::requestImage
void requestImage(void *, void *)