How to compile OpenCV in HEVC with Cmake? - opencv

I am modifying HEVC opensource project downloaded from bitbucket.
I have added OpenCV libraries now for some frame processing.
Code works fine with visual studio.
Problem is when I try to make it with cmake following error is producing:
libx265.so.102: undefined reference to `cv::dilate(cv::_InputArray const&, cv::_OutputArray const&, cv::_InputArray const&, cv::Point_<int>, int, int, cv::Scalar_<double> const&)'

Related

undefined reference to cv::ml with opencv_ml and opencv_objdetect

When developing a program, I tried to use opencv to open a CSV file. And I wrote
#include <opencv2/opencv.hpp>
#include <opencv2/ml.hpp>
// ...
cv::Ptr<cv::ml::TrainData> mlData = cv::ml::TrainData::loadFromCSV("train.csv", 1);
And My CMakeLists.txt, according to OpenCV doc, is
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
link_directories(${OpenCV_LIBRARY_DIRS})
message(STATUS "${OpenCV_LIBS}")
add_executable(Test ${EXAMPLE_DIR}/test.cpp)
target_link_libraries(Test ${OpenCV_LIBS} ${PROJECT_NAME})
But I got a undefined Error:
undefined reference to `cv::ml::TrainData::loadFromCSV(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char, char)'
I know it was because some opencv libs weren't linked. However, Print-Info In CMakeLists.txt told me that:
-- opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio
It seems that I linked all the libs I could but I still got an undefined error.
Ok, after serval times compiling and carefully consideration, I finally found what's wrong with my program.
The big problem is the link order. I just put ${OpenCV_LIBS} before ${PROJECT_NAME}. When I wrote:
target_link_libraries(Test ${PROJECT_NAME} ${OpenCV_LIBS})
target_link_libraries(Train ${PROJECT_NAME} ${OpenCV_LIBS})
Then All is well.

Caffe build fails repeatedly

I am trying to compile the software OpenPose on an Ubuntu 14 machine. The installation script installs Caffe. While installing Caffe, I get the following error message:
CXX tools/upgrade_net_proto_text.cpp
CXX/LD -o .build_release/tools/upgrade_net_proto_text.bin
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
make: *** [.build_release/tools/upgrade_net_proto_text.bin] Error 1
From here, I have tried running ldconfig, I use OpenCV 3.2.0, so I have uncommented that in the makefile. I have also tried updating the OpenCV path in ~/.bashrc but I am not sure if I did it correctly. I did:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
After each of these steps, I ran the install script again but it fails with the same error message (shown above) every time.
I haven't seen anyone so far who successfully installed caffe with openCV 3.2.0,i faced the same problem and what i did was to downgrade to OpenCV 3.1.Another problem that came along was missing modules that are in open_contrib that you should install along opencv,i d refer you to this answer also related to OpenPose here

OpenCV SFM Xcode 7.2: Undefined symbols for architecture x86_64: cv::sfm::reconstruct

I have linked to all the appropriate libraries and headers in my Xcode project (where I have the samples files from OpenCV for scene_reconstruction), after building and installing OpenCV with the contrib module.
I have also applied the #define CERES_FOUND true fix that is recommended here:
https://github.com/Itseez/opencv_contrib/issues/476
The editor prompts me with the correct functions completions from the sfm module and the reconstruct.hpp file (except that the prompts I get have the last boolean is_projective flag missing from all reconstruct()'s i.e.:
one of the prompts is:
reconstruct(<#const std::vector<std::string> images#>, <#OutputArray Rs#>, <#OutputArray Ts#>, <#InputOutputArray K#>, <#OutputArray points3d#>)
I however get:
Undefined symbols for architecture x86_64:
"cv::sfm::reconstruct(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, cv::_OutputArray const&, cv::_OutputArray const&, cv::_InputOutputArray const&, cv::_OutputArray const&, bool)", referenced from:
_main in scene_reconstruction.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
when I build the project.
I did a camera calibration in the same project and it ran fine, and everything else is alright, I have been using OpenCV built from source for years now, so I've taken care of the basics.
How do I proceed to fix/probe the issue further?
It was an issue with CERES_FOUND not being set because of a version mismatch between eigen and ceres.

How to build ZeroMQ on Xcode 5+ for iOS?

i am trying to build zmq 4.0.3 for iOS. i followed steps from here
i added two headers zmq.h and zmq_utils.h to copy files in target aggregate build phase (iOS framework). but when i added this framework to other project i got errors -
"std::__1::basic_string,
std::__1::allocator >::find(char const*, unsigned long, unsigned
long) const", referenced from:
zmq::socket_base_t::parse_uri(char const*,
std::__1::basic_string,
std::__1::allocator >&, std::__1::basic_string, std::__1::allocator >&) in
ZeroMQ-iOS(socket_base.o) "std::__1::basic_string, std::__1::allocator >::compare(char
const*) const", referenced from:
now i m confused what happened with .hpp files. i havent added this to anywhere while in compiled source is file witl all files having extension .cpp and .m.
if anyone had build this frame on xcode 5.0 so please give me instructions on how to build it.
how can i remove these linker error?

compilation error when using boost framework and opencv in ios project

I need to use boost framework in my iOS project. My first mission was getting boost to work for Ios. I tried using this script
http://goodliffe.blogspot.co.uk/2010/09/building-boost-framework-for-ios-iphone.html
but wasn't able to build due to lipo errors (?) and couldn't figure out how to solve it. I looked for a precompiled framework and came accross this project on github:
https://github.com/danomatika/ofxLua
There is an Ios version of boost included in the lib section. So I tried using it in my project
but now when I build my project I am getting these errors:
Undefined symbols for architecture i386:
"vtable for boost::filesystem::detail::utf8_codecvt_facet", referenced from:
(anonymous namespace)::path_locale() in boost(path.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"_inflate", referenced from:
MatlabIO::uncompressVariable(unsigned int&, unsigned int&, unsigned int&, std::vector<char, std::allocator<char> > const&) in MatlabIO.o
"_inflateEnd", referenced from:
MatlabIO::uncompressVariable(unsigned int&, unsigned int&, unsigned int&, std::vector<char, std::allocator<char> > const&) in MatlabIO.o
"_inflateInit_", referenced from:
MatlabIO::uncompressVariable(unsigned int&, unsigned int&, unsigned int&, std::vector<char, std::allocator<char> > const&) in MatlabIO.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I also want to make clear that I installed boost using
sudo port install boost
and under my xcode project I am not linking to /usr/local/include/boost/ or something like that. It seems that it is compiling with incorrect architecture.
Any solution for this? Maybe the framework isn't compiled for Ios? Or is my project not referencing the correct version
You can use the BOOST 1.57.0 with ofxiOSBoost static libraries and headers:
https://github.com/danoli3/ofxiOSBoost
Releases for libc++ (c++11), libstdc++.
All build scripts are in the /scripts folder (updated Peter Goodliffe script)

Resources