40 _widget.horizontalLayoutImageMonitors->addWidget(_maskEditor);
43 QImage bg(512, 512, QImage::Format_ARGB32);
46 _maskEditor->
setPenWidth(_widget.spinBoxPenWidth->value());
47 _maskEditor->
setMaskAlpha(_widget.spinBoxPenAlpha->value());
51 connect(_maskEditor, SIGNAL(maskUpdateFinished()),
this, SLOT(maskUpdated()));
53 SIGNAL(arrowDrawn(
const QPoint&,
const QPoint&)),
55 SLOT(arrowDrawn(
const QPoint&,
const QPoint&)));
58 _widget.spinBoxPenWidth, SIGNAL(valueChanged(
int)), _maskEditor, SLOT(setPenWidth(
int)));
60 _widget.spinBoxPenAlpha, SIGNAL(valueChanged(
int)), _maskEditor, SLOT(setMaskAlpha(
int)));
61 connect(_widget.pushButtonClear, SIGNAL(clicked()), _maskEditor, SLOT(clearMaskImage()));
64 _widget.spinBoxImageIndex, SIGNAL(valueChanged(
int)),
this, SLOT(imageIndexChanged(
int)));
65 connect(_widget.checkBoxErase, SIGNAL(clicked()),
this, SLOT(updatePenColor()));
78 _dialog->addProxyFinder<visionx::ImageProviderInterfacePrx>(
79 {
"ImageProvider",
"ImageProvider",
"Image*|*Provider"});
81 return qobject_cast<SimpleConfigDialog*>(_dialog);
93 _imageProviderName = _dialog->getProxyName(
"ImageProvider");
100 settings->value(
"_imageProviderName",
"OpenNIPointCloudProvider").toString().toStdString();
106 settings->setValue(
"_imageProviderName", QString::fromStdString(_imageProviderName));
112 if (!_providerImagesOwner.empty())
117 _imageProvider = _imageProviderInfo.
proxy;
121 _providerImagesOwner.reserve(_imageProviderInfo.
numberImages);
122 _providerImages.reserve(_imageProviderInfo.
numberImages);
123 for (
int i = 0; i < _imageProviderInfo.
numberImages; ++i)
126 _providerImages.emplace_back(
static_cast<void*
>(_providerImagesOwner.back()->pixels));
132 visionx::ImageType::eRgb,
133 _imageProviderName +
"_Mask");
136 _imageProviderReferenceFrame =
"Global";
137 auto frameprov = visionx::ReferenceFrameInterfacePrx::checkedCast(_imageProvider);
140 _imageProviderReferenceFrame = frameprov->getReferenceFrame();
144 _imageProviderAreImagesUndistorted =
true;
147 visionx::MonocularCalibrationCapturingProviderInterfacePrx::checkedCast(_imageProvider);
148 auto scalibprov = visionx::StereoCalibrationInterfacePrx::checkedCast(_imageProvider);
151 _imageProviderCalibration = scalibprov->getStereoCalibration();
152 _imageProviderAreImagesUndistorted = scalibprov->getImagesAreUndistorted();
156 ARMARX_WARNING <<
"only monoocular upstream calibration! duplicating it and using "
158 auto mono = mcalibprov->getCalibration();
159 _imageProviderCalibration.calibrationLeft = mono;
160 _imageProviderCalibration.calibrationRight = mono;
161 _imageProviderCalibration.rectificationHomographyLeft = {
162 {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
163 _imageProviderCalibration.rectificationHomographyRight = {
164 {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
166 _imageProviderAreImagesUndistorted =
true;
170 ARMARX_WARNING <<
"no upstream calibration! using default values";
171 _imageProviderCalibration.calibrationLeft.cameraParam.distortion = {0, 0};
172 _imageProviderCalibration.calibrationLeft.cameraParam.focalLength = {50, 50};
173 _imageProviderCalibration.calibrationLeft.cameraParam.height =
175 _imageProviderCalibration.calibrationLeft.cameraParam.width =
177 _imageProviderCalibration.calibrationLeft.cameraParam.principalPoint = {
178 _imageProviderInfo.
imageFormat.dimension.width / 2.f,
179 _imageProviderInfo.
imageFormat.dimension.height / 2.f};
180 _imageProviderCalibration.calibrationLeft.cameraParam.rotation = {
181 {1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
182 _imageProviderCalibration.calibrationLeft.cameraParam.translation = {0, 0, 0};
184 _imageProviderCalibration.calibrationRight = _imageProviderCalibration.calibrationLeft;
185 _imageProviderCalibration.rectificationHomographyLeft = {
186 {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
187 _imageProviderCalibration.rectificationHomographyRight = {
188 {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
201 const CByteImage& img = *(_providerImagesOwner.at(_imageIndex));
203 std::lock_guard<std::mutex> guard{_currentImageMutex};
204 _currentImage = QImage(img.width, img.height, QImage::Format_RGB888);
207 std::memcpy(_currentImage.bits(), img.pixels, 3 * img.width * img.height);
208 _currentImageDirty =
true;
216 _widget.spinBoxImageIndex->setMaximum(
std::max(1, _numberOfImages.load()) - 1);
217 if (!_currentImageDirty)
222 std::lock_guard<std::mutex> guard{_currentImageMutex};
224 _currentImageDirty =
false;
230 auto ptr = _resultImage.get();
238 return "VisionX.ImageMaskPainter";
242 ImageMaskPainterWidgetController::updatePenColor()
245 _widget.checkBoxErase->isChecked() ? _maskEditor->
transparentColor() : QColor(0, 0, 255);
250 ImageMaskPainterWidgetController::imageIndexChanged(
int i)
252 _imageIndex = _widget.spinBoxImageIndex->value();
256 ImageMaskPainterWidgetController::maskUpdated()
264 if (sz.width() != _resultImage->width || sz.height() != _resultImage->height)
276 for (
int x = 0; x < _resultImage->width; ++x)
278 for (
int y = 0; y < _resultImage->height; ++y)
280 int offset = (x + y * _resultImage->width) * 3;
281 const QColor color{mask.pixel(x, y)};
282 _resultImage->pixels[offset + 0] = color.red();
283 _resultImage->pixels[offset + 1] = color.green();
284 _resultImage->pixels[offset + 2] = color.blue();