0
我正在尝试使用openCV的decomposeHomographyMat
函数。我更像一个Swift的人,但为此我必须使用Objective C神秘的语言。功能的签名是使用OpenCV decomposeHomographyMat from Objective C
cv::decomposeHomographyMat(
<#InputArray H#>,
<#InputArray K#>,
<#OutputArrayOfArrays rotations#>,
<#OutputArrayOfArrays translations#>,
<#OutputArrayOfArrays normals#>
)
我有一个输入K和H都是NSArray<NSNumber*> *_Nonnull
与9个元素每个。
如何创建预期的InputArray
和OutputArrayOfArrays
,以及如何将OutputArrayOfArrays
转换回Objective C可以传递给Swift的类型?
OpenCV Error: Assertion failed (0 <= i && i < (int)vv.size()) in getMat_,
file .../opencv/modules/core/src/matrix.cpp, line 1287
的代码是:调用cv::decomposeHomographyMat
用时
===编辑===
试图广答案坠毁
+ (nullable NSArray<NSNumber*> *) decomposeHomography:(NSArray<NSNumber*> *_Nonnull) homography intrisics:(NSArray<NSNumber*> *_Nonnull) intrisics
{
cv::Mat rotations, translations, normals;
vector<vector<float> > H(3,vector<float>(3));
for (int i = 0; i<3; ++i){
for (int j = 0; j<3; ++j){
H[i][j] = [homography[i*3 + j] floatValue];
}
}
vector<vector<float> > K(3,vector<float>(3));
for (int i = 0; i<3; ++i){
for (int j = 0; j<3; ++j){
K[i][j] = [intrisics[i*3 + j] floatValue];
}
}
cv::decomposeHomographyMat(
H,
K,
rotations,
translations,
normals
);
NSLog(@"ok");
}
不幸的是它崩溃。我编辑了我的答案。 – Guig
使用'std :: vector'进行旋转,平移,法线;和H,K的作品。感谢您让我走向正确的方向 –
Guig