linking opencv4.1.0 with code::blocks on Jetson nano

asked 2019-09-26 10:18:57 -0500

Gandalf2019 gravatar image

Hi,

I installed opencv 4.1.0 using the following modified installer it worked perfect (you only need to increase memory swap - I increased it to 8GB). install_opencv4.1.0_Nano.sh (here is the following code for your use by the end of this post - without swap modification).

running it on terminal using: $ sudo ./install_opencv4.1.0_Nano.sh /opencv

I made some modification in the original file, one of them is that i skipped installing python 2 binding if someone need it change the flag -D BUILD_opencv_python2=OFF to ON).

After installation, when running opencv c++ code using cmake and CMakeLists.txt (as recommended by opencv) everything works perfectly (i tested opencv version and get 4.1.0), I've tested cuda acceleration with opencv and it works, perfectly. i tested python 3 as well and everything works good.

I downloaded and install latest code::blocks IDE, and tested the hello world with native GCC compiler (default).

when trying to link opencv and use this IDE nothing works, no auto-complete, build errors etc. i set the following:

  • compiler search directories: /usr/local/include/opencv4/

  • linker tab - usr/local/bin/

  • tried list of libs.

the code is:

#include <iostream>
#include <opencv2/opencv.hpp>

int main()

{
cv::Mat A;
std::cout << "Hello" << std::endl;
return 0;
}

if i comment the line:

//cv::Mat A;

I can build and run, if it isn't commented it wont build. linking error. Did opencv changed linking paths and libs from previous versions? if from 4.x it changed please advise. (i can't search the whole system)

and BTW pkg-config doesn't work.

I'll appreciate if someone will try the installer below, and provide instructions (for dummies), how to link latest code:blocks IDE with this opencv installation that can be build and run\debug using it, with autocomplete.

many thanks

    #!/bin/bash
#
# Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA Corporation and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA Corporation is strictly prohibited.
#

if [ "$#" -ne 1 ]; then
    echo "Usage: $0 <Install Folder>"
    exit
fi
folder="$1"
user="nvidia"
passwd="nvidia"

echo "** Remove OpenCV3.3 first"
sudo sudo apt-get purge *libopencv*

echo "** Install requirement"
sudo apt-get update
sudo apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install -y python2.7-dev python3.6-dev python-dev python-numpy python3-numpy
sudo apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp
sudo apt-get install -y curl
sudo apt-get update

echo "** Download opencv-4.1.0"
cd $folder
curl -L https://github.com/opencv/opencv/archive/4.1.0.zip -o opencv-4.1.0.zip
curl -L https://github.com/opencv/opencv_contrib/archive/4.1.0.zip -o opencv_contrib-4.1.0.zip
unzip opencv-4 ...
(more)
edit retag flag offensive close merge delete