2016-07-29 07:52:23 -0600 asked a question OpenCV Projection Matrix Choice Hi, I am currently facing a problem, to depict you what my programm does and should do, here is the copy/paste of the beginning of a previous post I've made. This program lies on the classic "structure from motion" method. The basic idea is to take a pair of images, detect their keypoints and compute the descriptors of those keypoints. Then, the keypoints matching is done, with a certain number of tests to insure the result is good. That part works perfectly. Once this is done, the following computations are performed : fundamental matrix, essential matrix, SVD decomposition of the essential matrix, camera projection matrices computation and finally, triangulation. The result for a pair of images is a set of 3D coordinates, giving us points to be drawn in a 3D viewer. This works perfectly, for a pair. However, I have to perform a step manually, and this is not acceptable if I want my program to efficiently work with more than two images. Indeed, I compute my projection matrices according the classic method, as follows, at paragraph "Determining R and t from E" : https://en.wikipedia.org/wiki/Essenti... I have then 4 possible solutions for my projection matrix. I think I have understood the geometrical point of view of the problem, portrayded in this Hartley and Zisserman paper extract (chapters 9.6.3 and 9.7.1) : http://www.robots.ox.ac.uk/~vgg/hzboo... Nonetheless, my question is : Given the four possible projection matrices computed and the 3D points computed by the OpenCV function triangulatePoints() (for each projection matrix), how can I elect the "true" projection matrix, automatically ? (without having to draw 4 times my points in my 3D viewer, in order to see if they are consistent) Thanks for reading. 2016-07-26 03:07:17 -0600 asked a question OpenCV Structure from Motion Reprojection Issue I am currently facing an issue with my Structure from Motion program based on OpenCv. I'm gonna try to depict you what it does, and what it is supposed to do. This program lies on the classic "structure from motion" method. The basic idea is to take a pair of images, detect their keypoints and compute the descriptors of those keypoints. Then, the keypoints matching is done, with a certain number of tests to insure the result is good. That part works perfectly. Once this is done, the following computations are performed : fundamental matrix, essential matrix, SVD decomposition of the essential matrix, camera matrix computation and finally, triangulation. The result for a pair of images is a set of 3D coordinates, giving us points to be drawn in a 3D viewer. This works perfectly, for a pair. Indeed, here is my problem : for a pair of images, the 3D points coordinates are calculated in the coordinate system of the first image of the image pair, taken as the reference image. When working with more than two images, which is the objective of my program, I have to reproject the 3D points computed in the coordinate system of the very first image, in order to get a consistent result. My question is : How do I reproject 3D points coordinate given in a camera related system, into an other camera related system ? With the camera matrices ? My idea was to take the 3D point coordinates, and to multiply them by the inverse of each camera matrix before. I clarify : Suppose I am working on the third and fourth image (hence, the third pair of images, because I am working like 1-2 / 2-3 / 3-4 and so on). I get my 3D point coordinates in the coordinate system of the third image, how do I do to reproject them properly in the very first image coordinate system ? I would have done the following : Get the 3D points coordinates matrix, apply the inverse of the camera matrix for image 2 to 3, and then apply the inverse of the camera matrix for image 1 to 2. Is that even correct ? Because those camera matrices are non square matrices, and I can't inverse them. I am surely mistaking somewhere, and I would be grateful if someone could enlighten me, I am pretty sure this is a relative easy one, but I am obviously missing something... Thanks a lot for reading :) 2016-06-21 02:35:48 -0600 received badge ● Enthusiast 2016-06-10 02:52:56 -0600 asked a question Interpreting Valgrind results about a 3D reconstruction program Hi, I was running Valgrind to check memory leaks in my 3D reconstruction program, coded in C++/C and using Opencv 2.4.13. So here are some results I have trouble to interpret. ==1826== LEAK SUMMARY: ==1826== definitely lost: 0 bytes in 0 blocks ==1826== indirectly lost: 0 bytes in 0 blocks ==1826== possibly lost: 7,292 bytes in 89 blocks ==1826== still reachable: 127,593 bytes in 812 blocks ==1826== suppressed: 0 bytes in 0 blocks  First, all issues concern "possibly lost" memory, but I still want to treat them as critical issues, to ensure the quality and fiability of the programm. The two main issues I am trying to solve are the following ones : ==1826== 1,560 bytes in 3 blocks are possibly lost in loss record 259 of 264 ==1826== at 0x4C298A0: operator new[](unsigned long) (vg_replace_malloc.c:389) ==1826== by 0x82872A8: ??? (in /usr/lib/libtbb.so.2) ==1826== by 0x828755D: ??? (in /usr/lib/libtbb.so.2) ==1826== by 0x82850B4: ??? (in /usr/lib/libtbb.so.2) ==1826== by 0x8284A32: ??? (in /usr/lib/libtbb.so.2) ==1826== by 0x8282DE0: tbb::internal::allocate_root_with_context_proxy::allocate(unsigned long) const (in /usr/lib/libtbb.so.2) ==1826== by 0x5497009: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /usr/local/lib/libopencv_core.so.2.4.13) ==1826== by 0x654A511: cv::remap(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::_InputArray const&, int, int, cv::Scalar_ const&) (in /usr/local/lib/libopencv_imgproc.so.2.4.13) ==1826== by 0x6440B3A: cv::undistort(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&) (in /usr/local/lib/libopencv_imgproc.so.2.4.13) ==1826== by 0x411CF9: cFeaturesMatcher::distorsion() (in /home/qmenard/StructureFromMotion/bin/Sfm) ==1826== by 0x403A8A: main (in /home/qmenard/StructureFromMotion/bin/Sfm) ==1826== 704 bytes in 2 blocks are possibly lost in loss record 255 of 264 ==1826== at 0x4C2AD10: calloc (vg_replace_malloc.c:623) ==1826== by 0x4010F91: allocate_dtv (dl-tls.c:296) ==1826== by 0x401169D: _dl_allocate_tls (dl-tls.c:460) ==1826== by 0x9531C27: allocate_stack (allocatestack.c:589) ==1826== by 0x9531C27: pthread_create@@GLIBC_2.2.5 (pthread_create.c:495) ==1826== by 0x8281460: ??? (in /usr/lib/libtbb.so.2) ==1826== by 0x82893C9: ??? (in /usr/lib/libtbb.so.2) ==1826== by 0x5496A8C: tbb::interface6::internal::start_for, (anonymous namespace)::ProxyLoopBody, tbb::auto_partitioner const>::execute() (in /usr/local/lib/libopencv_core.so.2.4.13) ==1826== by 0x828B24B: ??? (in /usr/lib/libtbb.so.2) ==1826== by 0x82895CF: ??? (in /usr/lib/libtbb.so.2) ==1826== by 0x5497061: cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double) (in /usr/local/lib/libopencv_core.so.2.4.13) ==1826== by 0x657BAF6: cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int) (in /usr/local/lib/libopencv_imgproc.so.2.4.13) ==1826== by 0x6E481B5: cv::SURF::operator()(cv::_InputArray const&, cv::_InputArray const&, std::vector >&, cv::_OutputArray const&, bool) const (in /usr/local/lib/libopencv_nonfree.so.2.4.13)  That's why I was wondering : do I have to ...