28 #include <VisionX/interface/core/DataTypes.h>
29 #include <VisionX/interface/components/PointCloudAndImageAndCalibrationProviderInterface.h>
46 #include "Calibration/Calibration.h"
52 : resultImagesEnabled(true)
53 , imagesAreUndistorted(false)
54 , numberOfResultImages(2)
74 resultImagesEnabled = getProperty<bool>(
"EnableResultImages").getValue();
76 useResultImageMask = getProperty<bool>(
"useResultImageMask").getValue();
77 colorMask = getProperty<Eigen::Vector3i>(
"colorMask").getValue();
82 usingTopic(getProperty<std::string>(
"CalibrationUpdateTopicName").getValue());
85 imageNoiseLeft(0) = imageNoiseLeft(1) = getProperty<float>(
"2DLocalizationNoise").getValue();
86 imageNoiseRight(0) = imageNoiseRight(1) = getProperty<float>(
"2DLocalizationNoise").getValue();
102 StereoCalibrationInterfacePrx calibrationProvider = StereoCalibrationInterfacePrx::checkedCast(imageProviderPrx);
104 if (calibrationProvider)
107 imagesAreUndistorted = calibrationProvider->getImagesAreUndistorted();
113 ARMARX_ERROR <<
"Unable to get calibration data. The image provider is not a StereoCalibrationProvider";
117 if (resultImagesEnabled)
123 setupImages(imageFormat.dimension.width, imageFormat.dimension.height);
128 void ObjectLocalizerProcessor::initObjectClasses()
134 classesSegmentPrx = priorKnowledgePrx->getObjectClassesSegment();
135 databasePrx = priorKnowledgePrx->getCommonStorage();
140 memoryx::CollectionInterfacePrx coll = databasePrx->requestCollection(getProperty<std::string>(
"DataBaseObjectCollectionName").getValue());
141 classesSegmentPrx->addReadCollection(coll);
144 memoryx::EntityIdList idList = classesSegmentPrx->getAllEntityIds();
146 ARMARX_INFO <<
"Found " << idList.size() <<
" object classes in the class segments: " << classesSegmentPrx->getReadCollectionsNS();
150 for (memoryx::EntityIdList::iterator iter = idList.begin(); iter != idList.end(); iter++)
152 memoryx::EntityPtr entity = memoryx::EntityPtr::dynamicCast(classesSegmentPrx->getEntityById(*iter));
162 if (recognitionWrapper->getRecognitionMethod() ==
getName())
166 std::string className = entity->getName();
180 memoryx::ObjectLocalizationResultList result;
185 job.
start(objectClassNames);
188 catch (std::exception& e)
206 Eigen::MatrixXd combinedNoise(4, 4);
207 combinedNoise.setZero();
208 combinedNoise(0, 0) = imageNoiseLeft(0);
209 combinedNoise(1, 1) = imageNoiseLeft(1);
210 combinedNoise(2, 2) = imageNoiseRight(0);
211 combinedNoise(3, 3) = imageNoiseRight(1);
213 Eigen::VectorXd
mean(4);
214 mean << left_point.x, left_point.y, right_point.x, right_point.y;
226 Eigen::VectorXd base(4);
227 Eigen::VectorXd world(4);
229 Eigen::MatrixXd processedpoints(3, sigmapoints.cols());
231 for (
int n = 0 ; n < sigmapoints.cols() ; n++)
234 Math2d::SetVec(l, sigmapoints(0, n), sigmapoints(1, n));
235 Math2d::SetVec(r, sigmapoints(2, n), sigmapoints(3, n));
238 stereoCalibration->Calculate3DPoint(l, r, w,
true,
true);
239 world << w.x, w.y, w.z, 1.0f;
241 processedpoints(0, n) = world(0);
242 processedpoints(1, n) = world(1);
243 processedpoints(2, n) = world(2);
258 Vec2d left2d, right2d;
260 Math3d::SetVec(pos, position(0), position(1), position(2));
266 Mat3d inverseHLeft, inverseHRight;
269 Math2d::ApplyHomography(inverseHLeft, left2d, left2d);
270 Math2d::ApplyHomography(inverseHRight, right2d, right2d);
276 void ObjectLocalizerProcessor::setupImages(
int width,
int height)
282 cameraImage.Set(width, height, CByteImage::eRGB24);
287 resultImagesData.replace(i,
new CByteImage(width, height, CByteImage::eRGB24));