ImageMonitorPropertiesWidget.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::
17 * @author Kai Welke ( welke at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 
25 
26 
27 // STD/STL
28 #include <map>
29 #include <string>
30 
31 // Qt
32 #include <QApplication>
33 
34 // ArmarXGui
36 
37 
38 using namespace armarx;
39 
40 
41 namespace visionx
42 {
43  ImageMonitorPropertiesWidget::ImageMonitorPropertiesWidget()
44  {
45  ui.setupUi(this);
47  proxyFinder->setSearchMask("*Provider|*Result");
48  ui.horizontalLayout->addWidget(proxyFinder);
49 
50  connect(proxyFinder, SIGNAL(validProxySelected(QString)), this, SLOT(onValidProxySelected(QString)));
51  connect(ui.spinBoxDepthImageIndex, SIGNAL(valueChanged(int)), this, SLOT(refreshRecordingWidgets()));
52  connect(ui.comboBoxCompressionType, SIGNAL(currentIndexChanged(int)), this, SLOT(compressionTypeChanged(int)));
53 
54  // Initialise options for frame rate dropdown
55  this->ui.comboBoxFrameRate->addItem("Source framerate", -1);
56  for (unsigned int i = 30; i > 0; i -= 5)
57  {
58  this->ui.comboBoxFrameRate->addItem(QString::number(i) + " fps", static_cast<int>(i));
59  }
60  this->ui.comboBoxFrameRate->addItem("1 fps", 1);
61 
62  QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
63  this->setSizePolicy(sizePolicy);
64  }
65 
66  ImageMonitorPropertiesWidget::~ImageMonitorPropertiesWidget()
67  {
68  // pass
69  }
70 
72  {
73  this->iceManager = iceManager;
74  proxyFinder->setIceManager(iceManager, proxyFinder->getSelectedProxyName().isEmpty());
75  proxyFinder->setDefaultSelectedProxy(QString::fromStdString(properties.providerName));
76 
77  // select framerate
78  this->ui.comboBoxFrameRate->setCurrentIndex(this->ui.comboBoxFrameRate->findData(properties.frameRate));
79 
80  ui.doubleSpinBoxBufferFps->setValue(static_cast<double>(properties.bufferFps));
81  ui.spinBoxImageBuffer->setValue(properties.imageBufferSize);
82 
83  QStringList l;
84  for (auto number : properties.imagesToShow)
85  {
86  l << QString::number(number);
87  }
88  ui.lineEditImagesToShow->setText(l.join(","));
89 
90  ui.spinBoxMaxDepth->setValue(properties.maxDepthmm);
91  ui.spinBoxDepthImageIndex->setValue(properties.depthImageIndex);
92 
93  ui.comboBoxCompressionType->setCurrentIndex((int)properties.compressionType);
94  // compressionTypeChanged((int)properties.compressionType);
95  ui.spinBoxCompressionQuality->setValue(properties.compressionQuality);
96  }
97 
98  ImageMonitorProperties ImageMonitorPropertiesWidget::getProperties()
99  {
100  ImageMonitorProperties properties;
101 
102  // retrieve provider name
103  QString text = proxyFinder->getSelectedProxyName();
104  std::string providerName = text.toStdString();
105  properties.providerName = providerName;
106 
107  // set framerate
108  properties.frameRate = this->ui.comboBoxFrameRate->itemData(this->ui.comboBoxFrameRate->currentIndex()).toInt();
109 
110  // buffer properties
111  properties.imageBufferSize = ui.spinBoxImageBuffer->value();
112  properties.bufferFps = static_cast<float>(ui.doubleSpinBoxBufferFps->value());
113  QStringList list = ui.lineEditImagesToShow->text().split(",");
114 
115  for (QString& s : list)
116  {
117  bool ok;
118  auto value = s.toULong(&ok);
119  if (ok)
120  {
121  properties.imagesToShow.insert(value);
122  }
123  }
124  for (auto i : properties.imagesToShow)
125  {
126  ARMARX_INFO_S << i;
127  }
128  properties.depthImageIndex = ui.spinBoxDepthImageIndex->value();
129  properties.maxDepthmm = ui.spinBoxMaxDepth->value();
130 
131  properties.compressionType = static_cast<CompressionType>(ui.comboBoxCompressionType->currentIndex());
132  properties.compressionQuality = ui.spinBoxCompressionQuality->value();
133 
134  return properties;
135  }
136 
137  void
138  ImageMonitorPropertiesWidget::onValidProxySelected(const QString& proxyName)
139  {
140  try
141  {
142  // Try to get the object proxy "objPrx" represented by "proxyName"
143  IceGrid::AdminPrx admin = this->iceManager->getIceGridSession()->getAdmin();
144  Ice::Identity objectIceId = Ice::stringToIdentity(proxyName.toStdString());
145  visionx::ImageProviderInterfacePrx imageProviderPrx = visionx::ImageProviderInterfacePrx::checkedCast(admin->getObjectInfo(objectIceId).proxy);
146  unsigned int numImages = static_cast<unsigned int>(imageProviderPrx->getNumberImages());
147  this->numImageSources = numImages;
148  }
149  catch (...)
150  {
151  // pass
152  }
153  }
154 
155  void ImageMonitorPropertiesWidget::compressionTypeChanged(int index)
156  {
157  ui.spinBoxCompressionQuality->setEnabled(index != 0);
158  if (index == 1)
159  {
160  ui.spinBoxCompressionQuality->setValue(9);
161  }
162  else if (index == 2)
163  {
164  ui.spinBoxCompressionQuality->setValue(95);
165  }
166  }
167 }
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
index
uint8_t index
Definition: EtherCATFrame.h:59
list
list(APPEND SOURCES ${QT_RESOURCES}) set(COMPONENT_LIBS ArmarXGui ArmarXCoreObservers ArmarXCoreEigen3Variants PlotterController $
Definition: CMakeLists.txt:49
visionx::ImageMonitorProperties::maxDepthmm
int maxDepthmm
Definition: ImageMonitorWidgetController.h:104
visionx::ImageMonitorProperties::imageBufferSize
int imageBufferSize
Definition: ImageMonitorWidgetController.h:97
visionx::ImageMonitorProperties::depthImageIndex
int depthImageIndex
Definition: ImageMonitorWidgetController.h:103
visionx::imrecman::ok
@ ok
Definition: ImageRecordingManagerInterface.ice:46
visionx::ImageMonitorProperties::imagesToShow
std::set< size_t > imagesToShow
Definition: ImageMonitorWidgetController.h:99
visionx::ImageMonitorProperties::frameRate
int frameRate
Definition: ImageMonitorWidgetController.h:95
ImageMonitorPropertiesWidget.h
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
IceProxyFinder.h
visionx::ImageMonitorProperties::providerName
std::string providerName
Definition: ImageMonitorWidgetController.h:94
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:67
IceUtil::Handle< IceManager >
armarx::IceProxyFinder< ImageProviderInterfacePrx >
visionx::ImageMonitorProperties
ImageMonitorProperties brief one line description.
Definition: ImageMonitorWidgetController.h:88
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:195
visionx::ImageMonitorProperties::bufferFps
float bufferFps
Definition: ImageMonitorWidgetController.h:98
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
visionx::ImageMonitorProperties::compressionType
CompressionType compressionType
Definition: ImageMonitorWidgetController.h:105
visionx::ImageMonitorProperties::compressionQuality
int compressionQuality
Definition: ImageMonitorWidgetController.h:106