我使用'+'按钮在'updateAttribute'处理器中添加了一些自定义属性。例如:我声明了一个属性'DBConnectionURL'并将值赋予'jdbc:mysql:// localhost:3306 / test'。然后,在“DBCPConnectionPool”服务控制器中,我简单地将值“$ {DBConnectionURL}”用于“数据库连接URL”属性。但是,我手动给出了'DBConnectionURL'属性的值。我想要一种可以从文件中动态提供值的方法,这样我只需要更改文件中的值,并且'DBConnectionURL'的值会动态更改在文件中存在的值。有办法吗?
答案 0 :(得分:2)
Rishab,
你必须使用nifi变量注册表。
在conf / nifi.properties中,您可以在其中配置以下配置,以动态更新数据流中的值。
// Focal lenght in pixel for x and y is needed for the camera matrix
double fx = img.getHeight() * img.getMetaDouble(Exif::FOCAL_LENGTH_35MM) / 24.;
// Principle point of the camera
double center_x = 1931.3;
double center_y = 1336.9;
// Creation of the camera matrix
cv::Mat camMatrix = (cv::Mat_<double>(3, 3) <<
fx, 0, center_x,
0, fx, center_y,
0, 0, 1);
// worldPoints are in arbitrary coordinate system.
std::vector<cv::Point3d> worldPoints;
worldPoints.push_back(cv::Point3d(-target.width_mm / 2., -target.heigth_mm / 2., 0));
worldPoints.push_back(cv::Point3d(target.width_mm / 2., -target.heigth_mm / 2., 0));
worldPoints.push_back(cv::Point3d(target.width_mm / 2., target.heigth_mm / 2., 0));
worldPoints.push_back(cv::Point3d(-target.width_mm / 2., target.heigth_mm / 2., 0));
// imagePoints are the detected marker in the image
std::vector<cv::Point2d> imagePoints;
imagePoints.push_back(cv::Point2d(targetInImage.top_left.getX(), chartInImage.top_left.getY()));
imagePoints.push_back(cv::Point2d(targetInImage.top_right.getX(), chartInImage.top_right.getY()));
imagePoints.push_back(cv::Point2d(targetInImage.bottom_right.getX(), chartInImage.bottom_right.getY()));
imagePoints.push_back(cv::Point2d(targetInImage.bottom_left.getX(), chartInImage.bottom_left.getY()));
cv::Mat rVec, tVec;
// Solve for pose of object in image
cv::solvePnP(worldPoints, imagePoints, camMatrix, cv::noArray(), rVec, tVec);
cv::Mat rotationMatrix;
cv::Rodrigues(rVec, rotationMatrix);
rotationMatrix = rotationMatrix.t();
tVec = -rotationMatrix * tVec;
double* _r = rotationMatrix.ptr<double>();
double projMatrix[12] = {_r[0], _r[1], _r[2], 0,
_r[3], _r[4], _r[5], 0,
_r[6], _r[7], _r[8], 0
};
cv::decomposeProjectionMatrix(cv::Mat(3, 4, CV_64FC1, projMatrix),
cameraMatrix,
rotMatrix,
transVect,
rotMatrixX,
rotMatrixY,
rotMatrixZ,
eulerAngles);
// Allocate single results
double x = tVec.at<double>(2, 0);
double y = tVec.at<double>(0, 0);
double z = tVec.at<double>(1, 0);
double roll = eulerAngles[2];
double pitch = eulerAngles[0];
double yaw = eulerAngles[1];
您可以在conf文件目录中显示该文件中的变量dynamic.properties。
例如,如果dynamic.properties文件包含以下值
nifi.variable.registry.properties=./dynamic.properties
您可以使用DBCPURL= jdbc://<host>:<port>
注意:如果更改conf / nifi.properties中的任何配置,则应重新启动nifi服务。否则,您的更改无法在数据流中使用。
如果适合你,请随时接受答案。