我目前正在尝试使用 OpenCV 重建相机姿势。对于实现,我大致遵循对极几何示例。这个想法如下:
cv::xfeatures2d::SURF::detectAndCompute()cv::DescriptorMatcher::knnMatch()cv::findEssentialMat()cv::recoverPose()作为输入数据,我使用免费提供的New Tsukuba Stereo Dataset中的一系列图片。该数据集是人工创建的一系列具有已知地面真实姿势的立体相机帧。为了测试我的实现,我估计了第 1 张和第 60 张左图以及第 1 张和第 60 张右图之间的相对姿势。两对的平移向量应指向大致相同的方向,因为两对是来自左相机和右相机的对应图片。从地面实况来看,两个姿势的旋转幅度应该大约为 7 度。不幸的是,当我运行我的实现时,我得到了以下姿势:
First pair:
-> Rotation vector: [[0.3406, 0.9054, 0.2534]]
-> Rotation angle: 10.975deg
-> Translation vector: [[-0.8103, 0.04748, -0.5841]]
Second pair:
-> Rotation vector: [[0.7907, 0.5027, 0.3494]]
-> Rotation angle: 5.24811deg
-> Translation vector: [[0.748, 0.2306, -0.6223]]
Run Code Online (Sandbox Code Playgroud)
我的结果到处都是,我不太确定出了什么问题。两次旋转都不接近 7 度,并且平移向量指向完全不同的方向。我创建了一个最小的代码示例来演示我的流程:
First pair:
-> Rotation vector: [[0.3406, 0.9054, 0.2534]]
-> Rotation angle: …Run Code Online (Sandbox Code Playgroud) c++ opencv computer-vision augmented-reality camera-calibration
我试图使用 googletest 设置 CMake C++ 项目。我对 CMake 并没有真正的经验并使用过这个指南来创建我自己的设置。
\n\n当尝试构建项目时,编译器会抛出错误:
\n\n.../test.cpp:12:5: error: \xe2\x80\x98EXPECT_THAT\xe2\x80\x99 was not declared in this scope\n EXPECT_THAT(a, ContainerEq(b));\n ^~~~~~~~~~~\n.../test.cpp:12:5: note: suggested alternative: \xe2\x80\x98EXPECT_GT\xe2\x80\x99\n EXPECT_THAT(a, ContainerEq(b));\n ^~~~~~~~~~~\n EXPECT_GT\n../test.cpp:13:31: error: \xe2\x80\x98ContainerEq\xe2\x80\x99 is not a member of \xe2\x80\x98testing\xe2\x80\x99\n EXPECT_THAT(a, ::testing::ContainerEq(b)); // doesn\'t work either\nRun Code Online (Sandbox Code Playgroud)\n\n不过 GTest 的某些部分似乎工作正常。如果我注释掉第二个测试,一切都会正常。
\n\n文件夹结构:
\n\n顶级 CMakeLists.txt
\n\ncmake_minimum_required (VERSION 3.8)\nproject (TestProject)\nenable_testing()\nadd_subdirectory(test)\nRun Code Online (Sandbox Code Playgroud)\n\n测试/CMakeLists.txt
\n\ninclude(gtest.cmake)\nadd_executable(UnitTests test.cpp)\ntarget_link_libraries(UnitTests libgtest)\nadd_test(NAME …Run Code Online (Sandbox Code Playgroud) 我一直在尝试定义一个类方法,它使用在类命名空间中声明的返回类型:
template<class T, int SIZE>
class SomeList{
public:
class SomeListIterator{
//...
};
using iterator = SomeListIterator;
iterator begin() const;
};
template<class T, int SIZE>
iterator SomeList<T,SIZE>::begin() const {
//...
}
Run Code Online (Sandbox Code Playgroud)
当我尝试编译代码时,我收到此错误:
Building file: ../SomeList.cpp
Invoking: GCC C++ Compiler
g++ -std=c++0x -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"SomeList.d" -MT"SomeList.d" -o "SomeList.o" "../SomeList.cpp"
../SomeList.cpp:17:1: error: ‘iterator’ does not name a type
iterator SomeList<T,SIZE>::begin() const {
^
make: *** [SomeList.o] Error 1
Run Code Online (Sandbox Code Playgroud)
我也尝试定义这样的方法:
template<class T, int SIZE>
SomeList::iterator SomeList<T,SIZE>::begin() const {
//... …Run Code Online (Sandbox Code Playgroud)