129 virtual public visionx::VisualContactDetectionInterface
138 return "VisualContactDetection";
144 armarx::FramedPoseBasePtr
getHandPose(
const Ice::Current&
c = Ice::emptyCurrent)
override;
149 visionx::FramedPositionBaseList
153 void activate(
const Ice::Current&
c = Ice::emptyCurrent)
override;
154 void deactivate(
const Ice::Current&
c = Ice::emptyCurrent)
override;
176 std::string providerName;
177 ImageProviderInterfacePrx imageProviderPrx;
178 std::string robotStateProxyName;
180 std::string handFrameName, cameraFrameName;
181 memoryx::ObjectMemoryObserverInterfacePrx objectMemoryObserver;
182 std::string handNameInMemoryX;
184 bool useHandLocalization;
186 std::mutex activationStateMutex;
187 IceUtil::Time timeOfLastExecution;
189 CStereoCalibration* stereoCalibration;
190 CByteImage** cameraImages;
191 CByteImage** resultImages;
196 *handModelVisualizer3;
197 static const bool drawComplexHandModelInResultImage =
false;
199 void calculateOpticalFlowClusters();
200 IplImage *pCamLeftIpl, *pCamLeftOldIpl;
201 CByteImage *camImgLeftGrey, *camImgLeftGreySmall, *camImgLeftGreyOld,
202 *camImgLeftGreyOldSmall, *tempImageRGB, *pSegmentedImage, *pOpticalFlowClusterImage;
204 Vec3d oldHandPosSensor;
205 std::vector<std::vector<std::vector<float>>> opticalFlowClusters;
206 float* pVisOptFlowRaw;
208 static const int imageResizeFactorForOpticalFlowCalculation = 4;
209 static const int maxNumOptFlowClusters = 5;
210 int minNumPixelsInClusterForCollisionDetection;
211 static const int clusteringSampleStep = 1;
212 static constexpr float pushDetectionBoxForwardOffsetToTCP = 150.0f;
213 float oldCollisionProbability;
215 bool detectCollision();
216 Vec2d handPos2D, pushTarget2D, pushTargetBoxLeftUpperCorner, pushTargetBoxRightLowerCorner;
218 void drawVisualization(
bool collisionDetected);
219 CByteImage *tempImageRGB1, *tempImageRGB2, *tempImageRGB3, *tempImageRGB4;
221 static const bool recordImages =
true;
222 int visualizationImageNumber;
223 std::vector<CByteImage*> cameraImagesForSaving, localizationResultImages, opticalFlowImages,
224 opticalFlowClusterImages;
225 std::vector<long> timesOfImageCapture;
227 static void extractAnglesFromRotationMatrix(
const Mat3d& mat, Vec3d& angles);
228 static IplImage* convertToIplImage(CByteImage* pByteImageRGB);
229 static void clusterXMeans(
const std::vector<std::vector<float>>& aPoints,
230 const int nMinNumClusters,
231 const int nMaxNumClusters,
232 const float fBICFactor,
233 std::vector<std::vector<std::vector<float>>>& aaPointClusters,
234 std::vector<std::vector<int>>& aaOldIndices);
236 void SetNumberInFileName(std::string& sFileName,
int nNumber,
int nNumDigits = 4);
238 VisualContactDetectionListenerPrx listener;
240 enum EResultImageIndices
250 eNumberOfResultImages