BUILD_PACKAGE -> Prior to version 2.3 with this you could build a project that will build an OpenCV installer. With this you can easily install your OpenCV flavor on other systems. For the latest source files of OpenCV it generates a new project that simply creates zip archive with OpenCV sources.
BUILD_PERF_TESTS -> There are also performance tests for many OpenCV functions. If you’re concerned about performance, build them and run.
This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:13:2: error: incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:14:2: error: your headers. #error your headers. ^ [ 42%] Linking CXX executable ../../bin/example_snippet_imgproc_segmentation [ 42%] Built target example_snippet_imgproc_segmentation [ 42%] Building CXX object modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/grfmt_base.cpp.o [ 42%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/onnx/opencv-onnx.pb.cc.o [ 42%] Building CXX object modules/photo/CMakeFiles/opencv_photo.dir/src/calibrate.cpp.o [ 42%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/agast.cpp.o /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1037:67: error: no type named 'ConstantInitialized' in namespace 'google::protobuf::internal' explicit constexpr BlobShape(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1151:16: error: unknown type name 'ClassData' static const ClassData _class_data_; ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1152:43: error: no type named 'ClassData' in 'google::protobuf::Message' const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1032:7: warning: abstract class is marked 'final' [-Wabstract-final-class] class BlobShape final : ^ /usr/local/include/google/protobuf/message.h:237:12: note: unimplemented pure virtual method 'New' in 'BlobShape' Message* New() const override = 0; ^ In file included from /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.cc:4: /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1051:9: error: use of undeclared identifier 'GetOwningArena' if (GetOwningArena() == from.GetOwningArena() ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1051:34: error: no member named 'GetOwningArena' in 'opencv_caffe::BlobShape' if (GetOwningArena() == from.GetOwningArena() ~~~~ ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1098:9: error: use of undeclared identifier 'GetOwningArena' if (GetOwningArena() == other->GetOwningArena()) { ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1098:36: error: no member named 'GetOwningArena' in 'opencv_caffe::BlobShape' if (GetOwningArena() == other->GetOwningArena()) { ~~~~~ ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1107:19: error: use of undeclared identifier 'GetOwningArena' GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1107:46: error: no member named 'GetOwningArena' in 'opencv_caffe::BlobShape' GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); ~~~~~ ^ /usr/local/include/google/protobuf/stubs/logging.h:181:61: note: expanded from macro 'GOOGLE_DCHECK' #define GOOGLE_DCHECK(EXPRESSION) while(false) GOOGLE_CHECK(EXPRESSION) ^~~~~~~~~~ /usr/local/include/google/protobuf/stubs/logging.h:154:26: note: expanded from macro 'GOOGLE_CHECK' GOOGLE_LOG_IF(FATAL, !(EXPRESSION)) << "CHECK failed: " #EXPRESSION ": " ^~~~~~~~~~ /usr/local/include/google/protobuf/stubs/logging.h:151:5: note: expanded from macro 'GOOGLE_LOG_IF' !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL) ^~~~~~~~~ In file included from /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.cc:4: /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1204:67: error: no type named 'ConstantInitialized' in namespace 'google::protobuf::internal' explicit constexpr BlobProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1318:16: error: unknown type name 'ClassData' static const ClassData _class_data_; ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1319:43: error: no type named 'ClassData' in 'google::protobuf::Message' const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1438:3: error: unknown type name 'PROTOBUF_NODISCARD' PROTOBUF_NODISCARD std::string* release_raw_data(); ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1438:27: error: non-friend class member 'string' cannot have a qualified name PROTOBUF_NODISCARD std::string* release_raw_data(); ~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1438:33: error: expected ';' at end of declaration list PROTOBUF_NODISCARD std::string* release_raw_data(); ^ ; /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/caffe/opencv-caffe.pb.h:1453:3: error: use of undeclared identifier 'PROTOBUF_NODISCARD' PROTOBUF_NODISCARD ::opencv_caffe::BlobShape* release_shape(); ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] In file included from /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.cc:4: /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:12:2: error: This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:13:2: error: incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:14:2: error: your headers. #error your headers. ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:216:72: error: no type named 'ConstantInitialized' in namespace 'google::protobuf::internal' explicit constexpr AttributeProto(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:330:16: error: unknown type name 'ClassData' static const ClassData _class_data_; ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:331:43: error: no type named 'ClassData' in 'google::protobuf::Message' const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:517:3: error: unknown type name 'PROTOBUF_NODISCARD' PROTOBUF_NODISCARD std::string* release_name(); ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:517:27: error: non-friend class member 'string' cannot have a qualified name PROTOBUF_NODISCARD std::string* release_name(); ~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:517:33: error: expected ';' at end of declaration list PROTOBUF_NODISCARD std::string* release_name(); ^ ; /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:535:3: error: unknown type name 'PROTOBUF_NODISCARD' PROTOBUF_NODISCARD std::string* release_s(); ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:535:27: error: non-friend class member 'string' cannot have a qualified name PROTOBUF_NODISCARD std::string* release_s(); ~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:535:27: error: duplicate member 'string' /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:517:27: note: previous declaration is here PROTOBUF_NODISCARD std::string* release_name(); ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:535:33: error: expected ';' at end of declaration list PROTOBUF_NODISCARD std::string* release_s(); ^ ; /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:553:3: error: unknown type name 'PROTOBUF_NODISCARD' PROTOBUF_NODISCARD std::string* release_doc_string(); ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:553:27: error: non-friend class member 'string' cannot have a qualified name PROTOBUF_NODISCARD std::string* release_doc_string(); ~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:553:27: error: duplicate member 'string' /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:517:27: note: previous declaration is here PROTOBUF_NODISCARD std::string* release_name(); ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:553:33: error: expected ';' at end of declaration list PROTOBUF_NODISCARD std::string* release_doc_string(); ^ ; [ 42%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/misc/tensorflow/attr_value.pb.cc.o /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:571:3: error: unknown type name 'PROTOBUF_NODISCARD' PROTOBUF_NODISCARD std::string* release_ref_attr_name(); ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/onnx/opencv-onnx.pb.h:571:27: error: non-friend class member 'string' cannot have a qualified name PROTOBUF_NODISCARD std::string* release_ref_attr_name(); ~~~~~^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 1 warning and 20 errors generated. 20 errors generated. make[2]: *** [modules/dnn/CMakeFiles/opencv_dnn.dir/misc/onnx/opencv-onnx.pb.cc.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[2]: *** [modules/dnn/CMakeFiles/opencv_dnn.dir/misc/caffe/opencv-caffe.pb.cc.o] Error 1 [ 42%] Building CXX object modules/photo/CMakeFiles/opencv_photo.dir/src/contrast_preserve.cpp.o [ 42%] Building CXX object modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/grfmt_bmp.cpp.o In file included from /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/attr_value.pb.cc:4: /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/attr_value.pb.h:12:2: error: This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/attr_value.pb.h:13:2: error: incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/attr_value.pb.h:14:2: error: your headers. #error your headers. ^ [ 42%] Building CXX object modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/grfmt_exr.cpp.o In file included from /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/attr_value.pb.cc:4: In file included from /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/attr_value.pb.h:37: /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor.pb.h:12:2: error: This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor.pb.h:13:2: error: incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor.pb.h:14:2: error: your headers. #error your headers. ^ In file included from /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/attr_value.pb.cc:4: In file included from /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/attr_value.pb.h:37: In file included from /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor.pb.h:34: /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:12:2: error: This file was generated by a newer version of protoc which is #error This file was generated by a newer version of protoc which is ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:13:2: error: incompatible with your Protocol Buffer headers. Please update #error incompatible with your Protocol Buffer headers. Please update ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:14:2: error: your headers. #error your headers. ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:77:78: error: no type named 'ConstantInitialized' in namespace 'google::protobuf::internal' explicit constexpr TensorShapeProto_Dim(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:184:16: error: unknown type name 'ClassData' static const ClassData _class_data_; ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:185:43: error: no type named 'ClassData' in 'google::protobuf::Message' const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:203:3: error: unknown type name 'PROTOBUF_NODISCARD' PROTOBUF_NODISCARD std::string* release_name(); ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:203:27: error: non-friend class member 'string' cannot have a qualified name PROTOBUF_NODISCARD std::string* release_name(); ~~~~~^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:203:33: error: expected ';' at end of declaration list PROTOBUF_NODISCARD std::string* release_name(); ^ ; /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:91:9: error: use of undeclared identifier 'GetOwningArena' if (GetOwningArena() == from.GetOwningArena() ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:91:34: error: no member named 'GetOwningArena' in 'opencv_tensorflow::TensorShapeProto_Dim' if (GetOwningArena() == from.GetOwningArena() ~~~~ ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:131:9: error: use of undeclared identifier 'GetOwningArena' if (GetOwningArena() == other->GetOwningArena()) { ^ /Users/frewen/03.ProgramStudy/20.AI/04.Resource/opencv-library/opencv4.7.0/opencv-4.7.0/modules/dnn/misc/tensorflow/tensor_shape.pb.h:131:36: error: no member named 'GetOwningArena' in 'opencv_tensorflow::TensorShapeProto_Dim' if (GetOwningArena() == other->GetOwningArena()) { ~~~~~ ^ fatal error: too many errors emitted, stopping now [-ferror-limit=]
Mat image = imread("test.jpg"); if (image.empty()){ printf("Image not loaded"); return-1; } imshow("image", image);
waitKey(0); return0; }
最后,将 test.jpg 文件放在工程中,就可以编译了。
编译
执行命令:
1
cmake .
然后再执行命令,用于生成可执行文件
1
make
生成可执行文件.jpeg
对于已经生成好的可执行文件,通过如下命令来执行,就可以把图片展示出来了。
1
./HelloWorld
每次修改 C++ 代码,只需要执行 make 即可。
对于一些常见的错误,如:
1 2 3 4 5 6 7
Undefined symbols for architecture x86_64: "__ZN2cv6imreadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi", referenced from: _main in main.cpp.o "__ZN2cv6imshowERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_11_InputArrayE", referenced from: _main in main.cpp.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status