34 #include <VisionX/interface/components/Calibration.h>
35 #include <VisionX/interface/components/OpticalFlowInterface.h>
37 #include <opencv2/opencv.hpp>
39 #include <Image/IplImageAdaptor.h>
42 #include <Eigen/Geometry>
69 defineOptionalProperty<float>(
"Framerate", 0.0,
"the framerate");
70 defineOptionalProperty<std::string>(
"providerName",
"Armar3ImageProvider",
"ImageProvider name");
71 defineOptionalProperty<OPTICAL_FLOW_METHOD>(
"Method",
Chessboard,
"use chessboard for feature tracking")
76 defineOptionalProperty<int>(
"Chessboard.Width", 7,
"Chessboard width");
77 defineOptionalProperty<int>(
"Chessboard.Height", 5,
"Chessboard height");
78 defineOptionalProperty<std::string>(
"OpticalFlowTopicName",
"OpticalFlowTopic",
"OpticalFlowTopicName name");
79 defineOptionalProperty<std::string>(
"DebugObserverName",
"DebugObserver",
"Name of the topic the DebugObserver listens on");
80 defineOptionalProperty<std::string>(
"RobotNodeSetName",
"Robot",
"Name of the RobotNodeSet");
82 defineOptionalProperty<std::string>(
"CalibrationUpdateTopicName",
"StereoCalibrationInterface",
"Topic name of the stereo calibration provider");
99 virtual public OpticalFlowInterface
107 return "OpticalFlow";
110 void reportStereoCalibrationChanged(
const visionx::StereoCalibration& stereoCalibration,
bool,
const std::string&,
const Ice::Current&
c = Ice::emptyCurrent)
override
113 std::unique_lock lock(imageMutex);
115 float f_x = stereoCalibration.calibrationRight.cameraParam.focalLength[0];
116 float f_y = stereoCalibration.calibrationRight.cameraParam.focalLength[1];
118 unitFactorX = 2.0 * std::atan(imageDimension.width / (2.0 * f_x)) / imageDimension.width;
119 unitFactorY = 2.0 * std::atan(imageDimension.height / (2.0 * f_y)) / imageDimension.height;
140 std::vector<float> removeHighestAndLowestMember(std::vector<float>&
input);
141 void drawDenseFlowMap(
const cv::Mat& flow, cv::Mat& cflowmap,
int step,
const cv::Scalar& color);
142 void computeAverageDenseFlow(
const cv::Mat& flow,
double&
mean,
double& rmse);
143 void ComputeOpticalFlow(cv::Mat resultImage, cv::Mat grayImage);
145 CByteImage** cameraImages;
146 std::string providerName;
147 std::mutex imageMutex;
148 cv::Mat previousImage, old2;
149 std::vector< cv::Point2f > previousFeatures;
150 visionx::ImageProviderInterfacePrx imageProviderPrx;
151 OpticalFlowListenerPrx prx;
152 visionx::ImageDimension imageDimension;
154 float resultX, resultY, timeDiff;
158 int chessboardWidth, chessboardHeight;
166 float unitFactorX, unitFactorY;