Error building opencv on a raspberry pi 3 - opencv

I was following this example and received the following error when running make
In file included from /root/src/opencv-3.1.0/modules/videoio/src/cap_ffmpeg.cpp:45:0:
/root/src/opencv-3.1.0/modules/videoio/src/cap_ffmpeg_impl.hpp: In member function ‘bool OutputMediaStream_FFMPEG::open(const char*, int, int, double)’:
/root/src/opencv-3.1.0/modules/videoio/src/cap_ffmpeg_impl.hpp:2207:41: warning: ignoring return value of ‘int avformat_write_header(AVFormatContext*, AVDictionary**)’, declared with attribute warn_unused_result [-Wunused-result]
avformat_write_header(oc_, NULL);
^
Linking CXX shared library ../../lib/libopencv_videoio.so
/usr/bin/ld: /usr/local/lib/libx264.a(common.o): relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libx264.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:215: recipe for target 'lib/libopencv_videoio.so.3.1.0' failed
make[2]: *** [lib/libopencv_videoio.so.3.1.0] Error 1
CMakeFiles/Makefile2:4058: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
Makefile:147: recipe for target 'all' failed
make: *** [all] Error 2

I have successfully installed opencv on Raspberry Pi 3 by following the steps in the link http://www.pyimagesearch.com/2015/02/23/install-opencv-and-python-on-your-raspberry-pi-2-and-b/
The changes i made while following the steps are:
Use 'aptitude' instead of 'apt-get' and accept all recommendations given
Before following Step 11, run 'source ~/.profile'. To quit, run 'deactivate'
Hope this helps :)

Related

How to make ardrone autonomy package work on Jetson Nano?

I'm working on a Jetson Nano board and I need to connect it with a parrot ar drone 2.0, so in order to do that I would like to use the ardrone_autonomy package, but I can't do that because jetson has Ubuntu 18, which only supports ROS Melodic, which doesn't have this package.
Here is what I tried:
I built the package from this repository:
https://github.com/dsapandora/ardrone_autonomy
But I obtained this error:
/tmp/ccIoQjBo.s: Assembler messages:
/tmp/ccIoQjBo.s:128: Error: unknown mnemonic `bswap' -- `bswap x3'
generic.makefile:231: recipe for target '../../Soft/Build/targets_versions/vlib_PROD_MODE_Linux_4.9.140-tegra_GNU_Linux_usrbingcc_5.4.0/video_mem32.o' failed
make[8]: *** [../../Soft/Build/targets_versions/vlib_PROD_MODE_Linux_4.9.140-tegra_GNU_Linux_usrbingcc_5.4.0/video_mem32.o] Error 1
vlib.makefile:104: recipe for target 'all' failed
make[7]: *** [all] Error 2
Makefile:167: recipe for target 'build_vlib' failed
make[6]: *** [build_vlib] Error 2
Makefile:170: recipe for target 'all' failed
make[5]: *** [all] Error 2
Makefile:84: recipe for target 'build_libs' failed
make[4]: *** [build_libs] Error 2
Makefile:20: recipe for target 'all' failed
make[3]: *** [all] Error 2
ardrone_autonomy/CMakeFiles/ardronelib.dir/build.make:110: recipe for target '/catkin_ws/devel/src/ardronelib-stamp/ardronelib-build' failed
make[2]: *** [/catkin_ws/devel/src/ardronelib-stamp/ardronelib-build] Error 2
CMakeFiles/Makefile2:578: recipe for target 'ardrone_autonomy/CMakeFiles/ardronelib.dir/all' failed
make[1]: *** [ardrone_autonomy/CMakeFiles/ardronelib.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
After I resolved that using almost any solution from here:
https://github.com/AutonomyLab/ardrone_autonomy/issues/71
I can compile the package without problems but when I try to run the node, it says that the ardrone_driver has died, without any other information.
2.Then I tried to build the package in a docker under ROS Kinetic, but after getting the same bswap error as above, after applying the above solution I get this:
/tmp/ccFs5LFZ.s: Assembler messages:
/tmp/ccFs5LFZ.s:130: Error: unexpected characters following instruction at operand 2 -- `mov x4,x4,ror#8'
generic.makefile:231: recipe for target '../../Soft/Build/targets_versions/vlib_PROD_MODE_Linux_4.9.140- tegra_GNU_Linux_usrbingcc_5.4.0/video_mem32.o' failed
make[8]: *** [../../Soft/Build/targets_versions /vlib_PROD_MODE_Linux_4.9.140-tegra_GNU_Linux_usrbingcc_5.4.0 /video_mem32.o] Error 1
vlib.makefile:110: recipe for target 'all' failed
make[7]: *** [all] Error 2
Makefile:167: recipe for target 'build_vlib' failed
make[6]: *** [build_vlib] Error 2
Makefile:170: recipe for target 'all' failed
make[5]: *** [all] Error 2
Makefile:84: recipe for target 'build_libs' failed
make[4]: *** [build_libs] Error 2
Makefile:24: recipe for target 'all' failed
make[3]: *** [all] Error 2
ardrone_autonomy/CMakeFiles/ardronelib.dir/build.make:110: recipe for target '/ardrone_ws/devel/src/ardronelib-stamp/ardronelib-build' failed
make[2]: *** [/ardrone_ws/devel/src/ardronelib-stamp/ardronelib-build] Error 2
CMakeFiles/Makefile2:578: recipe for target 'ardrone_autonomy/CMakeFiles/ardronelib.dir/all' failed
make[1]: *** [ardrone_autonomy/CMakeFiles/ardronelib.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 2%] Built target _ardrone_autonomy_generate_messages_check_deps_matrix33
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j2" failed
And here is where I'm stuck, because as much as I know it is a problem of processor architecture (Jetson uses armv8), and all the above solutions are for armv7, but I don't know how to solve this. Please let me know if anyone else found a solution to this problem. Any help would be highly appreciated!
I finally solved the problem, here are the complete steps, if there is someone else who is struggling with the same problems:
I downloaded the docker image using:
sudo docker pull ros:kinetic-robot-xenial
And then followed this steps to run the image: http://wiki.ros.org/docker/Tutorials/Docker
The I cloned the ardrone_autonomy package in a worksapce, from the above link:
mkdir -p catkin_ws/src
cd catkin_ws/src
git clone https://github.com/dsapandora/ardrone_autonomy.git
apt-get update
cd ../
rosdep install --from-paths src --ignore-src -r -y
catkin_make
After the error with bswap appears, edit this file: devel/src/ardronelib/ARDroneLib/VP_SDK/VP_Os/linux/intrin.h and replace:
static INLINE uint32_t _byteswap_ulong(uint32_t value)
{
__asm("bswap %0":
"=r" (value):
"0" (value));
return value;
}
with this:
static INLINE uint32_t _byteswap_ulong(uint32_t value)
{
int32_t tmp;
__asm __volatile(
"eor %1, %2, %2, ror #16\n"
"bic %1, %1, #0x00ff0000\n"
"mov %0, %2, ror #8\n"
"eor %0, %0, %1, lsr #8"
: "=r" (value), "=r" (tmp)
: "r" (value)
);
return value;
}
and comment this line: _BitScanReverse(&index, code);
After you do this if you try to give it a catkin_make it should appear the last error which can be resolved "simply" (after you understand what is happening there :) ) just by replacing this line (from the same file as above):
"mov %0, %2, ror #8\n"
with:
"mov %0, %2\n"
and now should work just fine.
PS: Don't forget to source your workspace.
AR Drone 2.0 is still compatible.
Just Downgrade the firmware to 2.4.1 (i use this one) from
https://www.espaciodrone.com/todos-los-firmware-del-ar-drone-1-y-2/
Power up your AR.Drone
Connect your computer to the AR.Drone’s network
Open a telnet session to 192.168.1.1
type the following: echo "1.1.1" > /firmware/version.txt
press enter
type the following: echo "2.4.1" > /update/version.txt
Connect an FTP client to: 192.168.1.1 Port: 5551 (i use nautilius ctrl + l then ftp://192.168.1.1:5551)
Upload the downloaded plf file to the FTP server (AR.Drone)
Disconnect your computer from the AR.Drone
Disconnect the battery from the AR.Drone
Reconnect the battery
Wait about 5 minutes while the upgrade completes, leave your drone switched on
And use this git clone https://github.com/dsapandora/ardrone...
It works like a charm...

Facing issue installing openCV 2.4.9 on ubuntu 18.04

I am trying to install openCv on ubuntu 18.0
I have followed steps of this blog
But when I run this command
make
it throws the following error
[ 57%] Built target opencv_perf_ocl
[ 57%] Built target opencv_nonfree
[ 57%] Built target opencv_perf_nonfree
[ 58%] Built target opencv_test_nonfree
[ 58%] Building CXX object modules/contrib/CMakeFiles/opencv_contrib.dir/src/chamfermatching.cpp.o
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp: In member function ‘void cv::ChamferMatcher::Matching::computeDistanceTransform(cv::Mat&, cv::Mat&, cv::Mat&, float, float, float)’:
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:969:30: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
if (&annotate_img!=NULL) {
^
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1016:34: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
if (&annotate_img!=NULL) {
^
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp: In member function ‘cv::ChamferMatcher::Match* cv::ChamferMatcher::Matching::localChamferDistance(cv::Point, cv::Mat&, cv::Mat&, cv::ChamferMatcher::Template*, float)’:
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1111:25: error: the compiler can assume that the address of ‘orientation_img’ will never be NULL [-Werror=address]
if (&orientation_img!=NULL) {
^
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1111:5: warning: nonnull argument ‘orientation_img’ compared to NULL [-Wnonnull-compare]
if (&orientation_img!=NULL) {
^~
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp: In member function ‘void cv::ChamferMatcher::Matching::computeDistanceTransform(cv::Mat&, cv::Mat&, cv::Mat&, float, float, float)’:
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:1016:17: warning: nonnull argument ‘annotate_img’ compared to NULL [-Wnonnull-compare]
if (&annotate_img!=NULL) {
^~
/home/knoldus/opencv-2.4.9/modules/contrib/src/chamfermatching.cpp:969:13: warning: nonnull argument ‘annotate_img’ compared to NULL [-Wnonnull-compare]
if (&annotate_img!=NULL) {
^~
cc1plus: some warnings being treated as errors
modules/contrib/CMakeFiles/opencv_contrib.dir/build.make:158: recipe for target 'modules/contrib/CMakeFiles/opencv_contrib.dir/src/chamfermatching.cpp.o' failed
make[2]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/src/chamfermatching.cpp.o] Error 1
CMakeFiles/Makefile2:2974: recipe for target 'modules/contrib/CMakeFiles/opencv_contrib.dir/all' failed
make[1]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2
Installing old versions of opencv can cause a lot problems as stated in this question (check comments).
Solution for Cmake errors regarding detection of CXXCompiler can be
found here
Solution for fatal error: stdlib.h: No such file or directory can
be found here
Solution for the make error stated in the latest edition of the
question can be found in the patch here

SIZE_MAX not declared when trying to build opencv-2.4.10 on raspbian wheezy

I'm trying to build opencv-2.4.10 on my Raspberry Pi model B (wheezy) following these instructions but am getting the error below. What's the best way of fixing this?
[ 14%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_jpeg2000.cpp.o
In file included from /usr/include/jasper/jasper.h:77:0,
from /home/pi/opencv-2.4.10/modules/highgui/src/grfmt_jpeg2000.cpp:58:
/usr/include/jasper/jas_math.h: In function ‘int jas_safe_size_mul(size_t, size_t, size_t*)’:
/usr/include/jasper/jas_math.h:117:22: error: ‘SIZE_MAX’ was not declared in this scope
modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:422: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_jpeg2000.cpp.o' failed
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_jpeg2000.cpp.o] Error 1
CMakeFiles/Makefile2:1772: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
Makefile:133: recipe for target 'all' failed
make: *** [all] Error 2
I'm not sure if its best practice but after trying to correct by defining __STDC_LIMIT_MACROS, I gave up and edited /usr/include/jasper/jas_math.h, adding
#if ! defined SIZE_MAX
#define SIZE_MAX (4294967295U)
#endif
right after
#include <stdint.h>

Compiling ROS Kinetec from source fails when building opencv

I'm using an Arch machine and trying to compile ROS desktop full from source. The build fails when image_proc is trying to link executable.
Here is the error log:
[ 23%] Built target image_proc_gencfg
[ 84%] Built target image_proc
[ 92%] Linking CXX executable /home/alphayed/ROS/ros_catkin_ws/devel_isolated/image_proc/lib/image_proc/image_proc
/home/alphayed/ROS/ros_catkin_ws/install_isolated/lib/libopencv_viz3.so.3.1.0: undefined reference to `vtkSTLReader::New()'
/home/alphayed/ROS/ros_catkin_ws/install_isolated/lib/libopencv_viz3.so.3.1.0: undefined reference to `vtkOBJReader::New()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/image_proc_exe.dir/build.make:219: /home/alphayed/ROS/ros_catkin_ws/devel_isolated/image_proc/lib/image_proc/image_proc] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/image_proc_exe.dir/all] Error 2
make: *** [Makefile:139: all] Error 2
I think the problem is related to opencv3. I removed it from the system and recompiled it from source but that didn't solve the issue. Can you please help?
I have found a fix as per this thread. You need to modify opencv3/cmake/OpenCVDetectVTK.cmake, for every find_package(VTK QUIET COMPONENTS ... add an entry vtkIOGeometry

Wireshark make error: undefined reference to symbol 'g_module_name'

I'm trying to compile wireshark-P2P-1.7.0 but it fails showing the following error:
/usr/bin/ld: gtk/libui.a(libui_a-plugins_dlg.o): undefined reference to symbol 'g_module_name'
//usr/lib/i386-linux-gnu/libgmodule-2.0.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [wireshark] Error 1
make[2]: Leaving directory `/home/sniffer/Desktop/P2P_install/Sigma_Sniffer-P2P-Ubuntu_v8.1.0/wireshark-P2P-1.7.0'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/sniffer/Desktop/P2P_install/Sigma_Sniffer-P2P-Ubuntu_v8.1.0/wireshark-P2P-1.7.0'
make: *** [all] Error 2
I'm not sure if it requires special libraries to run on a 64bit processor since this version of wireshark is 32 bit.
I cannot use a standard version of wireshark or download it from anywhere else. I have to use this one because is specially configure to make WFA tests.
Thank you!!
Oscar.
The only way a source code version of Wireshark would "[be] 32 bit" would be if somebody had added code to it that assumed that long or pointer data types were 32-bit; no code in the Wireshark source from wireshark.org is "32 bit" or "64 bit", it's all portable (and the Wireshark build infrastructure builds and tests both 32-bit and 64-bit versions).
What it does need is a version of GLib that includes g_module_name(), and you need to be linking with GLib (Wireshark uses it).

Resources