两个字符串的最长公共子序列长度_求2个字符串的最长公共子序列和最长公共子字符串...
时间: 2024-02-13 09:05:14 浏览: 66
int threshold2 = ComputeThreshold(pyramid2[0]);
Ptr<ORB> orb1 = ORB::create(threshold1);
Ptr<ORB> orb2 = ORB::create(threshold2);
Mat descriptors1;
Mat descriptors2;
orb1->好的,我明白了。对于两个字符串的最长公共子序列问题,可以使用动态规划compute(image1, keypoints1, descriptors1);
orb2->compute(image2, keypoints2, descriptors2);
BFMatcher matcher(N算法来解决。下面是具体的步骤:
首先定义子问题。假设我们有两个字符串SORM_HAMMING);
vector<vector<DMatch>> knn_matches;
matcher.knnMatch(descriptors1, descriptors2, knn1和S2,分别长度为m和n。我们定义LCS(S1,S2)为S1和S_matches, 2);
vector<DMatch> matches1to2;
for (int i = 0; i < knn_matches2的最长公共子序列。我们可以将问题分解为比较S1[1,i]和S2.size(); i++) {
if (knn_matches[i][0].distance < 0.7 * knn_matches[i][1].[1,j]的LCS长度,其中1<=i<=m, 1<=j<=n。
接下来,我们distance) {
matches1to2.push_back(knn_matches[i][0]);
}
}
vector<int> quadtree1;
需要确定状态转移方程。我们使用c [i,j]来表示S1 [1,i]和S2 [ vector<int> quadtree2;
BuildQuadTree(keypoints1, quadtree1, 0, image1.cols - 11,j]的LCS长度。则:
当i = 0或j = 0时,c [i,j], 0, image1.rows - 1, 0);
BuildQuadTree(keypoints2, quadtree2, 0, = 0;
当S1 [i] = S2 [j]时,c [i,j] = c [i- image2.cols - 1, 0, image2.rows - 1, 0);
vector<DMatch> matches;
G1,j-1] + 1;
当S1 [i]!= S2 [j]时,c [i,MSMatch(keypoints1, keypoints2, matches1to2, matches);
return 0;
}
```
阅读全文