Skip to content

Commit

Permalink
Update build for 2019/3.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Jan 4, 2019
1 parent 2329e0a commit a12d30a
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 53 deletions.
39 changes: 20 additions & 19 deletions README.md
@@ -1,17 +1,16 @@
OpenCV 3.3.0 build for RoboRIO
OpenCV 3.4.5 build for RoboRIO
==============================

This is a set of scripts that will build OpenCV for the RoboRIO with bindings for:

* C++
* Python 3.6.0
* ~~Java~~ (currently broken, but FIRST provides that so I'm not going to fix it)
* Python 3.7

The result of the compilation process is a zipfile that can be turned into IPK
files using the [roborio-packages](https://github.com/robotpy/roborio-packages)
repository.

**NOTE**: For 2017, OpenCV 3.1.0 is well-supported for C++ and Java by WPILib,
**NOTE**: For 2017+, OpenCV 3.x is well-supported for C++ and Java by WPILib,
so if you're looking to use those languages you should use their stuff instead.

RoboRIO Installation
Expand All @@ -21,14 +20,14 @@ The easiest way to install these packages is to set up the RobotPy opkg feed
on your RoboRIO. Create a `.conf` file in `/etc/opkg` (e.g. `/etc/opkg/robotpy.conf`)
containing the following line:

src/gz robotpy http://www.tortall.net/~robotpy/feeds/2017
src/gz robotpy http://www.tortall.net/~robotpy/feeds/2019

Once the feed is added, issue an `opkg update` and then you can install
packages using the following commands (requires internet access).

For Python3:

opkg install python36-opencv3
opkg install python37-opencv3

For C++:

Expand All @@ -44,11 +43,11 @@ Offline Installation
You can use the [RobotPy Installer Script](https://github.com/robotpy/robotpy-wpilib/blob/master/installer/installer.py)
to do offline opkg installs. First, download the package:

python3 installer.py download-opkg opencv3
python3 installer.py download-opkg python37-opencv3

Then, connect to the network with the RoboRIO, and install it:

python3 installer.py install-opkg opencv3
python3 installer.py install-opkg python37-opencv3

Manual Installation
-------------------
Expand All @@ -71,26 +70,28 @@ Building your own version of OpenCV
===================================

You probably just want to use the compiled version on our releases page or from
our opkg feed. This build has only been tested on Ubuntu 14.04 using the
included VM configuration.
our opkg feed. This build has only been tested on Linux using docker as directed
below.

Build steps
-----------

First, install [Vagrant](https://www.vagrantup.com/). Then...
First, install [docker](https://docs.docker.com/). Then run:

vagrant up
vagrant ssh
sudo /vagrant/fetch.sh
/vagrant/build.sh
./launch.sh

If you're building on your own Linux host, you can probably just execute the
following:
This will give you a shell in the docker container. You can then run:

sudo ./fetch.sh
./fetch.sh
./build.sh

But... I'd recommend using the VM instead.
If you're building on your own Linux host that has cmake and the FRC toolchain
installed, you can probably just execute the following:

./fetch.sh
./build.sh

But... I'd recommend using the docker image instead.

Troubleshooting
---------------
Expand Down
9 changes: 0 additions & 9 deletions Vagrantfile

This file was deleted.

16 changes: 10 additions & 6 deletions build.sh
@@ -1,14 +1,15 @@
#!/bin/bash -ex

OPENCV_VERSION=3.4.0
PYTHON_VERSION=3.6
OPENCV_VERSION=3.4.5
PYTHON_VERSION=3.7

pushd `dirname $0`
ROOT=`pwd`
popd

BUILD=`pwd`/build
SYSROOT="$BUILD"/sysroot
CMAKE_TOOLCHAIN_FILE=$(pwd)/toolchain.cmake
CVDIR="$ROOT"/opencv-${OPENCV_VERSION}

function unpack_download {
Expand Down Expand Up @@ -40,7 +41,7 @@ function assert_path {
# exit 1
# fi

sed -i 's/arm-linux-gnueabi/arm-frc-linux-gnueabi/g' "$CVDIR"/platforms/linux/arm-gnueabi.toolchain.cmake
sed -i 's/arm-linux-gnueabi/arm-frc2019-linux-gnueabi/g' "$CVDIR"/platforms/linux/arm-gnueabi.toolchain.cmake

[ -d build ] || mkdir build
pushd build
Expand All @@ -64,12 +65,15 @@ assert_path -d "$PYTHON3_INCLUDE_PATH"
assert_path -f "$PYTHON3_LIBRARY"
assert_path -d "$PYTHON3_NUMPY_INCLUDE_DIRS"

CMAKE_PREFIX_PATH="$SYSROOT"/usr/local frcmake \
-DOPENCV_VCSVERSION=${OPENCV_VERSION} -DCMAKE_SYSTEM_PROCESSOR=cortexa9-vfpv3 \
CMAKE_PREFIX_PATH="$SYSROOT"/usr/local cmake \
-DCMAKE_TOOLCHAIN_FILE="${CMAKE_TOOLCHAIN_FILE}" \
-DOPENCV_VCSVERSION=${OPENCV_VERSION} \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_NEON=ON -DENABLE_VFPV3=ON \
-DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF \
-DWITH_OPENCL=NO \
-DOPENCV_SKIP_PYTHON_LOADER=ON \
-DOPENCV_PYTHON3_INSTALL_PATH=lib/python3.7/site-packages \
"-DPYTHON3_INCLUDE_PATH=${PYTHON3_INCLUDE_PATH}" \
"-DPYTHON3_INCLUDE_DIR=${PYTHON3_INCLUDE_PATH}" \
"-DPYTHON3_INCLUDE_DIR2=${PYTHON3_INCLUDE_PATH}" \
Expand All @@ -84,5 +88,5 @@ fi
make $MAKEARGS

cpack -G TGZ
mv OpenCV-${OPENCV_VERSION}-cortexa9-vfpv3.tar.gz ${ROOT}/OpenCV-${OPENCV_VERSION}-cortexa9-vfpv3.tar.gz
mv OpenCV-${OPENCV_VERSION}-arm.tar.gz ${ROOT}/OpenCV-${OPENCV_VERSION}-cortexa9-vfpv3.tar.gz
popd
6 changes: 3 additions & 3 deletions deps
@@ -1,3 +1,3 @@
https://www.tortall.net/~robotpy/feeds/2018/python36_3.6.4-r0_cortexa9-vfpv3.ipk
https://www.tortall.net/~robotpy/feeds/2018/python36-dev_3.6.4-r0_cortexa9-vfpv3.ipk
https://www.tortall.net/~robotpy/feeds/2018/python36-numpy_1.13.1_cortexa9-vfpv3.ipk
https://www.tortall.net/~robotpy/feeds/2019/python37_3.7.2-r0_cortexa9-vfpv3.ipk
https://www.tortall.net/~robotpy/feeds/2019/python37-dev_3.7.2-r0_cortexa9-vfpv3.ipk
https://www.tortall.net/~robotpy/feeds/2019/python37-numpy_1.15.4_cortexa9-vfpv3.ipk
32 changes: 16 additions & 16 deletions fetch.sh
@@ -1,6 +1,6 @@
#!/bin/bash -e

OPENCV_VERSION=3.4.0
OPENCV_VERSION=3.4.5

cd `dirname $0`

Expand All @@ -13,16 +13,16 @@ function download {
fi
}

if ! which apt-add-repository; then
apt update
apt install -y software-properties-common
fi
# if ! which apt-add-repository; then
# apt update
# apt install -y software-properties-common
# fi

if ! which frcmake; then
apt-add-repository ppa:wpilib/toolchain-beta
apt update
apt install -y frc-toolchain frcmake
fi
# if ! which frcmake; then
# apt-add-repository ppa:wpilib/toolchain-beta
# apt update
# apt install -y frc-toolchain frcmake
# fi

# Note: Java build seems to be broken (needs JNI?), since FIRST provides java
# builds I'm not going to spend the time to fix it
Expand All @@ -36,13 +36,13 @@ fi
# apt install -y ant
#fi

if ! which unzip; then
apt install -y unzip
fi
# if ! which unzip; then
# apt install -y unzip
# fi

if ! which python; then
apt install -y python
fi
# if ! which python; then
# apt install -y python
# fi

DEPS=`cat deps`

Expand Down
3 changes: 3 additions & 0 deletions launch.sh
@@ -0,0 +1,3 @@
#!/bin/bash

docker run --hostname roborio-opencv --rm -it -v $(pwd):/build:Z -w /build wpilib/roborio-cross-ubuntu:2019-18.04 /bin/bash
15 changes: 15 additions & 0 deletions toolchain.cmake
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.8)
set(ARM_PREFIX arm-frc2019-linux-gnueabi)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSROOT /usr/local/${ARM_PREFIX})

set(CMAKE_C_COMPILER ${ARM_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${ARM_PREFIX}-g++)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

include("${CMAKE_CURRENT_LIST_DIR}/opencv-3.4.5/platforms/linux/arm-gnueabi.toolchain.cmake")

0 comments on commit a12d30a

Please sign in to comment.