我尝试使用OpenCV3进行生物识别,但我遇到了一个问题:
biometrics.cpp:22:1: error: C++ requires a type specifier for all declarations
threshold(input, input_binary, 0, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);
^
1 error generated.
这是我的剧本:
/**********************************************************************************************
This code is part of the code supplied with the OpenCV Blueprints book.
It was written by Steven Puttemans, who can be contacted via steven.puttemans[at]kuleuven.be
***********************************************************************************************
Software for processing fingerprints
USAGE
./fingerprint_process
***********************************************************************************************/
#include "/usr/local/Cellar/opencv/3.3.1_1/include/opencv2/opencv.hpp"
#include "/usr/local/Cellar/opencv/3.3.1_1/include/opencv2/xfeatures2d.hpp"
#include <fstream>
using namespace std;
using namespace cv;
using namespace cv::xfeatures2d;
Mat input = imread("finger1.jpg", IMREAD_GRAYSCALE);
// Binarize the image, through local thresholding
Mat input_binary;
threshold(input, input_binary, 0, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);
我是一个不是C ++的Pythonic开发者,所以我想知道究竟是什么问题以及如何解决这个问题?
谢谢
编辑:
我写道:
int main( int argc, const char** argv )
{
Mat input = imread("finger1.jpg", IMREAD_GRAYSCALE);
// Binarize the image, through local thresholding
Mat input_binary;
threshold(input, input_binary, 0, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);
}
这个追溯:
Undefined symbols for architecture x86_64:
"cv::Mat::deallocate()", referenced from:
cv::Mat::release() in biometrics-d0af0e.o
"cv::String::deallocate()", referenced from:
cv::String::~String() in biometrics-d0af0e.o
cv::String::operator=(cv::String const&) in biometrics-d0af0e.o
"cv::String::allocate(unsigned long)", referenced from:
cv::String::String(char const*) in biometrics-d0af0e.o
"cv::imread(cv::String const&, int)", referenced from:
_main in biometrics-d0af0e.o
"cv::fastFree(void*)", referenced from:
cv::Mat::~Mat() in biometrics-d0af0e.o
"cv::threshold(cv::_InputArray const&, cv::_OutputArray const&, double, double, int)", referenced from:
_main in biometrics-d0af0e.o
"std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in biometrics-d0af0e.o
"std::__1::ios_base::getloc() const", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in biometrics-d0af0e.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(unsigned long, char)", referenced from:
std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in biometrics-d0af0e.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in biometrics-d0af0e.o
"std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in biometrics-d0af0e.o
"std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in biometrics-d0af0e.o
"std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(bool)", referenced from:
cvflann::anyimpl::small_any_policy<bool>::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, void* const*) in biometrics-d0af0e.o
"std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(float)", referenced from:
cvflann::anyimpl::small_any_policy<float>::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, void* const*) in biometrics-d0af0e.o
"std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(int)", referenced from:
cvflann::anyimpl::small_any_policy<int>::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, void* const*) in biometrics-d0af0e.o
cvflann::anyimpl::big_any_policy<cvflann::flann_algorithm_t>::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, void* const*) in biometrics-d0af0e.o
cvflann::anyimpl::big_any_policy<cvflann::flann_centers_init_t>::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, void* const*) in biometrics-d0af0e.o
"std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(unsigned int)", referenced from:
cvflann::anyimpl::small_any_policy<unsigned int>::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, void* const*) in biometrics-d0af0e.o
"std::__1::ctype<char>::id", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in biometrics-d0af0e.o
"std::__1::locale::~locale()", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in biometrics-d0af0e.o
"std::__1::ios_base::__set_badbit_and_consider_rethrow()", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in biometrics-d0af0e.o
"std::__1::ios_base::clear(unsigned int)", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in biometrics-d0af0e.o
"std::terminate()", referenced from:
___clang_call_terminate in biometrics-d0af0e.o
"typeinfo for char const*", referenced from:
cvflann::anyimpl::typed_base_any_policy<char const*>::type() in biometrics-d0af0e.o
"typeinfo for bool", referenced from:
cvflann::anyimpl::typed_base_any_policy<bool>::type() in biometrics-d0af0e.o
"typeinfo for float", referenced from:
cvflann::anyimpl::typed_base_any_policy<float>::type() in biometrics-d0af0e.o
"typeinfo for int", referenced from:
cvflann::anyimpl::typed_base_any_policy<int>::type() in biometrics-d0af0e.o
"typeinfo for unsigned int", referenced from:
cvflann::anyimpl::typed_base_any_policy<unsigned int>::type() in biometrics-d0af0e.o
"vtable for __cxxabiv1::__enum_type_info", referenced from:
typeinfo for cvflann::flann_algorithm_t in biometrics-d0af0e.o
typeinfo for cvflann::flann_centers_init_t in biometrics-d0af0e.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for __cxxabiv1::__class_type_info", referenced from:
typeinfo for cvflann::anyimpl::base_any_policy in biometrics-d0af0e.o
typeinfo for cvflann::anyimpl::empty_any in biometrics-d0af0e.o
typeinfo for cv::String in biometrics-d0af0e.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for __cxxabiv1::__si_class_type_info", referenced from:
typeinfo for cvflann::anyimpl::typed_base_any_policy<cvflann::anyimpl::empty_any> in biometrics-d0af0e.o
typeinfo for cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any> in biometrics-d0af0e.o
typeinfo for cvflann::anyimpl::typed_base_any_policy<char const*> in biometrics-d0af0e.o
typeinfo for cvflann::anyimpl::small_any_policy<char const*> in biometrics-d0af0e.o
typeinfo for cvflann::anyimpl::typed_base_any_policy<int> in biometrics-d0af0e.o
typeinfo for cvflann::anyimpl::small_any_policy<int> in biometrics-d0af0e.o
typeinfo for cvflann::anyimpl::typed_base_any_policy<float> in biometrics-d0af0e.o
...
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"operator delete(void*)", referenced from:
cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any>::static_delete(void**) in biometrics-d0af0e.o
cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any>::~big_any_policy() in biometrics-d0af0e.o
cvflann::anyimpl::typed_base_any_policy<cvflann::anyimpl::empty_any>::~typed_base_any_policy() in biometrics-d0af0e.o
cvflann::anyimpl::base_any_policy::~base_any_policy() in biometrics-d0af0e.o
cvflann::anyimpl::small_any_policy<char const*>::~small_any_policy() in biometrics-d0af0e.o
cvflann::anyimpl::typed_base_any_policy<char const*>::~typed_base_any_policy() in biometrics-d0af0e.o
cvflann::anyimpl::small_any_policy<int>::~small_any_policy() in biometrics-d0af0e.o
...
"operator new(unsigned long)", referenced from:
cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any>::copy_from_value(void const*, void**) in biometrics-d0af0e.o
cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any>::clone(void* const*, void**) in biometrics-d0af0e.o
cvflann::anyimpl::big_any_policy<cvflann::flann_algorithm_t>::copy_from_value(void const*, void**) in biometrics-d0af0e.o
cvflann::anyimpl::big_any_policy<cvflann::flann_algorithm_t>::clone(void* const*, void**) in biometrics-d0af0e.o
cvflann::anyimpl::big_any_policy<cvflann::flann_centers_init_t>::copy_from_value(void const*, void**) in biometrics-d0af0e.o
cvflann::anyimpl::big_any_policy<cvflann::flann_centers_init_t>::clone(void* const*, void**) in biometrics-d0af0e.o
cvflann::anyimpl::big_any_policy<cv::String>::copy_from_value(void const*, void**) in biometrics-d0af0e.o
...
"___cxa_begin_catch", referenced from:
___clang_call_terminate in biometrics-d0af0e.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in biometrics-d0af0e.o
"___cxa_end_catch", referenced from:
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in biometrics-d0af0e.o
"___cxa_pure_virtual", referenced from:
vtable for cvflann::anyimpl::typed_base_any_policy<cvflann::anyimpl::empty_any> in biometrics-d0af0e.o
vtable for cvflann::anyimpl::base_any_policy in biometrics-d0af0e.o
vtable for cvflann::anyimpl::typed_base_any_policy<char const*> in biometrics-d0af0e.o
vtable for cvflann::anyimpl::typed_base_any_policy<int> in biometrics-d0af0e.o
vtable for cvflann::anyimpl::typed_base_any_policy<float> in biometrics-d0af0e.o
vtable for cvflann::anyimpl::typed_base_any_policy<bool> in biometrics-d0af0e.o
vtable for cvflann::anyimpl::typed_base_any_policy<cvflann::flann_algorithm_t> in biometrics-d0af0e.o
...
"___gxx_personality_v0", referenced from:
_main in biometrics-d0af0e.o
cv::_OutputArray::_OutputArray(cv::Mat&) in biometrics-d0af0e.o
cvflann::anyimpl::big_any_policy<cvflann::anyimpl::empty_any>::~big_any_policy() in biometrics-d0af0e.o
cvflann::anyimpl::typed_base_any_policy<cvflann::anyimpl::empty_any>::~typed_base_any_policy() in biometrics-d0af0e.o
cvflann::anyimpl::base_any_policy::~base_any_policy() in biometrics-d0af0e.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in biometrics-d0af0e.o
std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in biometrics-d0af0e.o
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
答案 0 :(得分:1)
你似乎错过了一个主要功能:
/**********************************************************************************************
This code is part of the code supplied with the OpenCV Blueprints book.
It was written by Steven Puttemans, who can be contacted via steven.puttemans[at]kuleuven.be
***********************************************************************************************
Software for processing fingerprints
USAGE
./fingerprint_process
***********************************************************************************************/
#include "/usr/local/Cellar/opencv/3.3.1_1/include/opencv2/opencv.hpp"
#include "/usr/local/Cellar/opencv/3.3.1_1/include/opencv2/xfeatures2d.hpp"
#include <fstream>
using namespace std;
using namespace cv;
using namespace cv::xfeatures2d;
void main(){
Mat input = imread("finger1.jpg", IMREAD_GRAYSCALE);
// Binarize the image, through local thresholding
Mat input_binary;
threshold(input, input_binary, 0, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);
}
答案 1 :(得分:0)
就我而言,我只是换了
CV_THRESH_BINARY_INV
到
THRESH_BINARY_INV
对我有用:)