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()));
52 connect(_maskEditor, SIGNAL(arrowDrawn(
const QPoint&,
const QPoint&)),
this, SLOT(arrowDrawn(
const QPoint&,
const QPoint&)));
54 connect(_widget.spinBoxPenWidth, SIGNAL(valueChanged(
int)), _maskEditor, SLOT(setPenWidth(
int)));
55 connect(_widget.spinBoxPenAlpha, SIGNAL(valueChanged(
int)), _maskEditor, SLOT(setMaskAlpha(
int)));
56 connect(_widget.pushButtonClear, SIGNAL(clicked()), _maskEditor, SLOT(clearMaskImage()));
58 connect(_widget.spinBoxImageIndex, SIGNAL(valueChanged(
int)),
this, SLOT(imageIndexChanged(
int)));
59 connect(_widget.checkBoxErase, SIGNAL(clicked()),
this, SLOT(updatePenColor()));
72 _dialog->addProxyFinder<visionx::ImageProviderInterfacePrx>({
"ImageProvider",
"ImageProvider",
"Image*|*Provider"});
74 return qobject_cast<SimpleConfigDialog*>(_dialog);
84 _imageProviderName = _dialog->getProxyName(
"ImageProvider");
89 _imageProviderName = settings->value(
"_imageProviderName",
"OpenNIPointCloudProvider").toString().toStdString();
94 settings->setValue(
"_imageProviderName", QString::fromStdString(_imageProviderName));
99 if (!_providerImagesOwner.empty())
104 _imageProvider = _imageProviderInfo.
proxy;
108 _providerImagesOwner.reserve(_imageProviderInfo.
numberImages);
109 _providerImages.reserve(_imageProviderInfo.
numberImages);
110 for (
int i = 0; i < _imageProviderInfo.
numberImages; ++i)
113 _providerImages.emplace_back(
static_cast<void*
>(_providerImagesOwner.back()->pixels));
120 _imageProviderReferenceFrame =
"Global";
121 auto frameprov = visionx::ReferenceFrameInterfacePrx::checkedCast(_imageProvider);
124 _imageProviderReferenceFrame = frameprov->getReferenceFrame();
128 _imageProviderAreImagesUndistorted =
true;
130 auto mcalibprov = visionx::MonocularCalibrationCapturingProviderInterfacePrx::checkedCast(_imageProvider);
131 auto scalibprov = visionx::StereoCalibrationInterfacePrx::checkedCast(_imageProvider);
134 _imageProviderCalibration = scalibprov->getStereoCalibration();
135 _imageProviderAreImagesUndistorted = scalibprov->getImagesAreUndistorted();
139 ARMARX_WARNING <<
"only monoocular upstream calibration! duplicating it and using identity matices";
140 auto mono = mcalibprov->getCalibration();
141 _imageProviderCalibration.calibrationLeft = mono;
142 _imageProviderCalibration.calibrationRight = mono;
143 _imageProviderCalibration.rectificationHomographyLeft = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
144 _imageProviderCalibration.rectificationHomographyRight = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
146 _imageProviderAreImagesUndistorted =
true;
150 ARMARX_WARNING <<
"no upstream calibration! using default values";
151 _imageProviderCalibration.calibrationLeft.cameraParam.distortion = {0, 0};
152 _imageProviderCalibration.calibrationLeft.cameraParam.focalLength = {50, 50};
153 _imageProviderCalibration.calibrationLeft.cameraParam.height = _imageProviderInfo.
imageFormat.dimension.height;
154 _imageProviderCalibration.calibrationLeft.cameraParam.width = _imageProviderInfo.
imageFormat.dimension.width;
155 _imageProviderCalibration.calibrationLeft.cameraParam.principalPoint =
157 _imageProviderInfo.
imageFormat.dimension.width / 2.f,
158 _imageProviderInfo.
imageFormat.dimension.height / 2.f
160 _imageProviderCalibration.calibrationLeft.cameraParam.rotation = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
161 _imageProviderCalibration.calibrationLeft.cameraParam.translation = {0, 0, 0};
163 _imageProviderCalibration.calibrationRight = _imageProviderCalibration.calibrationLeft;
164 _imageProviderCalibration.rectificationHomographyLeft = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
165 _imageProviderCalibration.rectificationHomographyRight = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
177 const CByteImage& img = *(_providerImagesOwner.at(_imageIndex));
179 std::lock_guard<std::mutex> guard {_currentImageMutex};
180 _currentImage = QImage(img.width, img.height, QImage::Format_RGB888);
183 std::memcpy(_currentImage.bits(), img.pixels, 3 * img.width * img.height);
184 _currentImageDirty =
true;
191 _widget.spinBoxImageIndex->setMaximum(
std::max(1, _numberOfImages.load()) - 1);
192 if (!_currentImageDirty)
197 std::lock_guard<std::mutex> guard {_currentImageMutex};
199 _currentImageDirty =
false;
205 auto ptr = _resultImage.get();
212 return "VisionX.ImageMaskPainter";
215 void ImageMaskPainterWidgetController::updatePenColor()
217 auto color = _widget.checkBoxErase->isChecked() ? _maskEditor->
transparentColor() : QColor(0, 0, 255);
221 void ImageMaskPainterWidgetController::imageIndexChanged(
int i)
223 _imageIndex = _widget.spinBoxImageIndex->value();
226 void ImageMaskPainterWidgetController::maskUpdated()
234 if (sz.width() != _resultImage->width || sz.height() != _resultImage->height)
246 for (
int x = 0; x < _resultImage->width; ++x)
248 for (
int y = 0; y < _resultImage->height; ++y)
250 int offset = (x + y * _resultImage->width) * 3;
255 _resultImage->pixels[offset + 0] = color.red();
256 _resultImage->pixels[offset + 1] = color.green();
257 _resultImage->pixels[offset + 2] = color.blue();