Skip to content

Quick Start

taotianran edited this page Feb 1, 2023 · 5 revisions
English | 简体中文

目录


We support most major operating systems, here we take armlinux and android as examples.

Let's start quickly with a demo:

Run in 5 minutes(armlinux)

step 1: Download release binary files from released packages.

step 2: Follow the instructions below to add the code.

create a main.cpp and copy the following code.

#include "flycv.h"

int main(int argc, char** argv) {
    fcv::Mat dst;
    fcv::Mat src = fcv::imread("user.jpg");
    fcv::resize(src, dst, fcv::Size(src.width() / 2, src.height() / 2));
    fcv::imwrite("resize.jpg", dst);

    return 0;
}

create a CMakeLists.txt at the same directory and copy the following code.

cmake_minimum_required(VERSION 3.10)
project(flycv_test)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/flycv/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/flycv/${ARCH})

add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME}
    libflycv_static.a
    libpng16.a
    libturbojpeg.a
    libz.a)

step 3: compile on armlinux

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release \
        -DARCH=aarch64 \
        ..
make

step 4: Run on the machine

./flycv_test

The result file "resize.jpg" will be generated.


Run in 5 minutes(Android)

step 1: Download release binary files from released packages.

step 2: Follow the instructions below to add the code.

create a main.cpp and copy the following code.

#include "flycv.h"

int main(int argc, char** argv) {
    fcv::Mat dst;
    fcv::Mat src = fcv::imread("user.jpg");
    fcv::resize(src, dst, fcv::Size(src.width() / 2, src.height() / 2));
    fcv::imwrite("resize.jpg", dst);

    return 0;
}

create a CMakeLists.txt at the same directory and copy the following code.

cmake_minimum_required(VERSION 3.10)
project(flycv_test)
add_compile_options(-std=c++11)
find_library(
    log-lib
    log)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/flycv/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/flycv/${ANDROID_ABI})

add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME}
    ${log-lib}
    libflycv_static.a
    libpng16.a
    libturbojpeg.a
    libz.a)

step 3: compile on local machine

We use android ndk to cross compile. Go to download if you don't have one locally.

export ANDROID_NDK={Your ndk path}
// such as: export ANDROID_NDK=/home/flycv/android-ndk-r16b

mkdir build
cd build
cmake -DANDROID_NDK=${ANDROID_NDK} \
        -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}"/build/cmake/android.toolchain.cmake \
        -DANDROID_ABI=arm64-v8a \
        -DANDROID_PLATFORM=android-21 \
        -DCMAKE_BUILD_TYPE=Release \
        ..

make -j4

step 4: Run on android terminal

adb push build/flycv_test /data/local/tmp/
adb push user.jpg /data/local/tmp/
adb shell
cd /data/local/tmp/
./flycv_test

You can download the result picture to local.

adb pull /data/local/tmp/resize.jpg

Clone this wiki locally