Revision f633b268
| b/prototypes/kinectvision-qt-pcl/commun.h | ||
|---|---|---|
| 24 | 24 |
|
| 25 | 25 |
#include <pcl/visualization/cloud_viewer.h> |
| 26 | 26 |
#include <QVector3D> |
| 27 |
#include <QStringList> |
|
| 27 | 28 |
|
| 28 | 29 |
using namespace pcl; |
| 29 | 30 |
|
| ... | ... | |
| 61 | 62 |
CalibrationInfo calibration; |
| 62 | 63 |
}; |
| 63 | 64 |
|
| 65 |
struct ConfigurationInfo {
|
|
| 66 |
QStringList serials; |
|
| 67 |
}; |
|
| 68 |
|
|
| 64 | 69 |
#endif // COMMUN_H |
| b/prototypes/kinectvision-qt-pcl/configurationparser.cpp | ||
|---|---|---|
| 1 |
#include "configurationparser.h" |
|
| 2 |
|
|
| 3 |
ConfigurationParser::ConfigurationParser() |
|
| 4 |
{
|
|
| 5 |
mFileConfig = new QFile("config/kinectvision.cfg");
|
|
| 6 |
mXmlWriter = new QXmlStreamWriter(mFileConfig); |
|
| 7 |
mXmlReader = new QXmlStreamReader(mFileConfig); |
|
| 8 |
} |
|
| 9 |
|
|
| 10 |
void ConfigurationParser::readConfigFile() |
|
| 11 |
{
|
|
| 12 |
//ConfigurationInfo configuration; |
|
| 13 |
|
|
| 14 |
mFileConfig->open(QFile::ReadOnly | QFile::Text); |
|
| 15 |
//QXmlStreamReader xmlReader; |
|
| 16 |
//xmlReader.setDevice(mFileConfig); |
|
| 17 |
//mXmlReader->readNext(); //XML version & text encoding |
|
| 18 |
while(!mXmlReader->atEnd()) |
|
| 19 |
{
|
|
| 20 |
if(mXmlReader->isStartElement()) |
|
| 21 |
{
|
|
| 22 |
if(mXmlReader->name() == "Kinect_Serial") |
|
| 23 |
{
|
|
| 24 |
//std::cout << mXmlReader->name().toString().toStdString() << std::endl; |
|
| 25 |
mXmlReader->readNext(); |
|
| 26 |
} |
|
| 27 |
else if(mXmlReader->name() == "Kinect_ID1" || mXmlReader->name() == "Kinect_ID2" || mXmlReader->name() == "Kinect_ID3") |
|
| 28 |
{
|
|
| 29 |
//std::cout << mXmlReader->name().toString().toStdString() << std::endl; |
|
| 30 |
//configuration.serials.append(mXmlReader->readElementText()); |
|
| 31 |
//configuration.serials.append(mXmlReader->readElementText()); |
|
| 32 |
mXmlReader->readNext(); |
|
| 33 |
} |
|
| 34 |
else if (mXmlReader->name() == "Serial") |
|
| 35 |
{
|
|
| 36 |
mConfiguration.serials.append(mXmlReader->readElementText()); |
|
| 37 |
} |
|
| 38 |
/*else |
|
| 39 |
{
|
|
| 40 |
//std::cout << mXmlReader->name().toString().toStdString() << std::endl; |
|
| 41 |
mXmlReader->raiseError(QObject::tr("Reading error..."));
|
|
| 42 |
}*/ |
|
| 43 |
} |
|
| 44 |
else |
|
| 45 |
{
|
|
| 46 |
//std::cout << mXmlReader->name().toString().toStdString() << std::endl; |
|
| 47 |
mXmlReader->readNext(); |
|
| 48 |
} |
|
| 49 |
} |
|
| 50 |
mFileConfig->close(); |
|
| 51 |
} |
|
| 52 |
|
|
| 53 |
void ConfigurationParser::writeConfigFile() |
|
| 54 |
{
|
|
| 55 |
mFileConfig->open(QIODevice::WriteOnly | QFile::Text); |
|
| 56 |
|
|
| 57 |
mXmlWriter->setAutoFormatting(true); |
|
| 58 |
mXmlWriter->writeStartDocument(); |
|
| 59 |
|
|
| 60 |
mXmlWriter->writeStartElement("Kinect_Serial");
|
|
| 61 |
|
|
| 62 |
mXmlWriter->writeStartElement("Kinect_ID1");
|
|
| 63 |
mXmlWriter->writeTextElement("Serial", "A00366A03643050A");
|
|
| 64 |
mXmlWriter->writeEndElement(); |
|
| 65 |
mXmlWriter->writeStartElement("Kinect_ID2");
|
|
| 66 |
mXmlWriter->writeTextElement("Serial", "A00364900117050A");
|
|
| 67 |
mXmlWriter->writeEndElement(); |
|
| 68 |
mXmlWriter->writeStartElement("Kinect_ID3");
|
|
| 69 |
mXmlWriter->writeTextElement("Serial", "A00362A15458045A");
|
|
| 70 |
mXmlWriter->writeEndElement(); |
|
| 71 |
|
|
| 72 |
mXmlWriter->writeEndDocument(); |
|
| 73 |
|
|
| 74 |
mFileConfig->close(); |
|
| 75 |
} |
|
| 76 |
|
|
| 77 |
ConfigurationInfo ConfigurationParser::getConfiguration() |
|
| 78 |
{
|
|
| 79 |
return mConfiguration; |
|
| 80 |
} |
|
| b/prototypes/kinectvision-qt-pcl/configurationparser.h | ||
|---|---|---|
| 1 |
#ifndef CONFIGURATIONPARSER_H |
|
| 2 |
#define CONFIGURATIONPARSER_H |
|
| 3 |
|
|
| 4 |
#include <QXmlStreamWriter> |
|
| 5 |
#include <QXmlStreamReader> |
|
| 6 |
#include <QFile> |
|
| 7 |
|
|
| 8 |
#include <commun.h> |
|
| 9 |
|
|
| 10 |
class ConfigurationParser |
|
| 11 |
{
|
|
| 12 |
public: |
|
| 13 |
ConfigurationParser(); |
|
| 14 |
|
|
| 15 |
void readConfigFile(); |
|
| 16 |
void writeConfigFile(); |
|
| 17 |
ConfigurationInfo getConfiguration(); |
|
| 18 |
|
|
| 19 |
private: |
|
| 20 |
QFile *mFileConfig; |
|
| 21 |
QXmlStreamWriter *mXmlWriter; |
|
| 22 |
QXmlStreamReader *mXmlReader; |
|
| 23 |
|
|
| 24 |
ConfigurationInfo mConfiguration; |
|
| 25 |
}; |
|
| 26 |
|
|
| 27 |
#endif // CONFIGURATIONPARSER_H |
|
| b/prototypes/kinectvision-qt-pcl/kinectpcl.cpp | ||
|---|---|---|
| 21 | 21 |
|
| 22 | 22 |
#include "kinectpcl.h" |
| 23 | 23 |
|
| 24 |
KinectPCL::KinectPCL() |
|
| 24 |
KinectPCL::KinectPCL(ConfigurationParser *configurationParser)
|
|
| 25 | 25 |
{
|
| 26 | 26 |
mKinectSelected = 0; |
| 27 | 27 |
captureStarted = false; |
| 28 | 28 |
height = 480; |
| 29 | 29 |
width = 640; |
| 30 | 30 |
|
| 31 |
mKinectSerials.append("A00366A03643050A");
|
|
| 32 |
mKinectSerials.append("A00364900117050A");
|
|
| 33 |
mKinectSerials.append("A00362A15458045A");
|
|
| 31 |
configurationParser->readConfigFile(); |
|
| 32 |
mConfiguration = configurationParser->getConfiguration(); |
|
| 33 |
|
|
| 34 |
initialize(); |
|
| 35 |
|
|
| 36 |
for (int c=0; c<mKinectSerials.count(); c++) |
|
| 37 |
mPointClouds.append(PointCloud<PointXYZRGB>()); |
|
| 34 | 38 |
} |
| 35 | 39 |
|
| 36 | 40 |
void KinectPCL::initialize() |
| 37 | 41 |
{
|
| 38 |
switch (mKinectSelected) {
|
|
| 39 |
case 0: |
|
| 40 |
interfaceKinect = new pcl::OpenNIGrabber(mKinectSerials.at(0).toStdString()); |
|
| 41 |
break; |
|
| 42 |
case 1: |
|
| 43 |
interfaceKinect = new pcl::OpenNIGrabber(mKinectSerials.at(1).toStdString()); |
|
| 44 |
break; |
|
| 45 |
case 2: |
|
| 46 |
interfaceKinect = new pcl::OpenNIGrabber(mKinectSerials.at(2).toStdString()); |
|
| 47 |
break; |
|
| 42 |
try {
|
|
| 43 |
mInterfaceKinect.append(new OpenNIGrabber(mConfiguration.serials.at(0).toStdString())); |
|
| 44 |
mKinectSerials.append(mConfiguration.serials.at(0)); |
|
| 45 |
boost::function<void (const PointCloud<PointXYZRGB>::ConstPtr &cloud)> fSignal1 = boost::bind(&KinectPCL::getSignal1, this, _1); |
|
| 46 |
mInterfaceKinect.at(0)->registerCallback(fSignal1); |
|
| 47 |
mInterfaceKinect.append(new OpenNIGrabber(mConfiguration.serials.at(1).toStdString())); |
|
| 48 |
mKinectSerials.append(mConfiguration.serials.at(1)); |
|
| 49 |
boost::function<void (const PointCloud<PointXYZRGB>::ConstPtr &cloud)> fSignal2 = boost::bind(&KinectPCL::getSignal2, this, _1); |
|
| 50 |
mInterfaceKinect.at(1)->registerCallback(fSignal2); |
|
| 51 |
mInterfaceKinect.append(new OpenNIGrabber(mConfiguration.serials.at(2).toStdString())); |
|
| 52 |
mKinectSerials.append(mConfiguration.serials.at(2)); |
|
| 53 |
boost::function<void (const PointCloud<PointXYZRGB>::ConstPtr &cloud)> fSignal3 = boost::bind(&KinectPCL::getSignal3, this, _1); |
|
| 54 |
mInterfaceKinect.at(2)->registerCallback(fSignal3); |
|
| 55 |
} |
|
| 56 |
catch (pcl::PCLIOException e) {
|
|
| 57 |
//TODO |
|
| 48 | 58 |
} |
| 49 |
|
|
| 50 |
boost::function<void (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud)> fSignal = boost::bind(&KinectPCL::getSignal, this, _1); |
|
| 51 |
//boost::function<void ()> fViewer = boost::bind(&Viewer::updateViewer(), this, _1); |
|
| 52 |
interfaceKinect->registerCallback(fSignal); |
|
| 53 |
//interfaceKinect->registerCallback(fViewer); |
|
| 54 | 59 |
} |
| 55 | 60 |
|
| 56 | 61 |
void KinectPCL::startCapture() |
| 57 | 62 |
{
|
| 58 |
if (isCaptureStarted()) interfaceKinect->stop(); |
|
| 59 |
initialize(); |
|
| 60 |
interfaceKinect->start(); |
|
| 63 |
mInterfaceKinect.at(mKinectSelected)->start(); |
|
| 61 | 64 |
captureStarted = true; |
| 62 | 65 |
} |
| 63 | 66 |
|
| 64 | 67 |
void KinectPCL::stopCapture() |
| 65 | 68 |
{
|
| 66 |
interfaceKinect->stop();
|
|
| 69 |
mInterfaceKinect.at(mKinectSelected)->stop();
|
|
| 67 | 70 |
captureStarted = false; |
| 68 | 71 |
} |
| 69 | 72 |
|
| 70 |
void KinectPCL::getSignal(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud){
|
|
| 71 |
pcl::PointCloud<pcl::PointXYZRGB>::Ptr pointCloudCaptured(new pcl::PointCloud<pcl::PointXYZRGB>(*cloud)); |
|
| 72 |
mPointCloud = *pointCloudCaptured; |
|
| 73 |
//pointCloud = cloudCopy; |
|
| 74 |
//viewer->updateViewer(); |
|
| 73 |
void KinectPCL::startCaptureAllCameras() |
|
| 74 |
{
|
|
| 75 |
for (int c=0; c<mKinectSerials.count(); c++) |
|
| 76 |
if (!mInterfaceKinect.at(c)->isRunning()) |
|
| 77 |
mInterfaceKinect.at(c)->start(); |
|
| 78 |
captureStarted = true; |
|
| 79 |
} |
|
| 80 |
|
|
| 81 |
void KinectPCL::stopCaptureAllCameras() |
|
| 82 |
{
|
|
| 83 |
for (int c=0; c<mKinectSerials.count(); c++) |
|
| 84 |
if (mInterfaceKinect.at(c)->isRunning()) |
|
| 85 |
mInterfaceKinect.at(c)->stop(); |
|
| 86 |
captureStarted = false; |
|
| 87 |
} |
|
| 88 |
|
|
| 89 |
void KinectPCL::getSignal1(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud){
|
|
| 90 |
PointCloud<PointXYZRGB>::Ptr pointCloudCaptured(new PointCloud<PointXYZRGB>(*cloud)); |
|
| 91 |
mPointClouds[0] = *pointCloudCaptured; |
|
| 92 |
} |
|
| 93 |
|
|
| 94 |
void KinectPCL::getSignal2(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud){
|
|
| 95 |
PointCloud<PointXYZRGB>::Ptr pointCloudCaptured(new PointCloud<PointXYZRGB>(*cloud)); |
|
| 96 |
mPointClouds[1] = *pointCloudCaptured; |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
void KinectPCL::getSignal3(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud){
|
|
| 100 |
PointCloud<PointXYZRGB>::Ptr pointCloudCaptured(new PointCloud<PointXYZRGB>(*cloud)); |
|
| 101 |
mPointClouds[2] = *pointCloudCaptured; |
|
| 75 | 102 |
} |
| 76 | 103 |
|
| 77 |
PointCloud<PointXYZRGB> KinectPCL::getPointCloud() |
|
| 104 |
PointCloud<PointXYZRGB> KinectPCL::getPointCloud(int index)
|
|
| 78 | 105 |
{
|
| 79 |
return mPointCloud; |
|
| 106 |
return mPointClouds.at(index);
|
|
| 80 | 107 |
} |
| 81 | 108 |
|
| 82 | 109 |
bool KinectPCL::isCaptureStarted() |
| ... | ... | |
| 84 | 111 |
return captureStarted; |
| 85 | 112 |
} |
| 86 | 113 |
|
| 87 |
bool KinectPCL::isPointCloudCaptured() |
|
| 114 |
bool KinectPCL::isPointCloudCaptured(int index)
|
|
| 88 | 115 |
{
|
| 89 |
return !mPointCloud.points.empty(); |
|
| 116 |
return !mPointClouds.at(index).points.empty();
|
|
| 90 | 117 |
} |
| 91 | 118 |
|
| 92 | 119 |
int KinectPCL::getHeight() |
| ... | ... | |
| 101 | 128 |
|
| 102 | 129 |
int KinectPCL::getKinectCount() |
| 103 | 130 |
{
|
| 104 |
return mKinectSerials.count();
|
|
| 131 |
return mInterfaceKinect.count();
|
|
| 105 | 132 |
} |
| 106 | 133 |
|
| 107 | 134 |
void KinectPCL::setKinectSelected(int index) |
| ... | ... | |
| 115 | 142 |
return mKinectSerials.at(index); |
| 116 | 143 |
} |
| 117 | 144 |
|
| 145 |
int KinectPCL::getKinectSelected() |
|
| 146 |
{
|
|
| 147 |
return mKinectSelected; |
|
| 148 |
} |
|
| 149 |
|
|
| 150 |
void KinectPCL::stopCapture(int index) |
|
| 151 |
{
|
|
| 152 |
mInterfaceKinect.at(index)->stop(); |
|
| 153 |
} |
|
| 154 |
|
|
| 155 |
/*void KinectPCL::stopRunningCameras() |
|
| 156 |
{
|
|
| 157 |
for (int c=0; c<mKinectSerials.count(); c++) |
|
| 158 |
if (interfaceKinect.at(c)->isRunning()) |
|
| 159 |
interfaceKinect.at(c)->stop(); |
|
| 160 |
}*/ |
|
| 161 |
|
|
| 162 |
/*void KinectPCL::startRunningCameras() |
|
| 163 |
{
|
|
| 164 |
for (int c=0; c<mKinectSerials.count(); c++) |
|
| 165 |
if (!interfaceKinect.at(c)->isRunning()) |
|
| 166 |
interfaceKinect.at(c)->start(); |
|
| 167 |
}*/ |
|
| 168 |
|
|
| 118 | 169 |
/*int KinectPCL::getPointCloudCount() |
| 119 | 170 |
{
|
| 120 | 171 |
|
| b/prototypes/kinectvision-qt-pcl/kinectpcl.h | ||
|---|---|---|
| 31 | 31 |
#include <pcl/visualization/cloud_viewer.h> |
| 32 | 32 |
#include <pcl/io/pcd_io.h> |
| 33 | 33 |
|
| 34 |
#include <configurationparser.h> |
|
| 35 |
|
|
| 34 | 36 |
using namespace pcl; |
| 35 | 37 |
|
| 36 | 38 |
class KinectPCL |
| 37 | 39 |
{
|
| 38 | 40 |
//Q_OBJECT |
| 39 | 41 |
public: |
| 40 |
KinectPCL(); |
|
| 42 |
KinectPCL(ConfigurationParser *configurationParser);
|
|
| 41 | 43 |
void initialize(); |
| 42 | 44 |
void startCapture(); |
| 43 | 45 |
void stopCapture(); |
| 44 |
PointCloud<PointXYZRGB> getPointCloud(); |
|
| 46 |
void stopCapture(int index); |
|
| 47 |
void startCaptureAllCameras(); |
|
| 48 |
void stopCaptureAllCameras(); |
|
| 49 |
PointCloud<PointXYZRGB> getPointCloud(int index); |
|
| 45 | 50 |
bool isCaptureStarted(); |
| 46 |
bool isPointCloudCaptured(); |
|
| 51 |
bool isPointCloudCaptured(int index);
|
|
| 47 | 52 |
int getHeight(); |
| 48 | 53 |
int getWidth(); |
| 49 | 54 |
int getKinectCount(); |
| 50 | 55 |
void setKinectSelected(int index); |
| 56 |
int getKinectSelected(); |
|
| 51 | 57 |
QString getKinectSerial(int index); |
| 58 |
//void stopRunningCameras(); |
|
| 59 |
//void startRunningCameras(); |
|
| 52 | 60 |
|
| 53 | 61 |
private: |
| 62 |
ConfigurationInfo mConfiguration; |
|
| 54 | 63 |
QStringList mKinectSerials; |
| 55 | 64 |
int mKinectSelected; |
| 56 | 65 |
bool captureStarted; |
| 57 | 66 |
int height, width; |
| 58 |
pcl::Grabber* interfaceKinect; |
|
| 59 |
PointCloud<PointXYZRGB> mPointCloud; |
|
| 60 |
void getSignal(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud); |
|
| 67 |
QList<OpenNIGrabber*> mInterfaceKinect; |
|
| 68 |
QList< PointCloud<PointXYZRGB> > mPointClouds; |
|
| 69 |
void getSignal1(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud); |
|
| 70 |
void getSignal2(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud); |
|
| 71 |
void getSignal3(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud); |
|
| 61 | 72 |
}; |
| 62 | 73 |
|
| 63 | 74 |
#endif // KINECTPCL_H |
| b/prototypes/kinectvision-qt-pcl/kinectvision.pro | ||
|---|---|---|
| 32 | 32 |
pointcloudpcl.h \ |
| 33 | 33 |
mediator.h \ |
| 34 | 34 |
commun.h \ |
| 35 |
calibrationparser.h |
|
| 35 |
calibrationparser.h \ |
|
| 36 |
configurationparser.h |
|
| 36 | 37 |
|
| 37 | 38 |
SOURCES += kinectpcl.cpp main.cpp viewer.cpp \ |
| 38 | 39 |
pointcloudpcl.cpp \ |
| 39 | 40 |
mediator.cpp \ |
| 40 |
calibrationparser.cpp |
|
| 41 |
calibrationparser.cpp \ |
|
| 42 |
configurationparser.cpp |
|
| 41 | 43 |
|
| 42 | 44 |
CONFIG += qt debug console |
| 43 | 45 |
|
| b/prototypes/kinectvision-qt-pcl/kinectvision.ui | ||
|---|---|---|
| 52 | 52 |
</size> |
| 53 | 53 |
</property> |
| 54 | 54 |
<property name="currentIndex"> |
| 55 |
<number>0</number>
|
|
| 55 |
<number>1</number>
|
|
| 56 | 56 |
</property> |
| 57 | 57 |
<widget class="QWidget" name="tabVisualization"> |
| 58 | 58 |
<attribute name="title"> |
| ... | ... | |
| 436 | 436 |
<string>Capture</string> |
| 437 | 437 |
</attribute> |
| 438 | 438 |
<layout class="QGridLayout" name="gridLayout_2"> |
| 439 |
<item row="3" column="0">
|
|
| 439 |
<item row="4" column="0">
|
|
| 440 | 440 |
<spacer name="verticalSpacer"> |
| 441 | 441 |
<property name="orientation"> |
| 442 | 442 |
<enum>Qt::Vertical</enum> |
| ... | ... | |
| 472 | 472 |
</property> |
| 473 | 473 |
</widget> |
| 474 | 474 |
</item> |
| 475 |
<item row="1" column="0"> |
|
| 476 |
<widget class="QCheckBox" name="ckContinuousShooting"> |
|
| 477 |
<property name="text"> |
|
| 478 |
<string>Continuous Shooting</string> |
|
| 479 |
</property> |
|
| 480 |
</widget> |
|
| 481 |
</item> |
|
| 482 |
<item row="2" column="0" colspan="2"> |
|
| 483 |
<widget class="QPushButton" name="bTakePicture"> |
|
| 484 |
<property name="text"> |
|
| 485 |
<string>Take Picture</string> |
|
| 486 |
</property> |
|
| 487 |
</widget> |
|
| 488 |
</item> |
|
| 489 |
<item row="3" column="0" colspan="2"> |
|
| 490 |
<widget class="QListWidget" name="listPointClouds"> |
|
| 491 |
<property name="minimumSize"> |
|
| 492 |
<size> |
|
| 493 |
<width>0</width> |
|
| 494 |
<height>200</height> |
|
| 495 |
</size> |
|
| 496 |
</property> |
|
| 497 |
<property name="maximumSize"> |
|
| 498 |
<size> |
|
| 499 |
<width>16777215</width> |
|
| 500 |
<height>500</height> |
|
| 501 |
</size> |
|
| 502 |
</property> |
|
| 503 |
</widget> |
|
| 504 |
</item> |
|
| 505 |
<item row="4" column="0"> |
|
| 506 |
<widget class="QPushButton" name="bClearPointClouds"> |
|
| 507 |
<property name="text"> |
|
| 508 |
<string>Clear</string> |
|
| 509 |
</property> |
|
| 510 |
</widget> |
|
| 511 |
</item> |
|
| 512 |
<item row="4" column="1"> |
|
| 513 |
<widget class="QPushButton" name="bLoadPointClouds"> |
|
| 514 |
<property name="text"> |
|
| 515 |
<string>Load To Viewer</string> |
|
| 516 |
</property> |
|
| 517 |
</widget> |
|
| 518 |
</item> |
|
| 475 | 519 |
</layout> |
| 476 | 520 |
</widget> |
| 477 | 521 |
</item> |
| ... | ... | |
| 481 | 525 |
<string>Camera</string> |
| 482 | 526 |
</property> |
| 483 | 527 |
<layout class="QGridLayout" name="gridLayout_4"> |
| 484 |
<item row="0" column="0">
|
|
| 528 |
<item row="1" column="0">
|
|
| 485 | 529 |
<widget class="QComboBox" name="cbCamera"/> |
| 486 | 530 |
</item> |
| 531 |
<item row="0" column="0"> |
|
| 532 |
<widget class="QCheckBox" name="ckAllCameras"> |
|
| 533 |
<property name="text"> |
|
| 534 |
<string>All Connected Cameras</string> |
|
| 535 |
</property> |
|
| 536 |
</widget> |
|
| 537 |
</item> |
|
| 487 | 538 |
</layout> |
| 488 | 539 |
</widget> |
| 489 | 540 |
</item> |
| b/prototypes/kinectvision-qt-pcl/main.cpp | ||
|---|---|---|
| 40 | 40 |
interfaceKinectVision.fViewer->setLayout(layout); |
| 41 | 41 |
|
| 42 | 42 |
PointCloudPCL *pointCloudPCL = new PointCloudPCL(); |
| 43 |
KinectPCL *kinectPCL = new KinectPCL(); |
|
| 43 |
ConfigurationParser *configurationParser = new ConfigurationParser(); |
|
| 44 |
KinectPCL *kinectPCL = new KinectPCL(configurationParser); |
|
| 44 | 45 |
CalibrationParser *calibrationParser = new CalibrationParser(); |
| 45 | 46 |
|
| 46 | 47 |
mainWindow->show(); |
| b/prototypes/kinectvision-qt-pcl/mediator.cpp | ||
|---|---|---|
| 43 | 43 |
cameraUpAxisGroup->addAction(mUI->actionCameraUpNegZAxis); |
| 44 | 44 |
cameraUpAxisGroup->addAction(mUI->actionCameraUpZAxis); |
| 45 | 45 |
|
| 46 |
for (int k=0; k<mKinectPCL->getKinectCount(); k++) {
|
|
| 47 |
mUI->cbCamera->addItem(QString("Kinect #").append(QString::number(k+1)).append(QString(" (")).append(mKinectPCL->getKinectSerial(k)).append(QString(")")));
|
|
| 48 |
} |
|
| 49 |
|
|
| 46 | 50 |
initializeConnect(); |
| 47 | 51 |
} |
| 48 | 52 |
|
| ... | ... | |
| 67 | 71 |
connect(mUI->bStartCapture, SIGNAL(clicked()), this, SLOT(startCapture())); |
| 68 | 72 |
connect(mUI->bStopCapture, SIGNAL(clicked()), this, SLOT(stopCapture())); |
| 69 | 73 |
connect(mUI->cbCamera, SIGNAL(currentIndexChanged(int)), this, SLOT(setKinectSelected(int))); |
| 74 |
connect(mUI->ckAllCameras, SIGNAL(toggled(bool)), this, SLOT(setAllCameras(bool))); |
|
| 75 |
connect(mUI->bClearPointClouds, SIGNAL(clicked()), this, SLOT(clearPointClouds())); |
|
| 70 | 76 |
|
| 71 | 77 |
//Visualization |
| 72 | 78 |
connect(mUI->ckFusion, SIGNAL(toggled(bool)), this, SLOT(setFusion(bool))); |
| ... | ... | |
| 98 | 104 |
|
| 99 | 105 |
void Mediator::quit() |
| 100 | 106 |
{
|
| 107 |
mKinectPCL->stopCaptureAllCameras(); |
|
| 101 | 108 |
mMainWindow->close(); |
| 102 | 109 |
} |
| 103 | 110 |
|
| ... | ... | |
| 159 | 166 |
|
| 160 | 167 |
void Mediator::setKinectSelected(int index) |
| 161 | 168 |
{
|
| 169 |
mKinectPCL->stopCapture(mKinectPCL->getKinectSelected()); |
|
| 162 | 170 |
mKinectPCL->setKinectSelected(index); |
| 163 | 171 |
} |
| 164 | 172 |
|
| ... | ... | |
| 294 | 302 |
mKinectPCL->startCapture(); |
| 295 | 303 |
mUI->bStartCapture->setEnabled(false); |
| 296 | 304 |
mUI->bStopCapture->setEnabled(true); |
| 297 |
//mViewer->setPointCloudPCL(mPointCloudPCL); |
|
| 298 | 305 |
mViewer->setPointCloudCaptured(true); |
| 299 | 306 |
mViewer->setKinectPCL(mKinectPCL); |
| 300 | 307 |
mViewer->startAnimation(); |
| 301 |
|
|
| 302 |
for (int k=0; k<mKinectPCL->getKinectCount(); k++) {
|
|
| 303 |
mUI->cbCamera->addItem(mKinectPCL->getKinectSerial(k)); |
|
| 304 |
} |
|
| 305 |
//mViewer->updateViewer(); |
|
| 306 | 308 |
} |
| 307 | 309 |
|
| 308 | 310 |
void Mediator::stopCapture() |
| ... | ... | |
| 312 | 314 |
mKinectPCL->stopCapture(); |
| 313 | 315 |
mUI->bStopCapture->setEnabled(false); |
| 314 | 316 |
mUI->bStartCapture->setEnabled(true); |
| 317 |
mViewer->updateGL(); |
|
| 315 | 318 |
} |
| 316 | 319 |
|
| 317 | 320 |
void Mediator::saveCalibration() |
| ... | ... | |
| 460 | 463 |
{
|
| 461 | 464 |
mViewer->updateViewer(); |
| 462 | 465 |
} |
| 466 |
|
|
| 467 |
void Mediator::setAllCameras(bool value) |
|
| 468 |
{
|
|
| 469 |
if (value) mKinectPCL->startCaptureAllCameras(); |
|
| 470 |
else {
|
|
| 471 |
mKinectPCL->stopCaptureAllCameras(); |
|
| 472 |
mKinectPCL->startCapture(); |
|
| 473 |
} |
|
| 474 |
mViewer->setAllCameras(value); |
|
| 475 |
} |
|
| 476 |
|
|
| 477 |
void Mediator::clearPointClouds() |
|
| 478 |
{
|
|
| 479 |
mUI->listPointClouds->clear(); |
|
| 480 |
} |
|
| b/prototypes/kinectvision-qt-pcl/mediator.h | ||
|---|---|---|
| 32 | 32 |
#include <pointcloudpcl.h> |
| 33 | 33 |
#include <kinectpcl.h> |
| 34 | 34 |
#include <calibrationparser.h> |
| 35 |
#include <configurationparser.h> |
|
| 35 | 36 |
|
| 36 | 37 |
using namespace std; |
| 37 | 38 |
|
| ... | ... | |
| 79 | 80 |
void updateViewer(); |
| 80 | 81 |
void startCapture(); |
| 81 | 82 |
void stopCapture(); |
| 83 |
void setAllCameras(bool value); |
|
| 84 |
void clearPointClouds(); |
|
| 82 | 85 |
|
| 83 | 86 |
//Visualization |
| 84 | 87 |
void setFusion(bool value); |
| b/prototypes/kinectvision-qt-pcl/viewer.cpp | ||
|---|---|---|
| 37 | 37 |
mPointCloudCaptured = false; |
| 38 | 38 |
mPointCloudSelected = 0; |
| 39 | 39 |
mSelectionColor = false; |
| 40 |
mAllCameras = false; |
|
| 40 | 41 |
} |
| 41 | 42 |
|
| 42 | 43 |
void Viewer::init() |
| ... | ... | |
| 96 | 97 |
glColor3f(0.0f, 1.0f, 0.0f); |
| 97 | 98 |
else*/ |
| 98 | 99 |
glColor3f(point.color.red, point.color.green, point.color.blue); |
| 99 |
glPushMatrix(); |
|
| 100 |
glPushName(p); |
|
| 100 |
/*glPushMatrix();
|
|
| 101 |
glPushName(p);*/
|
|
| 101 | 102 |
glVertex3d(point.position.x, point.position.y, point.position.z); |
| 102 | 103 |
//GLUquadricObj *quadratic; |
| 103 | 104 |
//gluSphere(); |
| 104 |
glPopName(); |
|
| 105 |
glPopMatrix(); |
|
| 105 |
/*glPopName();
|
|
| 106 |
glPopMatrix();*/
|
|
| 106 | 107 |
} |
| 107 | 108 |
//glTranslated(mPointCloudPCL->getPointCloud(mPointCloudSelected).calibration.rotX, mPointCloudPCL->getPointCloud(mPointCloudSelected).calibration.rotY, mPointCloudPCL->getPointCloud(mPointCloudSelected).calibration.rotZ); |
| 108 | 109 |
} |
| ... | ... | |
| 110 | 111 |
glEnd(); |
| 111 | 112 |
} |
| 112 | 113 |
else if (mPointCloudCaptured) {
|
| 113 |
if (mKinectPCL->isPointCloudCaptured()) {
|
|
| 114 |
//std::cout << "TEST!" << std::endl; |
|
| 115 |
PointCloud<PointXYZRGB> pointCloud = mKinectPCL->getPointCloud(); |
|
| 116 |
glBegin(GL_POINTS); |
|
| 117 |
{
|
|
| 118 |
for (int p=0; p<pointCloud.points.size(); p++) {
|
|
| 119 |
PointXYZRGB point = pointCloud.points.at(p); |
|
| 120 |
glColor3f((int)point.r/255.0, (int)point.g/255.0, (int)point.b/255.0); |
|
| 121 |
glVertex3d(point.x, point.y, point.z); |
|
| 114 |
if (mAllCameras) {
|
|
| 115 |
for (int c=0; c<mKinectPCL->getKinectCount(); c++) {
|
|
| 116 |
if (mKinectPCL->isPointCloudCaptured(c)) {
|
|
| 117 |
glPointSize(mPointSize); |
|
| 118 |
PointCloud<PointXYZRGB> pointCloud = mKinectPCL->getPointCloud(c); |
|
| 119 |
glBegin(GL_POINTS); |
|
| 120 |
{
|
|
| 121 |
for (int p=0; p<pointCloud.points.size(); p++) {
|
|
| 122 |
PointXYZRGB point = pointCloud.points.at(p); |
|
| 123 |
glColor3f((int)point.r/255.0, (int)point.g/255.0, (int)point.b/255.0); |
|
| 124 |
glVertex3d(point.x, point.y, point.z); |
|
| 125 |
} |
|
| 126 |
} |
|
| 127 |
glEnd(); |
|
| 128 |
} |
|
| 129 |
} |
|
| 130 |
} |
|
| 131 |
else {
|
|
| 132 |
int kinectSelected = mKinectPCL->getKinectSelected(); |
|
| 133 |
if (mKinectPCL->isPointCloudCaptured(kinectSelected)) {
|
|
| 134 |
glPointSize(mPointSize); |
|
| 135 |
PointCloud<PointXYZRGB> pointCloud = mKinectPCL->getPointCloud(kinectSelected); |
|
| 136 |
glBegin(GL_POINTS); |
|
| 137 |
{
|
|
| 138 |
for (int p=0; p<pointCloud.points.size(); p++) {
|
|
| 139 |
PointXYZRGB point = pointCloud.points.at(p); |
|
| 140 |
glColor3f((int)point.r/255.0, (int)point.g/255.0, (int)point.b/255.0); |
|
| 141 |
glVertex3d(point.x, point.y, point.z); |
|
| 142 |
} |
|
| 122 | 143 |
} |
| 144 |
glEnd(); |
|
| 123 | 145 |
} |
| 124 |
glEnd(); |
|
| 125 | 146 |
} |
| 126 | 147 |
} |
| 127 | 148 |
} |
| ... | ... | |
| 246 | 267 |
{
|
| 247 | 268 |
mKinectPCL = kinectPCL; |
| 248 | 269 |
} |
| 270 |
|
|
| 271 |
void Viewer::setAllCameras(bool value) |
|
| 272 |
{
|
|
| 273 |
mAllCameras = value; |
|
| 274 |
} |
|
| b/prototypes/kinectvision-qt-pcl/viewer.h | ||
|---|---|---|
| 39 | 39 |
Vec mUpInitCamera; |
| 40 | 40 |
bool mPointCloudLoaded; |
| 41 | 41 |
bool mPointCloudCaptured; |
| 42 |
bool mAllCameras; |
|
| 42 | 43 |
bool mSelectionColor; |
| 43 | 44 |
int mPointCloudSelected; |
| 44 | 45 |
Vec mSelectedPoint; |
| ... | ... | |
| 69 | 70 |
void setFileLoaded(bool value); |
| 70 | 71 |
void setPointCloudCaptured(bool value); |
| 71 | 72 |
void setCameraUpAxis(int axis); |
| 73 |
void setAllCameras(bool value); |
|
| 72 | 74 |
void updateViewer(); |
| 73 | 75 |
}; |
| 74 | 76 |
|
Also available in: Unified diff