Erro ao instalar OpenCV 4.0.0 [RESOLVIDO]

1. Erro ao instalar OpenCV 4.0.0 [RESOLVIDO]

Luis Felipe Miranda da Silva
luisfelip80

(usa Debian)

Enviado em 18/07/2018 - 23:16h

Olá, instalei o Opencv no meu ubuntu para começar a estudar, ir fazendo algumas coisas para aprender. Usei esse tutorial para instalar : http://www.codebind.com/cpp-tutorial/install-opencv-ubuntu-cpp/
Tudo ok, tirando alguns "Fails" que vi na hora da instalação rapidamente ao decorrer das linhas. Mas ai quando fui testar, fui compilar um código teste que ele dá e me deparei com esse erro gigante, que aparentemente está ligado a erros nos arquivos instalados. Vou colocar apenas parte da mensagem de erro, ela é umas 5 vezes esse tamanho:
Erro: "
/usr/local/include/opencv2/core/mat.inl.hpp:1529:1: error: cv::Mat_<_Tp>::Mat_(int, const int*)
Mat_<_Tp>::Mat_(int _dims, const int* _sz)
^
/usr/local/include/opencv2/core/mat.inl.hpp:1522:1: error: cv::Mat_<_Tp>::Mat_(cv::Size, const _Tp&)
Mat_<_Tp>::Mat_(Size _sz, const _Tp& value)
^
/usr/local/include/opencv2/core/mat.inl.hpp:1517:1: error: cv::Mat_<_Tp>::Mat_(cv::Size)
Mat_<_Tp>::Mat_(Size _sz)
^
/usr/local/include/opencv2/core/mat.inl.hpp:1510:1: error: cv::Mat_<_Tp>::Mat_(int, int, const _Tp&)
Mat_<_Tp>::Mat_(int _rows, int _cols, const _Tp& value)
^
/usr/local/include/opencv2/core/mat.inl.hpp:1504:1: error: cv::Mat_<_Tp>::Mat_(int, int)
Mat_<_Tp>::Mat_(int _rows, int _cols)
^
/usr/local/include/opencv2/core/mat.inl.hpp:1497:1: error: cv::Mat_<_Tp>::Mat_()
Mat_<_Tp>::Mat_()
^
In file included from /usr/local/include/opencv2/core/mat.hpp:3657:0,
from /usr/local/include/opencv2/core.hpp:59,
from /usr/local/include/opencv2/highgui.hpp:46,
from main.cpp:1:
/usr/local/include/opencv2/core/mat.inl.hpp:2005:39: error: expected ‘,’ or ‘...’ before ‘&&’ token
Mat_<_Tp>& Mat_<_Tp>::operator = (Mat_&& m)
^
/usr/local/include/opencv2/core/mat.inl.hpp: In member function ‘cv::Mat_<_Tp>& cv::Mat_<_Tp>::operator=(cv::Mat_<_Tp>)’:
/usr/local/include/opencv2/core/mat.inl.hpp:2007:22: error: ‘move’ is not a member of ‘std’
Mat::operator = (std::move(m));
^
/usr/local/include/opencv2/core/mat.inl.hpp:2007:32: error: ‘m’ was not declared in this scope
Mat::operator = (std::move(m));
^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:2012:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
Mat_<_Tp>::Mat_(Mat&& m)
^
/usr/local/include/opencv2/core/mat.inl.hpp: In constructor ‘cv::Mat_<_Tp>::Mat_(cv::Mat)’:
/usr/local/include/opencv2/core/mat.inl.hpp:2016:13: error: ‘m’ was not declared in this scope
*this = m;
^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:2020:38: error: expected ‘,’ or ‘...’ before ‘&&’ token
Mat_<_Tp>& Mat_<_Tp>::operator = (Mat&& m)
^
/usr/local/include/opencv2/core/mat.inl.hpp: In member function ‘cv::Mat_<_Tp>& cv::Mat_<_Tp>::operator=(cv::Mat)’:
/usr/local/include/opencv2/core/mat.inl.hpp:2022:37: error: ‘m’ was not declared in this scope
if( traits::Type<_Tp>::value == m.type() )
^
/usr/local/include/opencv2/core/mat.inl.hpp:2024:30: error: expected primary-expression before ‘&&’ token
Mat::operator = ((Mat&&)m);
^
/usr/local/include/opencv2/core/mat.inl.hpp:2024:32: error: expected primary-expression before ‘)’ token
Mat::operator = ((Mat&&)m);
^
/usr/local/include/opencv2/core/mat.inl.hpp:2027:38: error: ‘m’ was not declared in this scope
if( traits::Depth<_Tp>::value == m.depth() )
^
/usr/local/include/opencv2/core/mat.inl.hpp:2029:30: error: expected primary-expression before ‘&&’ token
Mat::operator = ((Mat&&)m.reshape(DataType<_Tp>::channels, m.dims, 0));
^
/usr/local/include/opencv2/core/mat.inl.hpp:2029:32: error: expected primary-expression before ‘)’ token
Mat::operator = ((Mat&&)m.reshape(DataType<_Tp>::channels, m.dims, 0));
^
/usr/local/include/opencv2/core/mat.inl.hpp:2033:5: error: ‘m’ was not declared in this scope
m.convertTo(*this, type());
^
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:2038:24: error: expected ‘,’ or ‘...’ before ‘&&’ token
Mat_<_Tp>::Mat_(MatExpr&& e)
^
/usr/local/include/opencv2/core/mat.inl.hpp: In constructor ‘cv::Mat_<_Tp>::Mat_(cv::MatExpr)’:
/usr/local/include/opencv2/core/mat.inl.hpp:2042:17: error: ‘e’ was not declared in this scope
*this = Mat(e);
^
/usr/local/include/opencv2/core/mat.inl.hpp: In member function ‘void cv::UMat::assignTo(cv::UMat&, int) const’:
/usr/local/include/opencv2/core/mat.inl.hpp:3689:11: error: ambiguous overload for ‘operator=’ (operand types are ‘cv::UMat’ and ‘const cv::UMat’)
m = *this;
^
/usr/local/include/opencv2/core/mat.inl.hpp:3615:7: note: candidate: cv::UMat& cv::UMat::operator=(const cv::UMat&)
UMat& UMat::operator = (const UMat& m)
^
In file included from /usr/local/include/opencv2/core.hpp:59:0,
from /usr/local/include/opencv2/highgui.hpp:46,
from main.cpp:1:
/usr/local/include/opencv2/core/mat.hpp:2531:11: note: candidate: cv::UMat& cv::UMat::operator=(cv::UMat)
UMat& operator = (UMat&& m);
^
In file included from /usr/local/include/opencv2/core/mat.hpp:3657:0,
from /usr/local/include/opencv2/core.hpp:59,
from /usr/local/include/opencv2/highgui.hpp:46,
from main.cpp:1:
/usr/local/include/opencv2/core/mat.inl.hpp: At global scope:
/usr/local/include/opencv2/core/mat.inl.hpp:3818:16: error: expected ‘,’ or ‘...’ before ‘&&’ token
UMat::UMat(UMat&& m)
^
/usr/local/include/opencv2/core/mat.inl.hpp:3818:1: error: prototype for ‘cv::UMat::UMat(cv::UMat)’ does not match any in class ‘cv::UMat’
UMat::UMat(UMat&& m)
^
In file included from /usr/local/include/opencv2/core.hpp:59:0,
from /usr/local/include/opencv2/highgui.hpp:46,
from main.cpp:1:
/usr/local/include/opencv2/core/mat.hpp:2404:37: error: candidates are: template<class _Tp> cv::UMat::UMat(const cv::MatCommaInitializer_<_Tp>&)
template<typename _Tp> explicit UMat(const MatCommaInitializer_<_Tp>& comma
^
/usr/local/include/opencv2/core/mat.hpp:2402:37: error: template<class _Tp> cv::UMat::UMat(const cv::Point3_<_Tp>&, bool)
template<typename _Tp> explicit UMat(const Point3_<_Tp>& pt, bool copyData=
^
/usr/local/include/opencv2/core/mat.hpp:2400:37: error: template<class _Tp> cv::UMat::UMat(const cv::Point_<_Tp>&, bool)
template<typename _Tp> explicit UMat(const Point_<_Tp>& pt, bool copyData=t
^
/usr/local/include/opencv2/core/mat.hpp:2398:51: error: template<class _Tp, int m, int n> cv::UMat::UMat(const cv::Matx<_Tp, m, n>&, bool)
template<typename _Tp, int m, int n> explicit UMat(const Matx<_Tp, m, n>& m
^
/usr/local/include/opencv2/core/mat.hpp:2396:44: error: template<class _Tp, int n> cv::UMat::UMat(const cv::Vec<_Tp, m>&, bool)
template<typename _Tp, int n> explicit UMat(const Vec<_Tp, n>& vec, bool co
^
/usr/local/include/opencv2/core/mat.hpp:2393:37: error: template<class _Tp> cv::UMat::UMat(const std::vector<_Tp>&, bool)
template<typename _Tp> explicit UMat(const std::vector<_Tp>& vec, bool copy
^
/usr/local/include/opencv2/core/mat.hpp:2391:5: error: cv::UMat::UMat(const cv::UMat&, const std::vector<cv::Range>&)
UMat(const UMat& m, const std::vector<Range>& ranges);
^
/usr/local/include/opencv2/core/mat.hpp:2390:5: error: cv::UMat::UMat(const cv::UMat&, const cv::Range*)
UMat(const UMat& m, const Range* ranges);
^
/usr/local/include/opencv2/core/mat.hpp:2389:5: error: cv::UMat::UMat(const cv::UMat&, const Rect&)
UMat(const UMat& m, const Rect& roi);
^
/usr/local/include/opencv2/core/mat.hpp:2388:5: error: cv::UMat::UMat(const cv::UMat&, const cv::Range&, const cv::Range&)
UMat(const UMat& m, const Range& rowRange, const Range& colRange=Range::all
^
In file included from /usr/local/include/opencv2/core/mat.hpp:3657:0,
from /usr/local/include/opencv2/core.hpp:59,
from /usr/local/include/opencv2/highgui.hpp:46,
from main.cpp:1:
/usr/local/include/opencv2/core/mat.inl.hpp:3581:1: error: cv::UMat::UMat(const cv::UMat&)
UMat::UMat(const UMat& m)
^
/usr/local/include/opencv2/core/mat.inl.hpp:3573:1: error: cv::UMat::UMat(int, const int*, int, const Scalar&, cv::UMatUsageFlags)
UMat::UMat(int _dims, const int* _sz, int _type, const Scalar& _s, UMatUsageFla
^
/usr/local/include/opencv2/core/mat.inl.hpp:3566:1: error: cv::UMat::UMat(int, const int*, int, cv::UMatUsageFlags)
UMat::UMat(int _dims, const int* _sz, int _type, UMatUsageFlags _usageFlags)
^
/usr/local/include/opencv2/core/mat.inl.hpp:3558:1: error: cv::UMat::UMat(cv::Size, int, const Scalar&, cv::UMatUsageFlags)
UMat::UMat(Size _sz, int _type, const Scalar& _s, UMatUsageFlags _usageFlags)
^
/usr/local/include/opencv2/core/mat.inl.hpp:3543:1: error: cv::UMat::UMat(int, int, int, const Scalar&, cv::UMatUsageFlags)
UMat::UMat(int _rows, int _cols, int _type, const Scalar& _s, UMatUsageFlags _u
^
/usr/local/include/opencv2/core/mat.inl.hpp:3551:1: error: cv::UMat::UMat(cv::Size, int, cv::UMatUsageFlags)
UMat::UMat(Size _sz, int _type, UMatUsageFlags _usageFlags)
^
/usr/local/include/opencv2/core/mat.inl.hpp:3536:1: error: cv::UMat::UMat(int, int, int, cv::UMatUsageFlags)
UMat::UMat(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags)
^
/usr/local/include/opencv2/core/mat.inl.hpp:3531:1: error: cv::UMat::UMat(cv::UMatUsageFlags)
UMat::UMat(UMatUsageFlags _usageFlags)
^
/usr/local/include/opencv2/core/mat.inl.hpp:3842:29: error: expected ‘,’ or ‘...’ before ‘&&’ token
UMat& UMat::operator = (UMat&& m)
^
/usr/local/include/opencv2/core/mat.inl.hpp: In member function ‘cv::UMat& cv::UMat::operator=(cv::UMat)’:
/usr/local/include/opencv2/core/mat.inl.hpp:3844:18: error: ‘m’ was not declared in this scope
if (this == &m)
^
/usr/local/include/opencv2/core/mat.inl.hpp:3847:13: error: ‘m’ was not declared in this scope
flags = m.flags; dims = m.dims; rows = m.rows; cols = m.cols;
^
In file included from /usr/local/include/opencv2/core.hpp:3281:0,
from /usr/local/include/opencv2/highgui.hpp:46,
from main.cpp:1:
/usr/local/include/opencv2/core/utility.hpp: At global scope:
/usr/local/include/opencv2/core/utility.hpp:549:10: error: ‘function’ in namespace ‘std’ does not name a template type
std::function<void(const Range&)> m_functor;
^
/usr/local/include/opencv2/core/utility.hpp:551:48: error: expected ‘)’ before ‘<’ token
ParallelLoopBodyLambdaWrapper(std::function<void(const Range&)> functor) :
^
/usr/local/include/opencv2/core/utility.hpp: In member function ‘virtual void cv::ParallelLoopBodyLambdaWrapper::operator()(const cv::Range&) const’:
/usr/local/include/opencv2/core/utility.hpp:557:24: error: ‘m_functor’ was not declared in this scope
m_functor(range);
^
/usr/local/include/opencv2/core/utility.hpp: At global scope:
/usr/local/include/opencv2/core/utility.hpp:561:52: error: ‘std::function’ has not been declared
inline void parallel_for_(const Range& range, std::function<void(const Range&)>
^
/usr/local/include/opencv2/core/utility.hpp:561:60: error: expected ‘,’ or ‘...’ before ‘<’ token
inline void parallel_for_(const Range& range, std::function<void(const Range&)>
^
/usr/local/include/opencv2/core/utility.hpp: In function ‘void cv::parallel_for_(const cv::Range&, int)’:
/usr/local/include/opencv2/core/utility.hpp:563:56: error: ‘functor’ was not declared in this scope
parallel_for_(range, ParallelLoopBodyLambdaWrapper(functor), nstripes);
^
/usr/local/include/opencv2/core/utility.hpp:563:66: error: ‘nstripes’ was not declared in this scope
parallel_for_(range, ParallelLoopBodyLambdaWrapper(functor), nstripes);
^
/usr/local/include/opencv2/core/utility.hpp: At global scope:
/usr/local/include/opencv2/core/utility.hpp:665:14: error: ‘recursive_mutex’ in namespace ‘std’ does not name a type
typedef std::recursive_mutex Mutex;
^
/usr/local/include/opencv2/core/utility.hpp:666:14: error: ‘lock_guard’ in namespace ‘std’ does not name a template type
typedef std::lock_guard<cv::Mutex> AutoLock;
^
main.cpp: In function ‘int main(int, char**)’:
main.cpp:7:38: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
image = cv::imread("sample.jpeg" , CV_LOAD_IMAGE_COLOR);
^
In file included from /usr/local/include/opencv2/core.hpp:60:0,
from /usr/local/include/opencv2/highgui.hpp:46,
from main.cpp:1:
/usr/local/include/opencv2/core/persistence.hpp: In instantiation of ‘void cv::read(const cv::FileNode&, cv::Point_<_Tp>&, const cv::Point_<_Tp>&) [with _Tp = int]’:
/usr/local/include/opencv2/core/persistence.hpp:782:34: required from here
/usr/local/include/opencv2/core/persistence.hpp:737:11: error: ambiguous overload for ‘operator=’ (operand types are ‘cv::Point_<int>’ and ‘const cv::Point_<int>’)
value = temp.size() != 2 ? default_value : Point_<_Tp>(saturate_cast<_Tp>(t
^
In file included from /usr/local/include/opencv2/core.hpp:58:0,
from /usr/local/include/opencv2/highgui.hpp:46,
from main.cpp:1:
/usr/local/include/opencv2/core/types.hpp:1177:14: note: candidate: cv::Point_<_Tp>& cv::Point_<_Tp>::operator=(const cv::Point_<_Tp>&) [with _Tp = int]
Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt)
^
/usr/local/include/opencv2/core/types.hpp:1184:14: note: candidate: cv::Point_<_Tp>& cv::Point_<_Tp>::operator=(cv::Point_<_Tp>) [with _Tp = int; cv::Point_<_Tp> = cv::Point_<int>]
Point_<_Tp>& Point_<_Tp>::operator = (Point_&& pt) CV_NOEXCEPT
^
/usr/local/include/opencv2/core/types.hpp: In instantiation of ‘static _OI std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m(_II, _II, _OI) [with _II = const cv::KeyPoint*; _OI = cv::KeyPoint*]’:
/usr/include/c++/5/bits/stl_algobase.h:402:44: required from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = const cv::KeyPoint*; _OI = cv::KeyPoint*]’
/usr/include/c++/5/bits/stl_algobase.h:438:45: required from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = __gnu_cxx::__normal_iterator<const cv::KeyPoint*, std::vector<cv::KeyPoint> >; _OI = __gnu_cxx::__normal_iterator<cv::KeyPoint*, std::vector<cv::KeyPoint> >]’
/usr/include/c++/5/bits/stl_algobase.h:471:8: required from ‘_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<const cv::KeyPoint*, std::vector<cv::KeyPoint> >; _OI = __gnu_cxx::__normal_iterator<cv::KeyPoint*, std::vector<cv::KeyPoint> >]’
/usr/include/c++/5/bits/vector.tcc:206:31: required from ‘std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = cv::KeyPoint; _Alloc = std::allocator<cv::KeyPoint>]’
/usr/local/include/opencv2/core/persistence.hpp:1158:13: required from here
/usr/local/include/opencv2/core/types.hpp:711:27: error: ambiguous overload for ‘operator=’ (operand types are ‘cv::Point2f {aka cv::Point_<float>}’ and ‘const Point2f {aka const cv::Point_<float>}’)
class CV_EXPORTS_W_SIMPLE KeyPoint
^
In file included from /usr/local/include/opencv2/core.hpp:58:0,
from /usr/local/include/opencv2/highgui.hpp:46,
from main.cpp:1:
/usr/local/include/opencv2/core/types.hpp:170:13: note: candidate: cv::Point_<_Tp>& cv::Point_<_Tp>::operator=(const cv::Point_<_Tp>&) [with _Tp = float]
Point_& operator = (const Point_& pt);
^
/usr/local/include/opencv2/core/types.hpp:171:13: note: candidate: cv::Point_<_Tp>& cv::Point_<_Tp>::operator=(cv::Point_<_Tp>) [with _Tp = float; cv::Point_<_Tp> = cv::Point_<float>]
Point_& operator = (Point_&& pt) CV_NOEXCEPT;
^
In file included from /usr/include/c++/5/algorithm:61:0,
from /usr/local/include/opencv2/core/base.hpp:55,
from /usr/local/include/opencv2/core.hpp:54,
from /usr/local/include/opencv2/highgui.hpp:46,
from main.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:340:18: note: synthesized method ‘cv::KeyPoint& cv::KeyPoint::operator=(const cv::KeyPoint&)’ first required here
*__result = *__first;
^
"


  


2. MELHOR RESPOSTA

Paulo
paulo1205

(usa Ubuntu)

Enviado em 19/07/2018 - 21:49h

Posso estar meio cego, pois não vi entre as opções geradas pelo pkg-config algo que mande compilar em modo C++11, mas algumas das mensagens de erro se referem a recursos do padrão de 2011. Experimente colocar a opção de compilação “-std=c++11”, e veja se melhora.

3. Re: Erro ao instalar OpenCV 4.0.0 [RESOLVIDO]

Paulo
paulo1205

(usa Ubuntu)

Enviado em 19/07/2018 - 04:45h

Qual comando você usou para tentar fazer a compilação? Qual a versão do seu compilador?


4. Erro ao instalar OpenCV 4.0.0

Luis Felipe Miranda da Silva
luisfelip80

(usa Debian)

Enviado em 19/07/2018 - 13:17h

paulo1205 escreveu:

Qual comando você usou para tentar fazer a compilação? Qual a versão do seu compilador?


Oi, estou usando um compilador 5.4.0 e o comando para compilar é esse :" g++ main.cpp -o output `pkg-config --cflags --libs opencv`".


5. Re: Erro ao instalar OpenCV 4.0.0

Paulo
paulo1205

(usa Ubuntu)

Enviado em 19/07/2018 - 14:15h

E qual a saída do comando “pkg-config --cflags --libs opencv”?


6. Re: Erro ao instalar OpenCV 4.0.0 [RESOLVIDO]

Luis Felipe Miranda da Silva
luisfelip80

(usa Debian)

Enviado em 19/07/2018 - 17:08h

paulo1205 escreveu:

E qual a saída do comando “pkg-config --cflags --libs opencv”?

Essa é a saída:
-I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_superres -lopencv_videostab -lopencv_stitching -lopencv_hfs -lopencv_saliency -lopencv_fuzzy -lopencv_xfeatures2d -lopencv_shape -lopencv_xphoto -lopencv_optflow -lopencv_dpm -lopencv_ccalib -lopencv_reg -lopencv_dnn_objdetect -lopencv_stereo -lopencv_structured_light -lopencv_face -lopencv_photo -lopencv_bioinspired -lopencv_img_hash -lopencv_line_descriptor -lopencv_aruco -lopencv_xobjdetect -lopencv_objdetect -lopencv_surface_matching -lopencv_rgbd -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_ml -lopencv_ximgproc -lopencv_plot -lopencv_freetype -lopencv_bgsegm -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_flann -lopencv_phase_unwrapping -lopencv_imgproc -lopencv_core



7. Re: Erro ao instalar OpenCV 4.0.0 [RESOLVIDO]

Luis Felipe Miranda da Silva
luisfelip80

(usa Debian)

Enviado em 24/07/2018 - 09:25h

paulo1205 escreveu:

Posso estar meio cego, pois não vi entre as opções geradas pelo pkg-config algo que mande compilar em modo C++11, mas algumas das mensagens de erro se referem a recursos do padrão de 2011. Experimente colocar a opção de compilação “-std=c++11”, e veja se melhora.


Deu certo, muito obrigado!






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts