Ask Your Question

Problem with push_back

asked 2017-12-19 13:00:30 -0600

i32romer gravatar image

updated 2017-12-19 16:58:57 -0600

berak gravatar image

if (tecla==102) cap >> frame;

        if (tecla==32 and capturado==true)
            //Aqui calculo los objectPoints
            for (int t=0; t<6; ++t)
                for (int e=0; e<5; ++e)

            //Aqui calculamos cada objectPoints para cada imagen procesada.
            for (int n=0; n<total_img.size(); n++)
                arrayObjectPoints[n].push_back( objectPoints );





This is my code. The problem is, where do push_back in line arrayObjectPoints[n].push_back( objectPoints ); The error is this.

i32romer@BIBSL016:~/Desktop/FSIV/Practica 5$ make 
Scanning dependencies of target prueba

[ 50%] Building CXX object CMakeFiles/prueba.dir/prueba.cpp.o
/home/i32romer/Desktop/FSIV/Practica 5/prueba.cpp: En la función ‘int main(int, char**)’:
/home/i32romer/Desktop/FSIV/Practica 5/prueba.cpp:175:50: error: no se encontró una función coincidente para la llamada a ‘std::vector<cv::Vec<float, 3> >::push_back(std::vector<cv::Point3_<float> >&)’
     arrayObjectPoints[n].push_back( objectPoints );
In file included from /usr/local/opt/gcc-5.3.0-32/include/c++/5.3.0/vector:64:0,
                 from /usr/local/include/opencv2/core/types.hpp:53,
                 from /usr/local/include/opencv2/core.hpp:58,
                 from /usr/local/include/opencv2/core/core.hpp:48,
                 from /home/i32romer/Desktop/FSIV/Practica 5/prueba.cpp:8:
/usr/local/opt/gcc-5.3.0-32/include/c++/5.3.0/bits/stl_vector.h:913:7: nota: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = cv::Vec<float, 3>; _Alloc = std::allocator<cv::Vec<float, 3> >; std::vector<_Tp, _Alloc>::value_type = cv::Vec<float, 3>]
       push_back(const value_type& __x)
/usr/local/opt/gcc-5.3.0-32/include/c++/5.3.0/bits/stl_vector.h:913:7: nota:   no hay una conversión conocida para el argumento 1 de ‘std::vector<cv::Point3_<float> >’ a ‘const value_type& {aka const cv::Vec<float, 3>&}’
CMakeFiles/prueba.dir/build.make:62: fallo en las instrucciones para el objetivo 'CMakeFiles/prueba.dir/prueba.cpp.o'
make[2]: *** [CMakeFiles/prueba.dir/prueba.cpp.o] Error 1
CMakeFiles/Makefile2:67: fallo en las instrucciones para el objetivo 'CMakeFiles/prueba.dir/all'
make[1]: *** [CMakeFiles/prueba.dir/all] Error 2
Makefile:83: fallo en las instrucciones para el objetivo 'all'
make: *** [all] Error 2
i32romer@BIBSL016:~/Desktop/FSIV/Practica 5$
edit retag flag offensive close merge delete


pro tip: NEVER use your native language for variable names, or comments. also, translate any error messages to english, before posting.

berak gravatar imageberak ( 2017-12-19 13:07:03 -0600 )edit

Adding to what berak said, next time just post the portion of your program with the problem. Dumping your entire program; especially if it is this long, is a great way to discourage people from helping.

eshirima gravatar imageeshirima ( 2017-12-19 13:18:33 -0600 )edit

1 answer

Sort by » oldest newest most voted

answered 2020-01-28 02:18:13 -0600

h22 gravatar image

You are trying to add the item of the wrong type to the collection.

For your code to work, arrayObjectPoints must be a 2D array or vector of elements having the same type as objectPoints (once you reference it by n, then assume the referenced element is still a collection).

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-12-19 13:00:30 -0600

Seen: 370 times

Last updated: Jan 28 '20